BWS API Docs
Contact UsCreate AccountSign In
  • Welcome!
    • Developer Grants
  • Quick Start
  • Platform Fees
    • Fees Calculator
  • API How Tos
    • API Endpoint
    • Authentication
      • Get your API Key
    • Main API Methods
      • 'call' API Method
      • 'fetch' API Method
    • API Responses
      • Error Status Codes
  • Certificate Of Trust
  • Media Assets
    • BWS Logo
    • Snapshots
      • BWS.IPFS.Upload
  • PLATFORM APIs
    • BWS.IPFS.Upload
      • Solution Overview
      • Operations
    • BWS.Blockchain.Save
      • Solution Overview
      • Operations
    • BWS.Blockchain.Hash
      • Solution Overview
      • Operations
    • BWS.NFT.zK
      • Solution Overview
        • NFT Ownership
        • NFT Data Location
        • Available Networks
      • Operations
        • Create NFT
        • List NFTs
        • Transfer NFT
        • Send NFT by Email
      • NFT Attributes (traits)
  • Marketplace Solutions
    • BWS.Blockchain.Badges
      • Badges User Interface
      • Badges API
        • Issuers
        • Badges
        • Awards (Credentials)
    • BWS.NFT.GameCube
      • NFT Game Overview
      • NFT Game Cube API
        • Calendar
        • Field
        • Cubes
        • Plays (Field-Calendar)
        • Match
        • Prizes
        • Event Types
        • Live Events
    • BWS.ESG.Credits
      • Solution Overview
      • ESG Credits API
        • Taxonomy
        • Translations
        • Currencies
        • Frameworks
        • Projects
        • Issuers
        • Assets
        • Investors
        • Positions
        • Portfolios
        • Impacts
        • Blockchain
        • Users
  • TELEGRAM BOTS
    • X BOT
      • Install
        • How does it work?
      • Commands
        • Monitoring Setup
Powered by GitBook
On this page
  • Upload to IPFS
  • Request Body
  • Upload to IPFS call Response
  • List IPFS Files
  • Request Body
  • List IPFS Files call Response

Was this helpful?

  1. PLATFORM APIs
  2. BWS.IPFS.Upload

Operations

Easily upload Images, PDF and JSON files to IPFS.

PreviousSolution OverviewNextBWS.Blockchain.Save

Last updated 4 months ago

Was this helpful?

Use this operation to upload content to IPFS and get the IPFS Content Identifier (CID).

POST https://api.bws.ninja/v1/call

Request Body

Name
Type
Description

solution*

string

BWS.IPFS.Upload

operation*

string

new

parameters*

JSON

{
    "statusCode": 200,
    "info": {
        "cid": "QmXmCX9S6ANVjYJh3rJmXjqgYtYv7WZLUDL2XCwdPrvUwN",
        "uris": {
            "ipfs": "ipfs://QmXmCX9S6ANVjYJh3rJmXjqgYtYv7WZLUDL2XCwdPrvUwN",
            "url": "https://ipfs.bws.ninja/ipfs/QmXmCX9S6ANVjYJh3rJmXjqgYtYv7WZLUDL2XCwdPrvUwN"
        }
    }
}

Parameter
Type
Desciption

description

string

content

JSON / base64

Content to save on the IPFS network. We currently support:

  • JSON (just pass the JSON or the stringified string)

  • File sent as a base64 encoded string

Please note that when uploading your file:

  • You must optimize your content to be less than 1 MB in size (there is a hard limit of 5MB when uploading files to IPFS using our API).

  • We currently support JSON, images, and PDF files.

If your use case requires higher file sizes or other file types, please contact us.

Upload to IPFS Examples

const fs = require('fs');
const axios = require('axios');

/* get the file you want to upload to IPFS */
const fileData = fs.readFileSync('./files/image.png');

/* encode file content to base64 */
const encodedData = fileData.toString('base64');

/* build request to use BWS IPFS solution */
const request = {
   "solution": "BWS.IPFS.Upload",
   "operation": "new",
   "parameters": {
        description: "My first IPFS file using BWS API!",
        parameters: {
            content: encodedData
        }
    }
};

