Zabbix Tutorials: Working with Zabbix API

Here is a short tutorial on how to use the Zabbix API:

  1. Create an API user: You need to create an API user in Zabbix before you can start using the API. To do this, go to Administration > Users and click on the Create User button. In the User tab, select the API role and enter a username and password for the user.
  2. Get an API token: Once you have created an API user, you need to get an API token for the user. To do this, go to Administration > Users and click on the API Tokens tab. Click on the Create Token button and enter a name for the token.
  3. Use the API: Now that you have an API token, you can start using the API. The Zabbix API documentation provides a detailed overview of the API. You can also use the Zabbix API Explorer to test the API calls.

Here are some examples of how to use the Zabbix API:

To get a list of hosts:
curl -X GET -H "Authorization: Bearer <API_TOKEN>" https://zabbix.example.com/api/v1/host
To create a new item:
curl -X POST -H "Authorization: Bearer <API_TOKEN>" -H "Content-Type: application/json" -d '{
    "hostid": 10001,
    "key": "system.cpu.load[all]",
    "type": "0",
    "value_type": "0",
    "multiplier": 1,
    "units": "percent"
}' https://zabbix.example.com/api/v1/item

# To get the list of host
curl --request POST   --url 'http://54.197.199.105/zabbix/api_jsonrpc.php'   --header 'Authorization: Bearer bc2dde7c3014a0cd77d662b40225bc634e922e7e4146a9f3a7da20fcf389f696'   --header 'Content-Type: application/json-rpc'   --data @data.json
Rajesh Kumar
Follow me
Latest posts by Rajesh Kumar (see all)
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x