https://github.com/andrew/ruby-ipfs-pinning-api-client
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.1%) to scientific vocabulary
Repository
Basic Info
- Host: GitHub
- Owner: andrew
- Language: Ruby
- Default Branch: master
- Size: 97.7 KB
Statistics
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
openapi_client
OpenapiClient - the Ruby gem for the IPFS Pinning Service API
About this spec
The IPFS Pinning Service API is intended to be an implementation-agnostic API: - For use and implementation by pinning service providers - For use in client mode by IPFS nodes and GUI-based applications
Document scope and intended audience
The intended audience of this document is IPFS developers building pinning service clients or servers compatible with this OpenAPI spec. Your input and feedback are welcome and valuable as we develop this API spec. Please join the design discussion at github.com/ipfs/pinning-services-api-spec.
IPFS users should see the tutorial at docs.ipfs.io/how-to/work-with-pinning-services instead.
Related resources
The latest version of this spec and additional resources can be found at: - Specification: https://github.com/ipfs/pinning-services-api-spec/raw/main/ipfs-pinning-service.yaml - Docs: https://ipfs.github.io/pinning-services-api-spec/ - Clients and services: https://github.com/ipfs/pinning-services-api-spec#adoption
Schemas
This section describes the most important object types and conventions.
A full list of fields and schemas can be found in the schemas section of the YAML file.
Identifiers
cid
Content Identifier (CID) points at the root of a DAG that is pinned recursively.
requestid
Unique identifier of a pin request.
When a pin is created, the service responds with unique requestid that can be later used for pin removal. When the same cid is pinned again, a different requestid is returned to differentiate between those pin requests.
Service implementation should use UUID, hash(accessToken,Pin,PinStatus.created), or any other opaque identifier that provides equally strong protection against race conditions.
Objects
Pin object

The Pin object is a representation of a pin request.
It includes the cid of data to be pinned, as well as optional metadata in name, origins, and meta.
Pin status response

The PinStatus object is a representation of the current state of a pinning operation.
It includes the original pin object, along with the current status and globally unique requestid of the entire pinning request, which can be used for future status checks and management. Addresses in the delegates array are peers delegated by the pinning service for facilitating direct file transfers (more details in the provider hints section). Any additional vendor-specific information is returned in optional info.
The pin lifecycle

