Powered by

API Overview

MóiBit is an enterprise ready, decentralized, peer to peer storage network that ensures availability, privacy and security. It is not only ideal for providing scalable off-chain storage for dApps and blockchain smart contracts, but can also be used by developers building apps for mobile, the web, and IOT devices.

Click here to create an account. Registered users are assigned an account URL and need to use the assigned API key and API secret in the header to authenticate API calls. Users/developers can also log into the user-friendly dashboard to interact with MóiBit.

Moibit v0.1.1 is out now! Read about what's new in the release notes.

API Endpoints

Write File

Description

Add a new file or add a new version of an existing file. File size limited to 1 GB.

Request

POST - [YOUR_API_URL]/moibit/v0/writefile

Headers

api_key: (put your API key here)

api_secret: (put your API secret here)

Content-Type: multipart/form-data

Parameters

Field Type Description
file File (data) The actual file you are uploading

Optional Parameters

Field Type Description Example(s)
fileName String File name or path italy.png
/2019/vacation/italy.png
createFolders Bool Create folders as needed. Otherwise, if a path specified in fileName does not exist, the operation will fail. Default:"true" true
false
pinVersion Bool Ensures that the version of the file uploaded won't be unpinned (and become eligible for garbage collection) when another version of the same file is uploaded (in the future). Default:"false" true
false

Response Fields

Field Description
hash IPFS multi-hash provided back for your content
name Name of the stored file
path Folder path where file was stored
size File size in bytes
cumulativeSize Size of the file + meta data of the file in bytes
blocks Number of shards the file was split into
createdTime Timestamp when this version of the file was created (only for files)
pinned Whether this version of the file should be removed when a new version is added (only for files)

Sample Response


{
    "meta":
         {
            "code": 200,
            "requestId": "44ef54db-9f67-4c19-8cc2-a660342d5613",
            "message": "file added successfully"
        },
    "data": 
        {
            "Hash": "zdj7WgRTUiTbYPWYoWjZjrmy5TYLy8U4jYgDQVK7rB25iNduf",
            "Path": "/",
            "Name": "tree.png",
            "Size": 26919,
            "CumulativeSize": 26977,
            "Blocks": 1,
            "Type": "file",
            "createdTime": "2020-01-31T09:31:25.057154Z",
            "pinned": true
        }
}
                                        

Write Files (Upload Directory)

Description

Add a non-empty directory with file(s) and nested non-empty directories inside it. If the path where the directory should be added is not specified, the directory will be added at the root path. Each file's size is limited to 1 GB.

Request

POST - [YOUR_API_URL]/moibit/v0/writefiles

Headers

api_key: (put your API key here)

api_secret: (put your API secret here)

Content-Type: multipart/form-data

Parameters

Field Type Description
dirData List of files(data) The actual non-empty folder you are uploading.

Optional Parameters

Field Type Description Example(s)
path String The path where the directory should be uploaded. Default: "/" /work
/reports/sales
pinVersion Bool For every single file uploaded, ensures that the version of the file uploaded won't be unpinned (and become eligible for garbage collection) when another version of the same file is uploaded (in the future). Default:"false" true
false

Response Fields

Field Description
hash IPFS multi-hash provided back for the uploaded folder
path Folder path where the uploaded folder was stored
cumulativeSize Size of the folder (including the size of nested files and folders) + meta data in bytes
blocks Number of blocks that the uploaded directory directly or indirectly links to

Sample Response


{
"meta":
        {
            "code": 200,
            "requestId": "44ef54db-9f67-4c19-8cc2-a660342d5613",
            "message": "file added successfully"
        },
"data": 
        {
            "Hash": "zdj7WgRTUiTbYPWYoWjZjrmy5TYLy8U4jYgDQVK7rB25iNduf",
            "Path": "/work/reports/sales",
            "Name": "",
            "Size": 0,
            "CumulativeSize": 26977,
            "Blocks": 3,
            "Type": "directory",
            "createdTime": "0001-01-01T00:00:00Z",
            "pinned": false
        }
}
            

Write Text To File

Description

Write string content to a file. The content of an existing file gets appended to the last byte of the existing content. String content can be added to a new file by setting the create field to true. Size limited to 1 GB.

