Send API calls using the command line
Prerequisites
To start sending API calls using the command line, ensure that curl is installed on your machine by running the curl --version command in the command line.
Main inputs for an API call:
•HTTP method
•Endpoint URL
•Authorization
When sending an API call from the command line, ensure you use the correct domain. You can locate the list of domains with the corresponding region in the Network Prerequisites topic. For details on the HTTP method, request path, request parameters, response and response codes, refer to the API Reference pages.
Alternatively, you can check the Swagger documentation; select the link according to your geographical region. When you select the required definition, you can see the corresponding domain under Servers.
Authorization requires the access token. To receive the access token, you must authenticate the API user.
Authentication
You can get your access token by following these steps:
1.Open the command line.
2.Type the following input with the corresponding domain, your username and password.
curl -X POST "https://DOMAIN_AUTH/oauth/token" ^ -H "Content-Type: application/x-www-form-urlencoded" ^ -d "grant_type=password" ^ -d "username=API_USER_USERNAME" ^ -d "password=API_USER_PASSWORD" ^ -d "refresh_token=" |
Input values details:
curl |
The tool used to send API calls. |
-X |
This option represents a request. You can also use --request |
POST |
HTTP method |
https://DOMAIN_AUTH/oauth/token |
Endpoint URL for Authentication. Use the domain according to the location of your ESET PROTECT/ESET Inspect Server (EU, DE, US, JPN, CA). |
-H |
This option represents a header. You can also use --header |
Content-Type: application/x-www-form-urlencoded |
Required header and its value |
-d |
This option represents data. You can also use --data |
grant_type |
Required field. Type password when requesting an access token or refresh_token when refreshing the existing token. |
username |
Username of the dedicated API user |
password |
Password of the dedicated API user |
refresh_token |
Optional field. Leave it empty or omit it completely when requesting an access token. Paste the refresh token string from the response when you need to refresh your token. |
3.Press Enter.
4.Copy and save the access token from the response; you will need it for further API calls.
API call execution
To execute your first API call, follow the steps below:
1.Select an API call you want to use, for example, Automation GET /v1/device_tasks.
2.In the command line, type the following input with the corresponding domain. Paste the access token to the Authorization header.
curl -X GET "https://DOMAIN_AUTOMATION/v1/device_tasks?pageSize=10" ^ |
Input values details:
curl |
The tool used to send API calls. |
-X |
This option represents a request. You can also use --request |
GET |
HTTP method |
https://DOMAIN_AUTOMATION/v1/device_tasks?pageSize=10 |
Endpoint URL for Automation with pageSize parameter. Use the domain according to the location of your ESET PROTECT/ESET Inspect Server (EU, DE, US, JPN, CA). For the pageSize parameter, we use 10 as an example. For more details, see Pagination. |
-H |
This option represents a header. You can also use --header |
Authorization: Bearer |
Required header and its value. Paste the access token you received in the previous call. |
3.Press Enter.
4.The server returns a response with details about existing device tasks.