Numbers Loading Icon

Unlocking the Power of Web3: Pin Your Files on Decentralized Web with NUM-Powered API Service

Posted in:

Tools

Translation: Chinese | Hindi | Polish | French| Vietnamese

For many, owning crypto can be a challenge because of the lack of utility the tokens have outside of holding and staking. With token utility being a challenge towards mainstream adoption, the Numbers Protocol team is super excited to announce NUM tokens newest and hopefully most impactful use case to date.

Introducing NUM Powered Web3 API service!

Advertised as the next iteration of the World Wide Web, Web3.0 envisions an internet that leverages blockchain technology to create decentralized applications that can operate without intermediaries and allow users to retain more control over their data.

As attractive as that sounds, Web3.0 is still in its early stages with few services available to access Web3 services such as decentralized storage. Available services such as Infura and Pinata fill some of the Web3 void, however they require lengthy subscriptions to access. Being a decentralized photo network for Web3.0 and seeing a need for a more accessible Web3 API service as well as an opportunity to leverage NUM utility, we created an on-demand Web3 API service powered by NUM that users can leverage to pin files on decentralized Web as well as other Web3 file actions.

Let us see how it works!



First we need to create a Capture account and acquire a valid Capture Token. The easiest way to create a Capture account is by downloading Capture App and signing up via the app. Alternatively you can leverage services such as API and SDK to create a Capture Account. More details can be found here.

To obtain your Capture Token you can login with your credentials using the API to obtain your token. See below:

curl -X POST https://api.numbersprotocol.io/api/v3/auth/token/login/ \

     -H "Content-Type: application/json" \

     -d '{"email": "user@example.com","password": "your_password"}'

Sample response:

{

    "auth_token": "02e6fd05701f49a8d1bd94bf814cfcf0eba5b98a"

}

With Capture Token in hand we are ready to go! Let us find a file we want to pin to decentralized storage. The Numbers pin file API requires either a file url or file object to work. For this example we will be using file url. Click here to see the example file we are using in this example.

Numbers Pin File API Details:

API Endpoint: https://eoqctv92ahgrcif.m.pipedream.net

Cost: 0.025 NUM + Gas (~0.004 NUM per transaction) per file per month. No Gas is required if paid with Credits.

Method: POST

Description:

This API endpoint allows developers to pin a file to IPFS via the Numbers Gateway (https://ipfs-pin.numbersprotocol.io/ipfs/).

Authentication:

This API requires a valid token for Authorization. The token should be passed in the headers of the request using the following format: "Authorization: token YOUR_CAPTURE_TOKEN"

Header:

Authorization: token $YOUR_CAPTURE_TOKEN (required)

Content-Type: application/json

Request Body (required):

fileURL (string) or file (object): Either the URL of the file to be pinned or the file object itself must be specified. If the fileURL is used, it should be passed as a string. If the file object is used, it should be the direct upload from the system.

Request Body (optional):

pin (boolean): true to pin the file (default: true)

version (integer): CID version (default: 1)

Putting all of this together in Postman we get the following:

Response:

Done! The file has been pinned on IPFS. You can view the link here

Check out the full dev doc: https://docs.numbersprotocol.io/developers/more-tools/ipfs-pin-file-to-ipfs

As mentioned before, a key feature is the on-demand nature of the Numbers API. This means that uses are charged only for the files you pin making it a cost-effective solution. It is also important to point out that Numbers API is powered by NUM meaning all API calls are funded with NUM token or credits in your Capture Account (For this particular API it is 0.025 NUM per file + Gas fees). This is why it is necessary to create a Capture Account and top up your Capture Account wallet with sufficient funds otherwise your files may be unpinned. To acquire NUM you can acquire them on centralized exchanges such as KuCoin or Gate.io. Alternatively you can use Pancake Swap or Uniswap as an additional means of acquiring NUM. For NUM Credits you can acquire them in Capture App via in-app purchase.

Being able to utilize NUM to gain access to tangible services is an important step forward for expanding NUM’s utility and usefulness. We hope as we move forward, NUM can continue to play an important role in not only the Numbers Protocol ecosystem but also the Web3 space. We hope you are excited as we are.

You're signed up! Watch you inbox for updates.
Oops! Something went wrong while submitting the form.