Request

POST - [YOUR_API_URL]/moibit/v0/writetexttofile

Headers

api_key: (put your API key here)

api_secret: (put your API secret here)

Request Body Parameters

Field Type Description Example(s)
fileName String File name and path credentials.json
/2019/account/transaction.txt
text String Text or JSON content to add {\"userName\":\"abc\", \"password\":\"Hell@1\"}

Optional Request Body Parameters

Field Type Description Example(s)
create String Create a new file if the file to which string content needs to be appended does not exist. Default: "false" true
false
createFolders String Create folders as needed. Otherwise, if a path specified in fileName does not exist, the operation will fail. Default:"true" true
false
pinVersion String Ensures that the version of the file with data appended, won't be unpinned (and become eligible for garbage collection) when another version of the same file is uploaded (in the future). Default:"false" true
false

Response Fields

Field Description
hash IPFS multi-hash provided back for your content
name Name of the stored file
path Folder path where file was stored
size File size in bytes
cumulativeSize Size of the file + meta data of the file in bytes
blocks Number of shards the file was split into
createdTime Timestamp when this version of the file was created
pinned Whether this version of the file should be removed when a new version is added

Sample Response


{
    "meta":  
        {
            "code": 200,
            "requestId": "5854bc85f594df06d6109366",
            "message": "uploaded successfully"
        },
    "data": 
        {
            "Hash": "zdj7WVtiuh9VpKKnQoWNKfSX5sXuWdiXq8Wwavfg29kd9yimR",
            "Path": "/sales",
            "Name": "reports.pdf",
            "Size": 39,
            "CumulativeSize": 91,
            "Blocks": 1,
            "Type": "file",
            "createdTime": "2020-01-30T09:30:25.017344",
            "pinned": false
        }
}
                

Stream

Description

Add a new file or add a new version of an existing file faster and in a memory optimized way by streaming chunks of data. File size limited to 2 GB.

Request

POST - [YOUR_API_URL]/moibit/v0/stream

Headers

api_key: (put your API key here)

api_secret: (put your API secret here)

Content-Type: multipart/form-data

Parameters

Field Type Description
file File (data) The actual file you are uploading.

Optional Parameters

Field Type Description Example(s)
fileName String File name or path italy.png
/2019/vacation/italy.png
pinVersion Bool Ensures that the version of the file uploaded won't be unpinned (and become eligible for garbage collection) when another version of the same file is uploaded (in the future). Default:"false" true
false

Response Fields

Field Description
hash IPFS multi-hash provided back for your content
name Name of the stored file
path Folder path where file was stored
size File size in bytes
cumulativeSize Size of the file + meta data of the file in bytes
blocks Number of shards the file was split into
createdTime Timestamp when this version of the file was created (only for files)
pinned Whether this version of the file should be removed when a new version is added (only for files)

Sample Response


{
    "meta":
         {
            "code": 200,
            "requestId": "5c87149b-c68f-4773-b393-8d8f45870e2a",
            "message": "linked successfully"
        },
    "data": 
        {
            "Hash": "zdj7WgRTUiTbYPWYoWjZjrmy5TYLy8U4jYgDQVK7rB25iNduf",
            "Path": "/sales.pdf",
            "Name": "reports",
            "Size": 26919,
            "CumulativeSize": 26977,
            "Blocks": 1,
            "Type": "file",
            "createdTime": "2020-02-03T11:47:39.054137Z",
            "pinned": false
        }
}
                                        

Make Dir

Description

Create an empty directory. Any folders that are a part of the path - and don't exist - will also be created.

Request

GET - [YOUR_API_URL]/moibit/v0/makedir

Headers

api_key: (put your API key here)

api_secret: (put your API secret here)

Query Parameters

Field Type Description Example(s)
path String The fully qualified path at which you're attempting to create a new directory. /sales
/2020/report/sales

Sample Response


{
    "meta": 
        {
            "code": 200,
            "requestId": "c052753a-61e7-4bf7-ad84-192f21dcc5a9",
            "message": "directory created successfully"
        },
    "data": "created directory successfully"
}
                                                

Read File

Description

Read a file that has been added.

Request

POST - [YOUR_API_URL]/moibit/v0/readfile

Headers

api_key: (put your API key here)

api_secret: (put your API secret here)

Request Body Parameters

Field Type Description Example(s)
fileName String The name of the file, with the fully qualified path, that you're attempting to read italy.png
/2019/vacation/italy.png

Response Body

The response body contains the content of the file.

Sample Response

Response will be raw data (content of the file).

Read File by Hash

Description

Read a file by its hash.

Request

POST - [YOUR_API_URL]/moibit/v0/readfilebyhash

Headers

api_key: (put your API key here)

api_secret: (put your API secret here)

Request Body Parameters

Field Type Description Example(s)
hash String The hash of the content for the file requested. QmR9HnAjbeVNa8pygEBLvYSgh57DRXUHaasw5WC3S

Response Body

The response body contains the content of the file.

Sample Response

Response will be raw data (content of the file).

Remove

Description

Remove a file or folder. In case of a file, only the most recent version of the file will be removed by default. In case of a folder, all the files and nested folders inside it will also be removed.

Request

POST - [YOUR_API_URL]/moibit/v0/remove

Headers

api_key: (put your API key here)

api_secret: (put your API secret here)

Request Body Parameters

Field Type Description Example(s)
path String The name of the file or folder with the fully qualified path, that you're attempting to remove Remove a file
italy.png
/2019/vacation/italy.png

Remove a Folder
/2019
/2019/vacation

Optional Request Body Parameters

Field Type Description Example(s)
recursive Bool Recursively remove directories. Default:"false" true
false
allVersions Bool Remove all versions of this file. Default:"false" true
false

Response Fields

Field Description
path The path of the file or folder removed.

Sample Response For Removing a File


{
    "meta": 
        {
            "code": 200,
            "requestId": "5854bc85f594df06d6109366",
            "message": "removed successfully"
        },
    "data": 
        {
            "path": "/reports/qtr1/forcast.pdf"
        }
}
                                            

Sample Response For Removing a Folder


{
    "meta": 
    {
        "code": 200,
        "requestId": "5854bc85f594df06d6109366",
        "message": "removed successfully"
    },
    "data": 
    {
        "path": "/reports/qtr1"
    }
}
                                                            

Add Pin

Description

Pin to keep this version of the file accessible by hash even after a new version of the file is added.

Request

POST - [YOUR_API_URL]/moibit/v0/addpin

Headers

api_key: (put your API key here)

api_secret: (put your API secret here)

Request Body Parameters (One of the below is mandatory)

Field Type Description Example(s)
hash String The hash of the content requested to pin QmR9HnAjbeVNa8pygEBLvYSgh57DRXUHaasw5WC3S
fileName String The name of the file, with the fully qualified path, that you're attempting to pin. Will only pin the latest version of the file. italy.png
/2019/vacation/italy.png

Response Fields

Field Description
CID An object containing the hash that has been pinned.

Sample Response


                                            
{
    "meta": 
        {
            "code": 200,
            "requestId": "e8ffa40b-99e8-4108-8a10-63e0dd317fac",
            "message": "pinned successfully"
        },
    "data": 
        {
            "replication_factor_min": -1,
            "replication_factor_max": -1,
            "name": "",
            "shard_size": 0,
            "user_allocations": null,
            "metadata": null,
            "pin_update": null,
            "cid": 
                {
                    "/": "bafybeibv3ldrpswogaxdglavyzucbnykgkc2n7tolz6l26xw67kig6bvia"
                },
            "type": 2,
            "allocations": [],
            "max_depth": -1,
            "reference": null
        }
}
                                           

Remove Pin

Description

Remove pin to make sure this version of the file is removed when another version of the same file is added. Removing pin also reduces the replication factor of the file.

Request

POST - [YOUR_API_URL]/moibit/v0/removepin

Headers

api_key: (put your API key here)

api_secret: (put your API secret here)

Request Body Parameters (One of the below is mandatory)

Field Type Description Example(s)
hash String The hash of the content to be unpinned QmR9HnAjbeVNa8pygEBLvYSgh57DRXUHaasw5WC3S
fileName String The name of the file, with the fully qualified path, that you're attempting to unpin. Will only unpin the latest version of the file. italy.png
/2019/vacation/italy.png

Response Fields

Field Description
CID An object containing the hash that has been unpinned.

Sample Response


{
    "meta": 
        {
            "code": 200,
            "requestId": "7aec5d41-c4d1-45cc-b5a4-24925f557b02",
            "message": "removed pin successfully"
         },
    "data": 
        {
            "replication_factor_min": -1,
            "replication_factor_max": -1,
            "name": "",
            "shard_size": 0,
            "user_allocations": null,
            "metadata": null,
            "pin_update": null,
            "cid": 
                {
                    "/": "bafybeibv3ldrpswogaxdglavyzucbnykgkc2n7tolz6l26xw67kig6bvia"
                },
            "type": 2,
            "allocations": [],
            "max_depth": -1,
            "reference": null
        }
}
                                            
                                               

List Files

Description

List files and sub-folders in the specified folder.

Request

POST - [YOUR_API_URL]/moibit/v0/listfiles

Headers

api_key: (put your API key here)

api_secret: (put your API secret here)

Optional Request Body Parameters

Field Type Description Example(s)
path String The name of the folder with the fully qualified path. Defaults to the root folder ‘/’ /2019
/2019/vacation/

Response Fields

Field Description
entries Array of file and folder objects
hash IPFS multi-hash of the file or folder
name Name of the file or folder
size Size in bytes (only for files).
type File(0) or Folder(1)
lastUpdated The time at which this file path was last updated (only for files).
pinned Whether the file was pinned by the user (only for files).

Sample Response


{
    "meta": 
        {
        "code": 200,
        "requestId": "5854bc85f594df06d6109366",
        "message": "got files list successfully"
    },
    "data": 
    { 
        "entries": 
        [  
            {
                "hash": "QmR9HnAjbeVNa8pygEBLvYSgh57DRXU6FTpUHaasw5WC3S"
                "name": "sales.pdf",
                "size": "592890",
                "type": 0,
                "lastUpdated": "2020-01-31T10:02:21.986521Z",
                "pinned": true 
                },
            {
                "hash": "ZmR9HnAjbeVNa8pygEBLvYSgh57DRXU6FTpUHaasw5WC3S"
                "name": "forecast.pdf",
                "size": "492890",
                "type": 0,
                "lastUpdated": "2020-01-30T10:01:13.766521Z",
                "pinned": false
            },
            {
                "hash": "RmR9HnAjbeVNa8pygEBLvYSgh57DRXU6FTpUHaasw5WC3S"
                "name": "work",
                "size": "0",
                "type": 1,
                "lastUpdated": "0001-01-01T00:00:00Z",
                "pinned": false
            },
            {
                "hash": "WmR9HnAjbeVNa8pygEBLvYSgh57DRXU6FTpUHaasw5WC3S"
                "name": "personal",
                "size": "0",
                "type": 1,
                "lastUpdated": "0001-01-01T00:00:00Z",
                "pinned": false 
            }
        ]
    }
}
                                       

File Status

Description

View the hash, size and parent folder of a file or a folder. Also view the pin status and creation time in case of a file.

Request

POST - [YOUR_API_URL]/moibit/v0/filestatus

Headers

api_key: (put your API key here)

api_secret: (put your API secret here)

Request Body Parameters

Field Type Description Example(s)
path String The fully qualified path of a file or folder. sales.pdf
/2019/reports/sales.pdf
/2019/reports

Response Fields

Field Description
hash IPFS multi-hash provided back for your content
path Folder path where file was stored
name Name of the stored file
size Size in bytes (only for files)
cumulativeSize Size of the file or folder + meta data of the file or folder in bytes
blocks Number of shards the file was split into
type File or directory
createdTime Timestamp when this version of the file was created (only for files)
pinned Whether the file was pinned by the user (only for files).

Sample Response for File


{
    "meta": 
        {
            "code": 200,
            "requestId": "5854bc85f594df06d6109366",
            "message": "got status successfully"
        },
    "data":
        {
            "Hash": "zdj7WZ48B7TzjdhGbnqUcADSNiX5s2ReBkhgJwSo1vvyDsfW7",
            "Path": "/2020/reports",
            "Name": "sales.pdf",
            "Size": 26919,
            "CumulativeSize": 27023,
            "Blocks": 2,
            "Type": "file",
            "createdTime": "2020-01-31T10:02:21.986521Z",
            "pinned": false
        }
}
                                    

Sample Response for Folder


{
    "meta":  
    {
        "code": 200,
        "requestId": "5854bc85f594df06d6109366",
        "message": "got status successfully"
    },
    "data": 
    {
        "Hash": "zdj7WaKGrBpENVxQsBPfDPe1VYGaGW6gwfYwXENMsM3PGDEBq",
        "Path": "/2019",
        "Name": "Reports",
        "Size": 0,
        "CumulativeSize": 34097,
        "Blocks": 4,
        "Type": "directory",
        "createdTime": "0001-01-01T00:00:00Z",
        "pinned": false
    }
}
                                         

Versions

Description

View details of all available versions of a file. The response will show file versions in reverse chronological order. Only files can have versions, not folders.

Request

POST - [YOUR_API_URL]/moibit/v0/versions

Headers

api_key: (put your API key here)

api_secret: (put your API secret here)

Request Body Parameters

Field Type Description Example(s)
fileName String The name of the file, with the fully qualified path. italy.png
/2019/vacation/italy.png

Response Fields

Field Description
hash IPFS multi-hash corresponding to this version of the file
size Size of the file + meta data of the file in bytes
timeAdded Timestamp when this version of the file was created
pinned Whether the file was pinned by the user

Sample Response


{
    "meta": 
            {
                "code": 200,
                "requestId": "446badf3-0df6-4365-8a12-c6b4e272b584",
                "message": "got versions successfully"
            },
    "data": 
        [
            {
                "hash": "bafybeibjwvq332udwj4iyqoqd4gxqnqzmhjgqyvn2f3quiloss32lb2gky",
                "pinned": true,
                "size": 1055,
                "timeAdded": "2020-02-05T06:31:18.833845984Z"
            },
            {
                "hash": "bafybeif2mupauaa37oetqtotq3crz54k47a6cwxukfbzgqn3rso4gjd7lm",
                "pinned": true,
                "size": 1009,
                "timeAdded": "2020-02-05T06:31:18.186657085Z"
            },
            {
                "hash": "bafybeihpaygjc4xzpuzad2sxyonvr6po576tsajia32gufkxdjb6vd7pzi",
                "pinned": true,
                "size": 963,
                "timeAdded": "2020-02-05T06:31:17.352762436Z"
            },
            {
                "hash": "bafybeido6kgq3mclhk74bohhgd6zolg5qydmyvk3abryq466qrhrpfn55q",
                "pinned": true,
                "size": 917,
                "timeAdded": "2020-02-05T06:31:16.120686257Z"
            }
        ]
}
                                    

Storage Used

Description

Returns the total storage used, including the storage used for file replication. Also returns the time at which the storage value was last updated.

Request

GET - [YOUR_API_URL]/moibit/v0/storageused

Headers

api_key: (put your API key here)

api_secret: (put your API secret here)

Response Fields

Field Description
storageUsed The total space in bytes used including multiple versions of files and file replication in different nodes.
lastUpdated The time at which storage data was last updated.
unit The unit in which storage used is listed

Sample Response


{
    "meta": 
        {
            "code": 200,
            "requestId": "27d1f815-8959-4930-8b8a-e55e551f3e39",
            "message": "got storage used successfully"   
        },    
    "data": 
        {
            "storageUsed": 218634,
            "lastUpdated": "2020-01-31T11:08:43Z",
            "unit": "byte"
        }
}
                                                   

MóiBit JS SDKs

MóiBit JS SDK makes it easy for Javascript developers to create software solutions that use MoiBit for distributed, secure storage. As a Javascript developer, you can store data in MóiBit without installing any HTTP client to call the API.

Core Bundle

Core Bundle (@moibitjs/core) is the main library to help registered developers store, read, delete, pin, unpin and see details of their file(s) using MóiBit.

Matic Bundle

Matic Bundle (@moibitjs/matic) uses the MoiBitJS/core bundle to perform file actions and also stores the provenance of files in Matic network.