Documentation
¶
Overview ¶
Package pinata is used to send requests to the Pinata pinByHash endpoint (https://pinata.cloud/documentation#PinByHash).
Index ¶
Constants ¶
const ( // DefaultEndpoint is the API endpoint to use for pinata. DefaultEndpoint = "https://api.pinata.cloud/pinning/addHashToPinQueue" // DefaultAuthEndpoint is the API endpoint to use for authentication testing. DefaultAuthEndpoint = "https://api.pinata.cloud/data/testAuthentication" // DefaultTimeout is maximum response time to wait before the client hangs up. DefaultTimeout = 42 * time.Second // MetaDataLimit is the maximum number of key value pairs permitted by Pinata in metadata. MetaDataLimit = 10 )
Variables ¶
var ( // ErrMetaLimit is issued when too many key value pairs are added to the Pinata metadata. ErrMetaLimit = fmt.Errorf("metadata capacity reached (only %d key values pairs allowed)", MetaDataLimit) )
Functions ¶
This section is empty.
Types ¶
type APIResponse ¶
APIResponse is a struct to unmarshal the Pinata API response into.
type Client ¶
Client handles pinata requests. It wraps the standard http.Client and adds the pinata requirements.
func NewClient ¶
NewClient takes an API Key, API Secret and the hostNode where the pinned CIDs are and returns a Client and any error.
Note: host can be blank ("") and it will be left out of pinByHash requests.
func (*Client) NewPinataRequest ¶
NewPinataRequest returns a http.NewRequest with the required headers required by Pinata.
func (*Client) PinByHashWithMetadata ¶
func (client *Client) PinByHashWithMetadata(cid string, metadata *Metadata) (*APIResponse, error)
PinByHashWithMetadata attaches metadata to the Pinata request.
For more details on using the metadata, see: pinata.cloud/documentation#PinByHash
type Metadata ¶
type Metadata struct { // Name is a custom name you can have for referencing your pinned content Name string `json:"name,omitempty"` // Keyvalues encode the metadata (as strings, numbers or ISO dates) Keyvalues map[string]interface{} `json:"keyvalues,omitempty"` }
Metadata is a general purpose data structure as described in the Pinata API docs.
"Similarily to other endpoints, Pinata also allows metadata to be attached to when pinning content by hash. This metadata can later be used for easy querying on what you've pinned with our userPinList request."
func NewMetadata ¶
NewMetadata initialises a Meatadata struct with the provided name.
type PinQueueRequest ¶
type PinQueueRequest struct { Cid string `json:"hashToPin"` PinataOptions map[string]interface{} `json:"pinataOptions,omitempty"` Metadata *Metadata `json:"pinataMetadata,omitempty"` }
PinQueueRequest is the request structure as outlined in https://pinata.cloud/documentation#PinByHash