Project

pika_sdk

0.0
The project is in a healthy, maintained state
Pika API sdk for ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.17
~> 10.0

Runtime

 Project Readme

Pika API Ruby Gem

View on Rubygems: rubygems.org/gems/pika_sdk

Installation

Add this line to your application's Gemfile:

gem 'pika_sdk'

And then execute:

$ bundle

Or install it yourself as:

$ gem install pika_sdk

Usage

If you don't have your API key, get one from pika.style. Check the documentation on how to get your API key

Initialise a client

require 'pika_sdk'

client = PikaSdk::Client.new('sk-he2jdus1cbz1dpt4mktgjyvx')

Generate image

response = client.generate_image_from_template('open-graph-image-1', {'title': 'From python sdk new'}, 'base64')
puts response['data']['base64']

Example

Base64 response format

require 'pika_sdk'

client = PikaSdk::Client.new('sk-he2jdus1cbz1dpt4mktgjyvx')

response = client.generate_image_from_template('open-graph-image-1', {'title': 'From ruby sdk'}, 'base64')
puts response['data']['base64']

Base64 output

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABLAAAAJ2CAYAAABPQHtcAAAAAXNSR0IArs4c6QAAIABJREFUeJzs3XmYJXdZL/Bvna37dM90FghLCBAQkC1BCBAMShLFBJAgKnofroBeFUUF5LrhiihXcV8BQRYVUUAlIewIGPbFmLCFLWwCYZEtzPR+trp/TM/......

Binary response format

require 'pika_sdk'

client = PikaSdk::Client.new('sk-he2jdus1cbz1dpt4mktgjyvx')

File.open("og.png", "w") do |file|
  response = client.generate_image_from_template('open-graph-image-1', {'title': 'From ruby sdk'}, 'binary')
  file.binmode
  file.write(response)
end

This example writes the binary image to the file og.png

generate_image_from_template

Use this function to generate an image. It takes in 3 arguments

argument required description
template_id Yes ID of the template (open-graph-image-1, tweet-image-1, beautify-screenshot-1, ...)
modifications Yes Modifications for the selected template.
response_format No base64 or binary (Defaults to base64).

For available templates and their modifications refer image generation api templates

Development

After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/rishimohan/pika-api-ruby-gem. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the PikaApi project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.