REST and WebSocket API
1.1 REST API Overview
1.2 Authentication
All requests to protected endpoints require an API key and authentication token. Requests must include the token in the Authorization
header, formatted as:
1.3 Main REST API Endpoints
/api/v1/auth/login
POST
Authenticates the user and provides a token.
/api/v1/nft/create
POST
Creates a new NFT asset.
/api/v1/assets
GET
Retrieves a list of all assets.
/api/v1/price/:id
GET
Gets current price data for a specific asset.
/api/v1/transfer
POST
Initiates a transfer of assets.
1.3.1 Authentication: Login Endpoint
Endpoint: /api/v1/auth/login
Method: POST
Description: Authenticates the user and returns an access token for use with other API requests.
Parameters:
username
(string, required): User’s username.password
(string, required): User’s password.
Sample Request (cURL):
Sample Response:
1.3.2 NFT Creation
Endpoint: /api/v1/nft/create
Method: POST
Description: Creates a new NFT with the specified metadata.
Parameters:
name
(string, required): The name of the NFT.description
(string, optional): A description of the NFT.metadata
(object, required): Metadata including the NFT image URL, attributes, and creator information.
Sample Request (Postman):
Select POST method.
Set the URL to
https://api.capsurelabs.com/api/v1/nft/create
.In the Authorization tab, add a Bearer Token (
Authorization: Bearer <token>
).In the Body tab, select
raw
and set theContent-Type
toJSON
.
Sample Response:
1.3.3 Asset List Retrieval
Endpoint: /api/v1/assets
Method: GET
Description: Retrieves a list of all assets available to the authenticated user.
Sample Request (cURL):
Sample Response:
1.3.4 Asset Price Retrieval
Endpoint: /api/v1/price/:id
Method: GET
Description: Gets the current price of the specified asset by id
.
Parameters:
id
(string, required): The unique identifier of the asset (e.g., Ethereum or NFT ID).
Sample Request (cURL):
Sample Response:
1.4 WebSocket API Overview
The WebSocket API provides real-time event data for CapsureLabs' users, including price updates and asset transfers.
WebSocket Endpoint: wss://api.capsurelabs.com/ws
1.4.1 Supported Events
priceUpdate
: Sends price updates in real-time for subscribed assets.newTransfer
: Notifies users when a new transfer involving their assets occurs.newNFT
: Informs users of new NFT minting events.
WebSocket Connection and Subscription
The following code example shows how to connect to CapsureLabs’ WebSocket API and subscribe to priceUpdate
events.
JavaScript WebSocket Code:
Sample WebSocket Message for priceUpdate
Event:
Last updated