How to connect to the API
In this article, we will explain how to authorize and make a request to the API. After this, you will be able to send commands to the server and receive data from it.
API address
All requests are sent to:
https://<server_address>/api/api.php
|
<server_address>— this is the address of the server or host where PILOT is running.
For example:
-
For users: https://pilot-gps.com/api/api.php
-
For administrators: https://admin.pilot-gps.com/ax/api.php
The API can be located in different "folders" of the project, and this is reflected in the request address. For example:
https://<server_address>/backend/api.php
https://<server_address>/ax/api.php
|
The folders (api, backend, ax, etc.) are simply the project structure. They indicate which set of commands you're accessing. Always use the full folder path provided in the specific API command, otherwise, the request will not work.
Authorization type
The connection uses Basic Auth.
For regular API access (user), use your account login and password.
For administrator API access, use the administrator login and password.
What a request looks like
The general form of a request is:
https://<server_address>/api/api.php?cmd=<command>&node=<node_num>
|
-
cmd — the command you want to execute
-
node — the number of the node where the command should be executed
Example response
The server will return a response in JSON format:
{
"code": 0,
"msg": "OK",
...requested data...
}
|
-
code = 0 — everything was successful
-
code = 1 — an error occurred
-
msg — a message from the server (for example, "OK" or an error description)
If you prefer working with XML, add the parameter out=xml to the request — the result will be returned in XML format.
Example request:
https://<address>/api/api.php?cmd=<command>&node=<node_num>&out=xml
|
Response in XML format:
<response>
<code>0</code>
<msg>OK</msg>
...requested data...
</response>
|
If you are just starting to work with the API, we recommend first reading the article Working with API requests to understand commands, parameters, and data formats.