Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
REST API endpoints that potentially may return an unlimited number of items are paginated.
In addition to the endpoint-specific parameters, endpoints that return paginated responses accept the following pagination parameters to control the page and number of items per page correspondingly:
page
int
1
Page number
page_size
int
10
Number of items per page
The maximum number of items per page is 250
.
Paginated responses contain two additional properties providing information on the total number of items and the total number of pages:
item_count
int
Total number of items
page_count
int
Total number of pages
Get the second page of accounts with 25
items per page:
When making an API request to an endpoint that returns paginated data, you usually don't receive all of the results in a single response. To traverse the data, you need to increment the page number in your requests until you collect all the required items. When doing so, note the rate limits. Setting the number of items per page to its maximum value of 250
will minimize the chances of being rate-limited for most of the use cases.
Note that if new objects are added to the list of items being paginated, the contents of each page will change.
REST and WebSocket API endpoints that return multiple results may provide possibility to filter the data by certain properties. Not all properties can be used as filters. Please check the endpoint documentation to find out what properties are available for filtering.
To filter the results by a property, the corresponding property should be provided as a query param. Multiply filters can be used in one request to narrow down the data to what fits your dApp use-case. Some filters can accept multiple values separated by a comma.
Filter NFT tokens by owner and contract package:
REST API endpoints that return paginated responses may provide a possibility to sort the results by one of the result properties. Not all properties can be used for sorting. Please check the endpoint documentation to find out the sorting properties.
In addition to the endpoint-specific parameters, endpoints that return sorted results accept the following parameters to control the sorting property and the order:
order_by
string
Sorting property the results should be sorted by
order_direction
string
Order direction: ASC or DESC
The defaults are different for different endpoints and are provided in the corresponding endpoint documentation.
Get blocks sorted by height from lowest to highest:
At CSPR.cloud, we distinguish between rate limits and quotas to ensure efficient API management.
We impose a limit on the number of requests per minute. This measure helps manage load and avoid overloading our systems.
Quotas control the overall call rates over an extended period, often tied to subscription tiers.
Long-term Management: Quotas determine the total number of calls that can be made in a set period, like a month.
Tier-based Access: For example, a free tier might allow 10,000 calls per month, while a premium tier could permit up to 10,000,000 calls in the same timeframe.
Exceeding these limits triggers a 429 error, signaling a rate limit breach.
The free tier limits are set to ensure that you can test the API and integrate it into your application.
To effectively manage your API usage and comply with rate limit or quota, consider the following strategies:
Implement a Backoff-Retry Strategy: In cases where you encounter a 429 error (rate limit or quota exceeded), it's advisable to implement a backoff-retry strategy. This involves reducing the frequency of your API requests to stay within the allowed limits.
Monitor API Calls: Utilize logging tools to monitor your application’s API usage. This can help you identify patterns and optimize your request strategy to ensure efficient usage.
Lazy Loading Technique: To reduce unnecessary API calls, implement lazy loading in your application. Trigger API calls based on user interactions, such as clicking a button or reaching a specific section of a page, to minimize the number of requests.
Adhering to these strategies will help you efficiently manage your API usage within the CSPR.cloud environment.
Upgrade to Premium Tier: If your needs exceed the free tier quota, consider upgrading to our Premium tier for higher limits. You can apply at .
CSPR.Node Proxy
20,000
1,200
100
CSPR.Node Proxy SSE
5,000
200
10
CSPR.Cloud API
100,000
6,000
100
CSPR.Node Proxy
20,000
1,200
100
CSPR.Node Proxy SSE
5,000
200
10
CSPR.Cloud API
100,000
6,000
100
The CSPR.cloud API is exclusively available to registered users. To authorize your API requests, an access token is required. The access tokens identify the API user and their corresponding access tier limitations. Please visit the CSPR.cloud website to learn about the tiers and to submit an access token request. To learn more about rate limites and quotas please read the Rate limits and quotas documentation page.
The access token should be included in the Authorization
header:
The access token provided in the example above is for the demonstration purposes only, and has limited capabilities.
To learn how to include the Authorization
header in Casper SDKs to access the CSPR.cloud Casper Node please read the Connecting with an SDK page.
At this moment CPSR.cloud provides only the server side integration. By using your access token in a front-end application, you'll expose it to the world.
You can request the usage report by sending an email from your registered account to support@cspr.cloud.
Requests made to our APIs can result in several different error responses. The following document describes error values.
The Error
has the following properties:
code
string
Error code constant represented as a string
message
string
Error message depending on the type of error and an API resource
invalid_input
InvalidParamError
400
Invalid client input parameters
unauthorized
UnauthorizedError
401
Client is not authorized
access_denied
AccessDeniedError
403
Entity
or resource access is forbidden
not_found
NotFoundError
404
Entity
not found
duplicate_entity
DuplicateEntityError
409
Entity
already exist
Visit the Rate limits and quotas for more information regarding Rate limiting errors.
Most of the REST API endpoints allow optional data to be included in their responses. It could be related entities, derived properties, account info standard data, or CSPR rates at the moment of the entity creation. Please check the endpoint documentation to find out what optional properties could be included in the responses.
Optional data can be included using the includes
query param that specifies a comma-separated list of all optional data that should be included. The includes
query param options can be one of three forms:
To include a scalar value its name should be specified the includes
list.
Similar to scalar values to include an object its name should be specified in the includes
list. However, for objects it's possible to specify a subset of fields that should be returned using the object querying syntax, which looks like this:
The request above will return only the name
and the branding.logo
properties of the account info object
When the included data requires extra parameters, it is included as a function. The function form provides a possibility to specify the needed input. For example, to include the USD to CSPR rate, the USD currency ID 1
should be passed as a parameter to the rate
function, like this:
The WriteTransfer
transforms that are used to track the native token transfers, contain the recipient account hash. It's possible, however, to include the corresponding public key if it is known to us. To learn more, visit the Transfer REST API page.
An entity is called related if its identifier is present among the requested entity's properties. To include a related entity you need to specify its name in the includes
query param. In the example below, we include contract package and contract entry point objects in the deploy list data. To learn more, visit the Including related entities page.
Entities that have the timestamp
property can optionally include the CSPR rate at that time in the requested currency, which is passed as an argument to the rate
function. In the example below, we include the USD to CSPR rate in the account transfers response. To learn more, visit the Including CSPR rates page.
The rate
property of the first result in the response above holds the CSPR rate from May 16th, 2023, and the second result has the rate
from November 11th, 2022.
CSPR.cloud REST API is an HTTP-based API that dApps can use to programmatically query Casper network data. It has predictable resource-oriented endpoints and uses standard HTTP response codes, authentication, and verbs.
CSPR.cloud Streaming API is WebSocket-based and follows the WebSocket standard conventions.
The APIs can be accessed using the following base URLs
CSPR.cloud REST API
CSPR.cloud Streaming API
Casper Node RPC API
Casper Node SSE API
CSPR.cloud REST API
CSPR.cloud Streaming API
Casper Node RPC API
Casper Node SSE API
The API is protected and requires access tokens to be provided with each request. The access tokens identify the API user and their corresponding access tier limits. Visit the Authorization page to learn more.
The API is rate-limited, with rate limits defined by the user access tier. The total number of requests to each of the APIs is limited by monthly and daily quotas. Visit the Rate limits and quotas page to learn more.
The API sends data in the JSON format. Successful REST API responses contain the data
property, which contains the response data:
The Streaming API messages additionally include the action
and timestamp
properties:
Requests that potentially may return an unlimited number of items are paginated. Endpoints that return paginated responses accept the page
and limit
query parameters to control the page and the number of items per page, correspondingly. Paginated responses contain two additional properties providing information on the total number of items and the total number of pages:
Visit the Pagination page to learn more.
Some of the endpoints that return paginated responses provide a possibility to sort the results. Sorting is controlled by the order_by
and order_direction
query params. Visit the Sorting page to learn more.
Some of the endpoints that return paginated responses provide a possibility to filter the results by certain properties. Available filter properties vary for different endpoints and are specified in the corresponding endpoint documentation. Visit the Filtering page to learn more.
Some of the endpoints provide a possibility to include optional properties into the responses using the includes
query param. Visit the Optional properties page to learn more.
Error responses contain the error
property with optional code
, message
, and description
properties providing more information about the error that occurred:
Visit the Errors page to learn more.
This documentation covers CSPR.cloud V2. Click here for CSPR.cloud V1 documentation, which will be deprecated soon.