Overview
In dRPC you can use the API to get the statistics of your account and to fetch your dRPC keys.
Below you can find the list of available API endpoints and the description of how to use them.
Authorization#
Both Statistics API
and Web API
need you to specify Authorization
header with the Bearer
token like so:
Authorization: Bearer YOUR_TOKEN_GOES_HERE
.
Tokens can be regenerated on the same page where you generated them.
All the listed API endpoints have rate limit for 10 requests per 1 minute.
Statistics API#
In the dRPC Dashboard you can see the statistics of the user on the Dashboard
-> Stats
page. There are charts and tables with the information about the user's activity.
There's also a possibility to get the same information via the API.
To get started with Statistics API you need to generate API token in the dRPC Dashboard. You can do it in the Dashboard
-> Settings
-> Statistics API
page.
Statistics API JSON#
The JSON data is available at the https://drpc.org/api/metrics/json
endpoint.
For JSON endpoint you must specify range
query parameter to get the data for the specified time range.
Valid values are hour
, day
, week
, month
. So if you want to configure range it will look like https://drpc.org/api/metrics/json?range=day
.
JSON response has the following format:
type MetricsResponseJSON = {
balance: number;
data: GroupedDataItem[];
};
type GroupedDataItem = {
client_key: string;
request_count: number;
cu: number;
network: string;
connection: string;
provider_id: string;
method: string;
};
Statistics API Prometheus metrics#
The Prometheus metrics are available at the https://drpc.org/api/metrics/prom
endpoint.
For Prometheus metrics time range is last day.
Prometheus metrics are available in the following format:
# HELP drpc_client_balance Balance of dRPC client
# TYPE drpc_client_balance gauge
...
# HELP drpc_client_requests_count Count of dRPC client requests
# TYPE drpc_client_requests_count counter
...
# HELP drpc_client_cu_count Count of dRPC client compute units spent
# TYPE drpc_client_cu_count counter
...
Keys API#
It's also now possible to fetch your dRPC keys via API.
To get started with Keys API you need to generate token on the Dashboard
-> Settings
-> Keys API
page.
Keys API JSON#
The JSON data is available at the https://drpc.org/api/team/keys/list
endpoint.
type TKey = {
cu_spent_today: number;
key: Required<DataKey>;
public_keys: Required<JwtsPublicKey>[];
};
interface DataKey {
api_key?: string;
cors_origins?: string[];
/** @example 100 */
cu_day_limit?: number;
fallback_enabled?: boolean;
fallback_providers?: string[];
ip_whitelist?: string[];
jwt_enabled?: boolean;
key_id?: string;
methods_blacklist?: string[];
mev_enabled?: boolean;
mev_fallback?: boolean;
mev_providers?: string[];
/** @example "test" */
name?: string;
owner_id?: string;
providers?: string[];
rate_limit?: number;
status?: boolean;
/** @example "2022-09-16T12:15:30.331Z" */
updated_at?: string;
}