GraphQL API for Developers
1.1 API Overview
Endpoint: https://api.capsurelabs.com/graphql
Authentication Header:
1.2 Configuration
CapsureLabs’ GraphQL API can be configured to work with any GraphQL client or HTTP client (such as Apollo Client
, Postman
, or curl
). Authentication tokens are required for access to secure endpoints.
Sample Configuration with Apollo Client (JavaScript):
1.3 Basic GraphQL Queries
Below are examples of common GraphQL queries and mutations, along with their purpose, structure, and example responses.
1.3.1 Query: Get User Profile
Description: Retrieves the authenticated user’s profile, including information about their assets and preferences.
Query:
Sample Request (cURL):
Sample Response:
1.3.2 Query: Get Asset Price
Description: Fetches the current price and 24-hour change percentage of a specified asset.
Query:
Variables:
Sample Request (Postman):
Set the method to
POST
.Enter the URL
https://api.capsurelabs.com/graphql
.In the Headers section, add
Authorization: Bearer <token>
.In the Body section, select
raw
, chooseJSON
, and add:
Sample Response:
1.4 Basic Mutations
Mutations allow developers to perform actions, such as creating NFTs or transferring assets. Each mutation requires specific input fields.
1.4.1 Mutation: Create NFT
Description: Creates a new NFT on the platform with specified metadata.
Mutation:
Variables:
Sample Response:
1.5 Real-Time Data Subscriptions (Using WebSocket)
CapsureLabs supports GraphQL subscriptions for real-time data. Subscriptions are useful for receiving live updates on asset prices, new transfers, or NFT activities.
Real-Time Price Updates
Subscription:
Variables:
Sample Response:
Last updated