Pinning

Pin Files or Directory

This API allows you to pin a file to IPFS using the provided pinning API key and secret key.

Example metadata:

{
  "name": "sample name", 
  "keyvalues": {
    "key1": "value1",
    "key2": "value2"
  }
}

Example options (optional):

{
  "cid_version": 1,
  "wrap_with_directory": false,
  "vectorize": true
}
OptionDescription
cid_versionCID version of the pinned file.
wrap_with_directoryWrap the uploaded file in a directory.
vectorizeSet to true to create File Vectors for a single text file, so you can search it by meaning. The response then contains vectorize_status: "queued".

Vector Status

Every pin object returned by the endpoints on this page has a vectorize_status field. It tells you whether the file can be found with File Vectors. The values are not_requested (the default), queued, processing, completed, failed, and deleted. See Vector Status for what each value means and how failed files are retried.

vectorize_status is separate from status. status is the pinning state of the file, and vectorize_status is the search indexing state.

POSThttps://api.aiozpin.network/api/pinning

Headers

pinning_api_key* PINNING-API-KEY
pinning_secret_key* PINNING-SECRET-KEY

Body

file* Read stream representing the file
metadata Optional stringified object
options Optional stringified object, for example {"cid_version": 1, "wrap_with_directory": false, "vectorize": true}. Set vectorize to true to create File Vectors for a single text file. See File Vectors.

Response

201: Created
{
    "data": {
        "id": "string",
        "file_record_id": "string",
        "root_hash": "string",
        "cid": "string",
        "user_id": "string",
        "date_pinned": "2023-01-01T11:11:11.111111Z",
        "date_unpinned": "2023-11-11T11:11:11.111111Z",
        "pinned": false,
        "is_pin_by_hash": false,
        "sub_hash_status": "string",
        "is_dir": false,
        "metadata": {
            "name": "string",
            "type": "string"
        },
        "status": "string",
        "vectorize_status": "not_requested"
    },
    "status": "success"
}
curl --location --request POST 'https://api.aiozpin.network/api/pinning/' \
--header 'pinning_api_key: KEY' \
--header 'pinning_secret_key: SECRET' \
--form 'file=@"/test.png"'

Pin by CID

The request body when pin a file by CID will look like this:

{
    "hash_to_pin": "CID",
    "metadata": {
        "name": "string",
        "keyvalues": {
            "key1": "value1",
            "key2": "value2"
        }
    },
    "pin_options": {
        "vectorize": false
    }
}

pin_options is optional. Set pin_options.vectorize to true to create File Vectors for the file once it is pinned. The file must be a supported text file.

POSThttps://api.aiozpin.network/api/pinning/pinByHash

Headers

pinning_api_key* PINNING-API-KEY
pinning_secret_key* PINNING-SECRET-KEY

Body

hash_to_pin* CID
metadata Optional object
pin_options Optional object, for example {"vectorize": true}. See File Vectors.

Response

200: OK
{
    "data": {
        "id": "string",
        "file_record_id": "string",
        "root_hash": "string",
        "cid": "string",
        "user_id": "string",
        "date_pinned": "2023-01-01T11:11:11.111111Z",
        "date_unpinned": "2023-11-11T11:11:11.111111Z",
        "pinned": false,
        "is_pin_by_hash": true,
        "is_dir": false,
        "metadata": {
            "name": "string"
        },
        "status": "string",
        "vectorize_status": "not_requested"
    },
    "status": "success"
}
curl --location --request POST 'https://api.aiozpin.network/api/pinning/pinByHash' \
--header 'pinning_api_key: KEY' \
--header 'pinning_secret_key: SECRET' \
--header 'Content-Type: application/json' \
--data-raw '{
"hash_to_pin": "Qmc1135ziMvmFG534i75E8HpJoLqzLzgKBxfjBV9cBsMAs",
"metadata": {
    "name": "name-ipfs-hash"
}
}'

