App
Use end-to-end encryption or publish public files to Arweave.
API
Plug Akord vaults into existing products and workflows.
Explorer
Find, discover and follow Akord vaults with our Permaweb dApp.
Arweave

Integrating Arweave

Integrate Arweave into your project using the Akord API.

26 Aug 2021
Clock 3 min read

Introducing Arweave

Akord is built on Arweave – a protocol for decentralised, sustainable and permanent storage of data with a one-off payment. The network is decentralised, like Bitcoin, and miners on the network provide hard drive space to those individuals and organisations looking to store data.

To discover moe about Arweave, check out our article, What is Arweave?

Simple API Upload

1.1. Minimal upload

Want a super fast way to upload to Arweave with no tokens or wallets needed, and also get your first uploads free?

You just need two things to get started:

  1. Create your account in seconds (100 MB free to test your workflow)
  2. Get your API key here
const fs = require('fs').promises;
const data = await fs.readFile('/path/to/your/file.txt', 'utf8'); //nodejs specific

const response = await fetch('https://api.akord.com/files', {
    method: 'POST',
    headers: {
        'Accept': 'application/json',
        'Api-Key': 'your_api_key',
        'Content-Type': 'text/plain'
    },
    body: data
})

Thats it! You just uploaded the file to Arweave. Here is the example response:

{
    "id": "a6f1fbfc-403d-4607-b648-4b949fdd50bd", 
    //technical id of upload. can be used to get metadata of the upload or file binary from cloud storage
    
    "mime_type": "text/plain", //depends on content-type of upload, goes as a tag 
    "sizeInBytes": 10,
    "cloud": {
        "uri": "a6f1fbfc-403d-4607-b648-4b949fdd50bd", //same as ID
        "url": "https://api.akord.com/files/a6f1fbfc-403d-4607-b648-4b949fdd50bd"                 //url to binary served from cloud storage
    },
    "tx": {
        "id": "LAWVdsBRTkUF8ptiEwiU6n4Q-_5ukBJIFmeAllX7Q0E", //fixed ID of Arweave transaction (ANS-104 data item ID)
        "status": "scheduled", 
        //indicates where is your file in Arweave bundling context
        //scheduled - file is in our cloud storage and is scheduled for ANS-104 
        //verification - file is being verified for malicious content
        //blocked - file is recognized as malicious, won't go to Arweave
        //pending - file was bundled and posted to Arweave
        //confirmed - file is confirmed on Arweave
        //rejected - this indicates a technical problem with our bundling service)
        "tags": [], //your Arweave tags appended to transaction
        "statusUrl": "https://api.akord.com/files/a6f1fbfc-403d-4607-b648-4b949fdd50bd/status", //check file status endpoint, returns simillar JSON schema
        "gatewayUrls": [
            "https://akrd.net/LAWVdsBRTkUF8ptiEwiU6n4Q-_5ukBJIFmeAllX7Q0E", 
            //our instance of Arweave gateway - this url will work always, even right after upload since it falls back to cloud storage when file is not yet on Arweave
            "https://arweave.net/LAWVdsBRTkUF8ptiEwiU6n4Q-_5ukBJIFmeAllX7Q0E" 
            // other Arweave gatways
        ]
        "viewblockUrl": "https://viewblock.io/arweave/tx/LAWVdsBRTkUF8ptiEwiU6n4Q-_5ukBJIFmeAllX7Q0E", //see your file on Viewblock - this url will only work when file is in 'committed' status & indexed by Viewblock
        "info": "Transaction is visible on the blockchain indexers when in the \"committed\" status.",
        "infoUrl": "https://docs.akord.com/api-and-dev-tools/build/akord-api/files"
    }
}

1.2. Upload with Arweave transaction tags

To add tags to your Arweave transaction - use query params. Each query param with key prefixed with tag- is treated as Arweave transaction tags. Tags query params are case sensitive. E.g.

tag-file-category=photo => Tag name: 'file-category', Tag value: 'photo'

Tag-File-Category=PHOTO => Tag name: 'File-Category', Tag value: 'PHOTO'

const fs = require('fs').promises;
const data = await fs.readFile('/path/to/your/file.txt', 'utf8'); //nodejs specific

const response = await fetch('https://api.akord.com/files?tag-file-category=photo&tag-file-description=wedding%202024', {
    method: 'POST',
    headers: {
        'Accept': 'application/json',
        'Api-Key': 'your_api_key',
        'Content-Type': 'text/plain'
    },
    body: data
})
{
    "id": "a2a48bc6-7e9f-48c6-abc7-9e641390680b",
    "mimeType": "image/png",
    "sizeInBytes": 437432,
    "cloud": {
        "uri": "a2a48bc6-7e9f-48c6-abc7-9e641390680b",
        "url": "https://api.akord.com/files/a2a48bc6-7e9f-48c6-abc7-9e641390680b"
    },
    "tx": {
        "id": "ewR2EcQJOSAN-dH0GZVswOG_g_kjtFh_dUSrjpbd_Lo",
        "status": "scheduled",
        "tags": [
            {
                "name": "file-category",
                "value": "photo"
            },
            {
                "name": "file-description",
                "value": "wedding 2024"
            }
        ],
        "statusUrl": "https://api.akord.com/files/a2a48bc6-7e9f-48c6-abc7-9e641390680b/status",
        "gatewayUrls": [
            "https://akrd.net/ewR2EcQJOSAN-dH0GZVswOG_g_kjtFh_dUSrjpbd_Lo",
            "https://arweave.net/ewR2EcQJOSAN-dH0GZVswOG_g_kjtFh_dUSrjpbd_Lo"
        ],
        "viewblockUrl": "https://viewblock.io/arweave/tx/ewR2EcQJOSAN-dH0GZVswOG_g_kjtFh_dUSrjpbd_Lo",
        "info": "Transaction is visible on the blockchain indexers when in the \"committed\" status.",
        "infoUrl": "https://docs.akord.com/api-and-dev-tools/build/akord-api/files"
    }
}

1.3. Upload with Arweave transaction tags (encoded)

You may encode your tags as base64 string and pass it as a single param.

const fs = require('fs').promises;

const tags = [
    {
        name: "file-category",
        value: "photo"
    },
    {
        name: "file-description",
        value: "wedding 2024"
    }
];

const jsonTags = JSON.stringify(tags);
const base64EncodedTags = Buffer.from(jsonTags).toString('base64url');

const data = await fs.readFile('/path/to/your/file.txt', 'utf8'); //nodejs specific

//Use in querystring
const response = await fetch(`https://api.akord.com?tags=${base64EncodedTags}`, {
    method: 'POST',
    headers: {
        'Accept': 'application/json',
        'Api-Key': 'your_api_key',
        'Content-Type': 'text/plain'
    },
    body: data
})

//Or use in header
const response = await fetch(`https://api.akord.com`, {
    method: 'POST',
    headers: {
        'Accept': 'application/json',
        'Api-Key': 'your_api_key',
        'Content-Type': 'text/plain'
        'Tags': base64EncodedTags
    },
    body: data
})

More options

Check out examples of multipart uploads for larger files in our docs here. You can also check out full documentation on the API, SDK and CLI

Chat with our community

Talk to other members of our community, ask questions and get the heads up on all the latest Akord happenings.