Tangocrypto
Search
⌃K

Client library

The Tangocrypto library is a small, user-friendly tool that allows you to integrate your JavaScript or TypeScript project in just a few minutes. In this guide, we'll cover the basics of creating a client object and introduce you to the most common and practical operations. If you're looking for more in-depth information, be sure to check out the complete client API documentation. And if you just want a quick overview of the library, check out the Quickstart guide.
We hope this guide helps you get up and running with the Tangocrypto library in no time! If you have any questions or need further assistance, don't hesitate to reach out.

Installation and importing

The tangocrypto-js NPM package can be added to your project with your favorite JS dependency manager:
npm i @tango-crypto/tangocrypto-js
How you import the client into your code will depend on whether your project uses ES Modules or the CommonJS require syntax:
First Tab
CommonJS (require)
import { Tangocrypto } from '@tango-crypto/tangocrypto-js';
const { Tangocrypto } = require('@tango-crypto/tangocrypto-js');

Creating a client object

To create an Tangocrypto client object, you'll need an Tangocrypto API token. If you don't have one yet, head to the Getting Started to learn more.
const client = new Tangocrypto({
apiKey: process.env.API_KEY, // your account id
})

Examples

Here we have an example to upload a file:
import { Tangocrypto } from '@tango-crypto/tangocrypto-js';
import fs from 'fs';
const API_KEY= "<YOUR_API_KEY>"
const tangocrypto = new Tangocrypto({ apiKey: API_KEY });
const api = tangocrypto.ipfs();
(async () => {
const filename = 'filename';
const file = fs.createReadStream('image.png');
const result = await api.createContent(filename, file);
console.log(result);
})();
Listing content in your account
import { Tangocrypto } from '@tango-crypto/tangocrypto-js';
import fs from 'fs'
const api = new Tangocrypto({
apiKey: "4588c8026e7c47b4b2527150e126e914"
}).ipfs()
const { result } = await api.listContents();
console.log(result.data);