Creating a new pin object
The user sends a Pin object to POST /pins and receives a PinStatus response:
- requestid in PinStatus is the identifier of the pin operation, which can can be used for checking status, and removing the pin in the future
- status in PinStatus indicates the current state of a pin
Checking status of in-progress pinning
status (in PinStatus) may indicate a pending state (queued or pinning). This means the data behind Pin.cid was not found on the pinning service and is being fetched from the IPFS network at large, which may take time.
In this case, the user can periodically check pinning progress via GET /pins/{requestid} until pinning is successful, or the user decides to remove the pending pin.
Replacing an existing pin object
The user can replace an existing pin object via POST /pins/{requestid}. This is a shortcut for removing a pin object identified by requestid and creating a new one in a single API call that protects against undesired garbage collection of blocks common to both pins. Useful when updating a pin representing a huge dataset where most of blocks did not change. The new pin object requestid is returned in the PinStatus response. The old pin object is deleted automatically.
Removing a pin object
A pin object can be removed via DELETE /pins/{requestid}.
Provider hints
A pinning service will use the DHT and other discovery methods to locate pinned content; however, it is a good practice to provide additional provider hints to speed up the discovery phase and start the transfer immediately, especially if a client has the data in their own datastore or already knows of other providers.
The most common scenario is a client putting its own IPFS node's multiaddrs in Pin.origins, and then attempt to connect to every multiaddr returned by a pinning service in PinStatus.delegates to initiate transfer. At the same time, a pinning service will try to connect to multiaddrs provided by the client in Pin.origins.
This ensures data transfer starts immediately (without waiting for provider discovery over DHT), and mutual direct dial between a client and a service works around peer routing issues in restrictive network topologies, such as NATs, firewalls, etc.
NOTE: Connections to multiaddrs in origins and delegates arrays should be attempted in best-effort fashion, and dial failure should not fail the pinning operation. When unable to act on explicit provider hints, DHT and other discovery methods should be used as a fallback by a pinning service.
NOTE: All multiaddrs MUST end with /p2p/{peerID} and SHOULD be fully resolved and confirmed to be dialable from the public internet. Avoid sending addresses from local networks.
Custom metadata
Pinning services are encouraged to add support for additional features by leveraging the optional Pin.meta and PinStatus.info fields. While these attributes can be application- or vendor-specific, we encourage the community at large to leverage these attributes as a sandbox to come up with conventions that could become part of future revisions of this API.
Pin metadata
String keys and values passed in Pin.meta are persisted with the pin object. This is an opt-in feature: It is OK for a client to omit or ignore these optional attributes, and doing so should not impact the basic pinning functionality.
Potential uses:
- Pin.meta[app_id]: Attaching a unique identifier to pins created by an app enables meta-filtering pins per app
- Pin.meta[vendor_policy]: Vendor-specific policy (for example: which region to use, how many copies to keep)
Filtering based on metadata
The contents of Pin.meta can be used as an advanced search filter for situations where searching by name and cid is not enough.
Metadata key matching rule is AND:
- lookup returns pins that have meta with all key-value pairs matching the passed values
- pin metadata may have more keys, but only ones passed in the query are used for filtering
The wire format for the meta when used as a query parameter is a URL-escaped stringified JSON object. A lookup example for pins that have a meta key-value pair {\"app_id\":\"UUID\"} is:
- GET /pins?meta=%7B%22app_id%22%3A%22UUID%22%7D
Pin status info
Additional PinStatus.info can be returned by pinning service.
Potential uses:
- PinStatus.info[status_details]: more info about the current status (queue position, percentage of transferred data, summary of where data is stored, etc); when PinStatus.status=failed, it could provide a reason why a pin operation failed (e.g. lack of funds, DAG too big, etc.)
- PinStatus.info[dag_size]: the size of pinned data, along with DAG overhead
- PinStatus.info[raw_size]: the size of data without DAG overhead (eg. unixfs)
- PinStatus.info[pinned_until]: if vendor supports time-bound pins, this could indicate when the pin will expire
Pagination and filtering
Pin objects can be listed by executing GET /pins with optional parameters:
- When no filters are provided, the endpoint will return a small batch of the 10 most recently created items, from the latest to the oldest.
- The number of returned items can be adjusted with the
limitparameter (implicit default is 10). - If the value in
PinResults.countis bigger than the length ofPinResults.results, the client can infer there are more results that can be queried. - To read more items, pass the
beforefilter with the timestamp fromPinStatus.createdfound in the oldest item in the current batch of results. Repeat to read all results. - Returned results can be fine-tuned by applying optional
after,cid,name,status, ormetafilters.
Note: pagination by the
createdtimestamp requires each value to be globally unique. Any future considerations to add support for bulk creation must account for this.
This SDK is automatically generated by the OpenAPI Generator project:
- API version: 1.0.0
- Package version: 1.0.0
- Build package: org.openapitools.codegen.languages.RubyClientCodegen
Installation
Build a gem
To build the Ruby code into a gem:
shell
gem build openapi_client.gemspec
Then either install the gem locally:
shell
gem install ./openapi_client-1.0.0.gem
(for development, run gem install --dev ./openapi_client-1.0.0.gem to install the development dependencies)
or publish the gem to a gem hosting service, e.g. RubyGems.
Finally add this to the Gemfile:
gem 'openapi_client', '~> 1.0.0'
Install from Git
If the Ruby gem is hosted at a git repository: https://github.com/GITUSERID/GITREPOID, then add the following in the Gemfile:
gem 'openapi_client', :git => 'https://github.com/GIT_USER_ID/GIT_REPO_ID.git'
Include the Ruby code directly
Include the Ruby code directly using -I as follows:
shell
ruby -Ilib script.rb
Getting Started
Please follow the installation procedure and then run the following code:
```ruby
Load the gem
require 'openapi_client'
Setup authorization
OpenapiClient.configure do |config| # Configure Bearer authorization: accessToken config.accesstoken = 'YOURBEARER_TOKEN' end
apiinstance = OpenapiClient::PinsApi.new
opts = {
cid: ['innerexample'], # Array
begin #List pin objects result = apiinstance.pinsget(opts) p result rescue OpenapiClient::ApiError => e puts "Exception when calling PinsApi->pins_get: #{e}" end
```
Documentation for API Endpoints
All URIs are relative to https://pinning-service.example.com
Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- OpenapiClient::PinsApi | pins_get | GET /pins | List pin objects OpenapiClient::PinsApi | pins_post | POST /pins | Add pin object OpenapiClient::PinsApi | pinsrequestiddelete | DELETE /pins/{requestid} | Remove pin object OpenapiClient::PinsApi | pinsrequestidget | GET /pins/{requestid} | Get pin object OpenapiClient::PinsApi | pinsrequestidpost | POST /pins/{requestid} | Replace pin object
Documentation for Models
- OpenapiClient::Failure
- OpenapiClient::FailureError
- OpenapiClient::Pin
- OpenapiClient::PinResults
- OpenapiClient::PinStatus
- OpenapiClient::Status
- OpenapiClient::TextMatchingStrategy
Documentation for Authorization
accessToken
- Type: Bearer authentication
Owner
- Name: Andrew Nesbitt
- Login: andrew
- Kind: user
- Location: Bristol, UK
- Company: @ecosyste-ms and @octobox
- Website: https://nesbitt.io
- Twitter: teabass
- Repositories: 357
- Profile: https://github.com/andrew
Working on mapping the world of open source software @ecosyste-ms and empowering developers with @octobox
GitHub Events
Total
Last Year
Committers
Last synced: 10 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Andrew Nesbitt | a****z@g****m | 6 |
Issues and Pull Requests
Last synced: 11 months ago
All Time
- Total issues: 1
- Total pull requests: 0
- Average time to close issues: 1 day
- Average time to close pull requests: N/A
- Total issue authors: 1
- Total pull request authors: 0
- Average comments per issue: 0.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- lidel (1)