1.11. Working with the API

Notes:

  • The token is tied to the account and allows you to manage all the services that are available in it, including delegated.
  • The token is valid for 6 months from the date of the last use.
  1. Open the section "API".
  2. In the tab "Access data" mark "I agree to the user agreement and terms of service" and press "Activate token":

Limits on the number of requests to the API:

  • No more than 300 requests per hour.
  • Per day — no more than 5000 requests.
Information about the time of the last request and the current number of sent requests is displayed in the section "API".

HTTP headers are added in response to each request:

  • With current limits:
    • X-RateLimit-Hour: 300 — at one o’clock.
    • X-RateLimit-Day: 5000 — per day.
  • With the number of requests left before the limits are exhausted:
    • X-RateLimit-Hour-Remaining: XXX — at one o’clock.
    • X-RateLimit-Day-Remaining: XXXX — per day.

Requests per second/minute not limited.

If the limit is exceeded, an error message will be returned in response to the request with the limit value and the remaining number of seconds until it is reset:

  • "Too Many Requests per hour. Limit 300. Pause XXX seconds" — for the hourly limit.
  • "Too Many Requests per day. Limit 5000. Pause XXXX seconds" — for the daily limit.

Also, when the limits are reached, a corresponding notification is sent to mail and in Telegram (but not more than once a week).

Attention!

It is highly recommended to set API access restriction by IP.

Access restrictions are configured on the tab "Access restriction":

The logic of work is as follows:

  • The address list is empty — access is open for all.
  • There is one or more addresses in the list — access is open only for addresses from the list, closed for the rest.

Addresses and subnets in CIDR format are added to the list of allowed by the button "Add IP to the list of allowed"... All added addresses are displayed in the list below. You can add a note to each of them or remove it from the list.

You can get acquainted with the list of methods, their descriptions, test their work and get code examples on the tab "Documentation"... The tab consists of several blocks.

In the block "Methods" a list of available methods is displayed:

Attention!

The documentation is being finalized, so not all methods have detailed descriptions.

The block with the name of the selected method contains its detailed description:

  • The method for sending the request is GET or POST.
  • URL — the address to which the request should be sent.
  • Parameters — a list of available parameters, data types for each of them and options for available values.
  • Detailed description of the method and its return values (not for all methods).

On the left side of the block "Request execution" there is a form for quickly sending a request on behalf of the current account, in the right one displays the response code and the result of the sent request:

When an action is performed in the control panel, the system automatically records the data of the last request to the corresponding method and stores it for 10 minutes. During this time, the documentation on the method page will show the date and time of its last call, you can view the list of parameters passed to it and substitute these parameters into the request form. For each method, only the data of the last 1 request made in the current account is stored.

In the block "Code example" shows example code for using the current method using cURL or a library HostingAPI:

  • Current active the token is automatically substituted into the string with the parameter $auth_token... If the token is not active, it will need to be activated and manually substituted into the code.
  • Parameters from shape after the query is executed, they are automatically substituted into the string with the parameter $post... If the request was not executed, the parameters will need to be specified independently.
Content