The Pinata Ruby library provides convenient access to the Pinata API from applications written in the Ruby language. It includes a pre-defined set of classes for API resources that initialize themselves dynamically from API responses.
- Pinata
- Contents
- Documentation
- Installation
- Resources
- Development
- Contributing
- License
- Code of Conduct
See the Pinata API docs.
Add this line to your application's Gemfile:
gem 'pinata'And then execute:
bundle installOr install with:
gem install pinata- Ruby 2.6+.
To access the API, you'll need to create a Pinata::Client and pass in your API key. You can find your API key at https://app.pinata.cloud/developers/api-keys.
client = Pinata::Client.new(jwt_key: ENV["PINATA_JWT"])The gem maps as closely as we can to the Pinata API so you can easily convert API examples to gem code.
Responses are created as objects like Pinata::File. They're built using OpenStruct so you can easily access data in a Ruby-ish way.
List endpoints return pages of results. The result object will have a data key to access the results, as well as metadata like next_page_token for retrieving the next page.
results = client.files.list
#=> Pinata::Collection
results.data.size
#=> 48
results.data
#=> [#<Pinata::File>, #<Pinata::File>]
results.next_page_token
#=> "MDE5MzJjNzctMDg2Ny03ZTdhLWE2ZDEtMDRhZWRlZDNjMWI5"
# Retrieve the next page
client.files.list(pageToken: "MDE5MzJjNzctMDg2Ny03ZTdhLWE2ZDEtMDRhZWRlZDNjMWI5")
#=> Pinata::Collectionclient.authentication.testclient.files.upload(file: "/path/to/file")
client.files.list
client.files.list("metadata[key]": "value")
client.files.get(file_id: "1234567890")
client.files.sign("gateway": "yourgatewaydomain", "file_cid": "thefilecid", "expires": 500000)
client.files.update(file_id: "thefilesid", "name": "thenameoffile")
client.files.delete(file_id: "1234567890")client.groups.create({})
client.groups.get(group_id: "id")
client.groups.list
client.groups.add_file(group_id: "id", file_id: "id")
client.groups.remove_file(group_id: "id", file_id: "id")
client.groups.update(group_id: "id", {})
client.groups.delete(group_id: "id")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 the created tag, and push the .gem file to rubygems.org.
- Fork it ( https://github.com/onyxmueller/pinata-ruby/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Support it by joining stargazers for this repository. ⭐ And follow me for other creations.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the Pinata project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
