zeeve-zdfs-sdk
v1.0.2
Published
NodeJS SDK for intracting with Zeeve's ZDFS service.
Downloads
4
Keywords
Readme
Zeeve ZDFS SDK
Offical ZDFS NodeJS SDK from Zeeve.
Overview
NodeJS based rapid development kit to allow you to build applications faster with seamless integration available without the need of writing the bloatware code repeatedly. Hence, saving a lot of precious time and cost.
Installation
npm install --save zeeve-zdfs-sdk
Setup
You need to create Pinning Service and Data APIs SDK instances with your endpoint and access token. Configure endpoint based on the gateway. Please read how to create access key.
- Shared Gatway Endpoint: https://app.zeeve.io/zdfs-api
- Dedicated Gatway Endpoint: https://app.zeeve.io/zdfs-api/YOUR_DEDICATED_GATEWAY_KEY
/** import zeeve zdfs sdk */
import { PSAV1Api, DataV1Api } from 'zeeve-zdfs-sdk';
/** create instance of pinning service api version 1 */
const psaApi = new PSAV1Api(YOUR_ENDPOINT, YOUR_ACCESS_TOKEN);
/** create instance of data api version 1 */
const dataApi = new DataV1Api(YOUR_ENDPOINT, YOUR_ACCESS_TOKEN);
Usage
Once you done with the setup part, now it becomes so easy to integrate ZDFS service. Now you just need to call any of the following functions to perform desired operations.
Pinning Service APIs Function
Data APIs Function
addPinObject
Add a new pin object for the current access token. User can add name, origions and meta data associated to the CID object using this function.
psaApi.addPinObject(cid, name, origins, meta, headers)
Params
cid
- A string of valid IPFS Content Identifier (CID).name
(optional) - A name that ZDFS will associate with this particular CID hash.origins
(optional) - A list of multiaddrs known to provide the data.meta
(optional)- A JSON object with the updated keyvalues you want associated with the CID hash provided.headers
(optional)- An extra http request headers.
getPinObject
Get a pin object details and it's status using the current access token.
psaApi.getPinObject(requestID, headers)
Params
requestID
- A string of valid UUID or you can say fileID provided by ZDFS.headers
(optional)- An extra http request headers.
listPinObjects
List all the pin objects associated to the access token, matching optionall filters when no filter is provided, only successful pins are returned.
psaApi.listPinObjects(cid, name, match, status, before, after, limit, headers)
Params
cid
(optional) - Return pin object of specified valid IPFS CID.name
(optional)- Return pin objects of the specified name (by default a case-sensitive, exact match).match
(optional)- To customize the text matching strategy applied when the name filter is present. Default: "exact". Options: "exact" "iexact" "partial" "ipartial".status
(optional) - Return pin objects of the specified status array string. Default: "pinned", Options: "queued" "pinning" "pinned" "failed".before
(optional) - Return pin objects created before the provided timestamp. Example: "2022-09-29T00:00:00.000Z".after
(optional) - Return pin objects created after the provided timestamp. Example: "2022-09-29T00:00:00.000Z".limit
(optional) - Number of records limit. Default: 10.headers
(optional)- An extra http request headers.
replacePinObject
Replace an existing pin object associated with the access token (shortcut for executing remove and add operations in one step to avoid unnecessary garbage collection of blocks present in both recursive pins).
psaApi.replacePinObject(requestID, cid, name, origins, meta, headers)
Params
requestID
- A string of valid UUID or you can say fileID provided by ZDFS.cid
- A string of valid IPFS Content Identifier (CID) of object by which you want to replace the current pinned object.name
(optional) - A name that ZDFS will associate with this particular CID hash.origins
(optional) - A list of multiaddrs known to provide the data.meta
(optional)- A JSON object with the updated keyvalues you want associated with the CID hash provided.headers
(optional)- An extra http request headers.
removePinObject
Remove a pin object associated to the access token.
psaApi.removePinObject(requestID, headers)
Params
requestID
- A string of valid UUID or you can say fileID provided by ZDFS.headers
(optional)- An extra http request headers.
uploadFile
Upload a file to the IPFS gateway.
dataApi.uploadFile(path, name, headers)
Params
path
- An absolute path of the file.name
- A name that ZDFS will associate with this particular file.headers
(optional)- An extra http request headers.
uploadDirectory
Upload a directory/folder to the IPFS gateway.
dataApi.uploadDirectory(path, name, headers)
Params
path
- An absolute path of the directory/folder.name
- A name that ZDFS will associate with this particular directory/folder.headers
(optional)- An extra http request headers.
uploadCID
Upload a file/folder using IPFS hash CID to the IPFS gateway.
dataApi.uploadCID(fileCID, fileName, headers)
Params
fileCID
- A string of valid IPFS Content Identifier (CID).fileName
- A name that ZDFS will associate with this particular directory/folder.headers
(optional)- An extra http request headers.
viewFileByFileID
View the file detail of the already upload content on ZDFS.
dataApi.viewFileByFileID(fileID, headers)
Params
fileID
- A string of valid UUID or requestID provided by ZDFS by using its fileID(or you can say requestID provided by ZDFS).headers
(optional)- An extra http request headers.
editFileByFileID
Edit the file detail of the already upload content on ZDFS by using its fileID(or you can say requestID provided by ZDFS).
dataApi.editFileByFileID(fileID, fileName, fileMetadata, headers)
Params
fileID
- A string of valid UUID or requestID provided by ZDFS.fileName
- A name that ZDFS will associate with this particular file.fileMetadata
- An array of keyvalues you want associated with the the fileID.headers
(optional)- An extra http request headers.
fileList
List all the uploaded files on ZDFS based on the optional parameters.
dataApi.fileList(page, size, fileCIDs, fileName, match, status, before, after, headers)
Params
page
(optional) - Return records for a particular page. Default: 1size
(optional) - Return specified number of records per page. Default: 10fileCIDs
(optional) - Return files of the specified array of valid IFPS CID.fileName
- Return files of the specified name (by default a case-sensitive, exact match).match
- To customize the text matching strategy applied when the name filter is present. Default: "exact". Options: "exact" "iexact" "partial" "ipartial"status
(optional) - Return files of the specified status array string. Options: "queued" "pinning" "pinned" "unpinning" "unpinned" "failed". Default: All Status.before
(optional) - Return files created before the provided timestamp. Example: "2022-09-29T00:00:00.000Z".after
(optional) - Return files created after the provided timestamp. Example: "2022-09-29T00:00:00.000Z".headers
(optional)- An extra http request headers.
pinByFileID
Pin the already uploaded content on ZDFS by using its fileID(or you can say requestID provided by ZDFS).
dataApi.pinByFileID(fileID, headers)
Params
fileID
- A string of valid UUID or requestID provided by ZDFS.headers
(optional)- An extra http request headers.
unpinByFileID
Unpin the already uploaded content on ZDFS by using its fileID(or you can say requestID provided by ZDFS).
dataApi.unpinByFileID(fileID, headers)
Params
fileID
- A string of valid UUID or requestID provided by ZDFS.headers
(optional)- An extra http request headers.
deleteByFileIDs
Delete multiple files from ZDFS by using its fileID(or you can say requestID provided by ZDFS).
dataApi.deleteByFileIDs(fileIDs, headers)
Params
fileIDs
- An array of string of valid UUID or requestID provided by ZDFS.headers
(optional)- An extra http request headers.