/* call BWS API using Axios */
let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.bws.ninja/v1/call',
  headers: { 
    'X-Api-Key': 'XqaLg...... A5k2V729v', /* use your API key here! */
    'Content-Type': 'application/json'
  },
  data : JSON.stringify(request)
};

axios.request(config)
  .then((response) => {
    console.log(JSON.stringify(response.data));
  })
  .catch((error) => {
    console.log(error);
  });
curl --location 'https://api.bws.ninja/v1/call' \
--header 'X-Api-Key: XqaLg...729v' \
--header 'Content-Type: application/json' \
--data '{
    "solution": "BWS.IPFS.Upload",
    "operation": "new",
    "parameters": {
         "description": "Just a simple JSON for testing BWS API",
         "content": {
                "text": "Hello World!"
             } 
    }
}'

When the API call is successfully executed, it returns the IPFS Content Identifier (CID) along with the corresponding IPFS URI and URL. These details facilitate easy access and reference to the uploaded content on the IPFS network.

{
    "statusCode": 200,
    "info": {
        "cid": "QmXmCX9S6ANVjYJh3rJmXjqgYtYv7WZLUDL2XCwdPrvUwN",
        "uris": {
            "ipfs": "ipfs://QmXmCX9S6ANVjYJh3rJmXjqgYtYv7WZLUDL2XCwdPrvUwN",
            "url": "https://ipfs.bws.ninja/ipfs/QmXmCX9S6ANVjYJh3rJmXjqgYtYv7WZLUDL2XCwdPrvUwN"
        }
    }
}

Get the list of your IPFS files

POST https://api.bws.ninja/v1/call

Request Body

Name
Type
Description

solution*

string

BWS.IPFS.Upload

operation*

string

list

parameters

JSON

{
    "statusCode": 200,
    "statusMessage": "",
    "info": [
        {
            "": ""
        }
    ]
}
Parameter
Type
Desciption

from

long

to

long

LIST IPFS Files Request Example

curl --location 'https://api.staging.bws.ninja/v1/call' \
--header 'X-Api-Key: XqaLg...729v' \
--header 'Content-Type: application/json' \
--data '{
    "solution": "BWS.IPFS.Upload",
    "operation": "list"
    "parameters": {
        "from": 1700404140000
        "to": 1700411940000
    }
}'

Once executed correctly, you will get a list of the IPFS uploaded files using BWS API. That list will contain for each file:

  • the IPFS Content Identifier (CID),

  • the file type,

  • and the URIs to easily access the file

    • IPFS URI,

    • web URL - using the BWS IPFS Gateway to fetch the file.

{
    "statusCode": 200,
    "info": [
        {
            "timestamp": "1700416540067",
            "cid": "QmXmCX9S6ANVjYJh3rJmXjqgYtYv7WZLUDL2XCwdPrvUwN",
            "description": "Just a simple JSON for testing BWS API",
            "fileType": "json",
            "uris": {
                "ipfs": "ipfs://QmXmCX9S6ANVjYJh3rJmXjqgYtYv7WZLUDL2XCwdPrvUwN",
                "url": "https://ipfs.bws.ninja/ipfs/QmXmCX9S6ANVjYJh3rJmXjqgYtYv7WZLUDL2XCwdPrvUwN"
            }
        },
        {
            "timestamp": "1700121600009",
            "cid": "QmcduEBAppXxnyn37deHHf33Ep7cPbYxn1mH36Nvvowkiu",
            "description": "image for token 1325",
            "fileType": "image",
            "uris": {
                "ipfs": "ipfs://QmcduEBAppXxnyn37deHHf33Ep7cPbYxn1mH36Nvvowkiu",
                "url": "https://ipfs.bws.ninja/ipfs/QmcduEBAppXxnyn37deHHf33Ep7cPbYxn1mH36Nvvowkiu"
            }
        }
    ]
}

check

Short description of your content (will be returned when ).

check

in milliseconds representing a timestamp to select IPFS files from.

in milliseconds representing a timestamp to select IPFS files to.

the timestamp of creation ( in milliseconds),

Unix time
Upload to IPFS
Upload to IPFS Method Parameters
Upload to IPFS call Response
List IPFS Files
List IPFS Files Method Parameters
List IPFS Files call Response
Unix time
Unix time
Method Parameters
listing your IPFS files
Method Parameters