Get Pin Details by pinID

This code snippet makes a GET request to the /pinning/{pinId} endpoint, where {pinId} is the ID of the pin you want to retrieve information for.

GEThttps://api.aiozpin.network/api/pinning/:pinId

Parameters

pinId* pinId

Headers

pinning_api_key* PINNING-API-KEY
pinning_secret_key* PINNING-SECRET-KEY

Response

200: OK
{
    "data": {
        "id": "string",
        "file_record_id": "string",
        "root_hash": "string",
        "cid": "string",
        "size": number,
        "user_id": "string",
        "date_pinned": "2023-01-01T11:11:11.111111Z",
        "date_unpinned": "2023-11-11T11:11:11.111111Z",
        "pinned": true,
        "is_pin_by_hash": false,
        "sub_hash_status": "string",
        "is_dir": false,
        "metadata": {
            "name": "string",
            "type": "string"
        },
        "status": "string",
        "vectorize_status": "not_requested"
    },
    "status": "success"
}
curl --location --request GET 'https://api.aiozpin.network/api/pinning/3c3fec2a-ca65-4b8e-bcf3-c8e2ceaa23d2' \
--header 'pinning_api_key: KEY' \
--header 'pinning_secret_key: SECRET' 

List Pins of User

GEThttps://api.aiozpin.network/api/pinning/pins/

Query

offset (default 0)
limit (default 10)
pinned Filter by pinned status (options: all, true, false) (default all)
sortBy Field to sort by (options: created_at, size, name). Defaults to created_at.
sortOrder Sort direction (options: ASC, DESC). Defaults to DESC.
name Search by file name
metadata Stringified JSON of key values to filter by

Headers

pinning_api_key* PINNING-API-KEY
pinning_secret_key* PINNING-SECRET-KEY

Response

200: OK
{
    "data": {
        "totals": {
            "files": number,
            "size": number
        },
        "pins": [
            {
                "id": "string",
                "file_record_id": "string",
                "root_hash": "string",
                "cid": "string",
                "size": number,
                "user_id": "string",
                "date_pinned": "2023-01-01T11:11:11.111111Z",
                "date_unpinned": "2023-11-11T11:11:11.111111Z",
                "pinned": true,
                "is_pin_by_hash": true,
                "sub_hash_status": "string",
                "is_dir": false,
                "metadata": {
                    "name": "string"
                },
                "status": "string",
                "vectorize_status": "not_requested"
            }
        ]
    },
    "status": "success"
}
curl --location --request GET 'https://api.aiozpin.network/api/pinning/pins/?offset=0&limit=10&pinned=true&sortBy=name&sortOrder=ASC' \
--header 'pinning_api_key: KEY' \
--header 'pinning_secret_key: SECRET'

Remove Files (Unpin)

Unpinning a file does not delete its file vectors. To remove the file from query results, call Delete File Vectors.

DELETEhttps://api.aiozpin.network/api/pinning/unpin/:pinId

Parameters

pinId* pinId

Headers

pinning_api_key* PINNING-API-KEY
pinning_secret_key* PINNING-SECRET-KEY

Response

200: OK
{
    "data": {
        "id": "string",
        "file_record_id": "string",
        "root_hash": "string",
        "cid": "string",
        "size": number,
        "user_id": "string",
        "date_pinned": "2023-01-01T11:11:11.111111Z",
        "date_unpinned": "2023-11-11T11:11:11.111111Z",
        "pinned": true,
        "is_pin_by_hash": true,
        "is_dir": false,
        "metadata": {
            "name": "string"
        },
        "status": "string",
        "vectorize_status": "not_requested"
    },
    "status": "success"
}
curl --location --request DELETE 'https://api.aiozpin.network/api/pinning/unpin/e5c4456d-5e5c-465d-a02a-3a536fc6e718' \
--header 'pinning_api_key: KEY' \
--header 'pinning_secret_key: SECRET'

See Also