# Overview

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.

## Base URLs

The APIs can be accessed using the following base URLs

### Mainnet

| API                      | Base URL                      |
| ------------------------ | ----------------------------- |
| CSPR.cloud REST API      | <https://api.cspr.cloud>      |
| CSPR.cloud Streaming API | <wss://streaming.cspr.cloud>  |
| Casper Node RPC API      | <https://node.cspr.cloud>     |
| Casper Node SSE API      | <https://node-sse.cspr.cloud> |

### Testnet

| API                      | Base URL                                                                  |
| ------------------------ | ------------------------------------------------------------------------- |
| CSPR.cloud REST API      | <https://api.testnet.cspr.cloud>                                          |
| CSPR.cloud Streaming API | <wss://streaming.testnet.cspr.cloud>                                      |
| Casper Node RPC API      | <https://node.testnet.cspr.cloud>                                         |
| Casper Node SSE API      | [https://node-sse.testnet.cspr.cloud](https://node-sse.testnetcspr.cloud) |

## Authorization

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](https://docs.cspr.cloud/1.2.x/documentation/overview/authorization) page to learn more.

## Rate limits and quotas

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](https://docs.cspr.cloud/1.2.x/documentation/overview/rate-limits-and-quotas) page to learn more.

## Responses

The API sends data in the JSON format. Successful REST API responses contain the `data` property, which contains the response data:

```json
{
    "data": <ResponseData>
}
```

The Streaming API messages additionally include the `action` and `timestamp` properties:

```json
{
    "action": <string>,
    "data": <MessageData>,
    "timestamp": <datetime>
}
```

## Pagination

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:

```json
{
    "data": [<ResponseData>],
    "item_count": <int>,
    "page_count": <int>
}
```

Visit the [Pagination](https://docs.cspr.cloud/1.2.x/documentation/overview/pagination) page to learn more.

## Sorting

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](https://docs.cspr.cloud/1.2.x/documentation/overview/sorting) page to learn more.

## Filtering

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](https://docs.cspr.cloud/1.2.x/documentation/overview/filtering) page to learn more.

## Optional properties

Some of the endpoints provide a possibility to include optional properties into the responses using the `includes` query param. Visit the [Optional properties](https://docs.cspr.cloud/1.2.x/documentation/overview/optional-properties) page to learn more.

## Errors

Error responses contain the `error` property with optional `code`, `message`, and `description` properties providing more information about the error that occurred:

```json
{
    "error": {
        "code": 404,
        "message": "The requested block was not found"
    }
}
```

Visit the [Errors](https://docs.cspr.cloud/1.2.x/documentation/overview/errors) page to learn more.

## Versions

This documentation covers CSPR.cloud V2. Click [here](http://casper-docs.make.software) for CSPR.cloud V1 documentation, which will be deprecated soon.
