Files

2.1 KiB

Zabbix API — Reference for Portal Integration

Researched: 2026-07-07 | Zabbix 7.x

Protocol

JSON-RPC 2.0 over HTTP — single endpoint:

POST https://<zabbix-server>/zabbix/api_jsonrpc.php
Content-Type: application/json-rpc
Authorization: Bearer <token>

All requests are HTTP POST to one URL. No REST endpoints, no OpenAPI spec. Well-documented, stable.

Authentication

API token (recommended):

  • Create in Zabbix UI: Users > API tokens
  • Pass as Authorization: Bearer <token> header
  • Or use session via user.login method (returns token string)

Key Methods for Portal Integration

Portal Need Zabbix Method
List monitored hosts + status host.get with selectInterfaces, selectGroups
Live CPU/RAM/disk item.get with lastvalue, filter by host name
Bandwidth history history.get (raw) or trends.get (hourly/daily rollups)
Active problems/alerts problem.get or trigger.get with value=1
Acknowledge/close event event.acknowledge with action parameter
Register new device host.create with interface, template, group, macros
Real-time push Zabbix webhooks (Slack, Teams, custom URL) + action.create

Example: Get All Hosts (Python)

import requests, json
r = requests.post(
    "https://zabbix.example.com/api_jsonrpc.php",
    headers={"Authorization": f"Bearer {token}", "Content-Type": "application/json-rpc"},
    json={"jsonrpc": "2.0", "method": "host.get", "params": {"output": ["hostid","name","status"], "selectInterfaces": ["ip","dns","port"]}, "id": 1}
)

Example: Get Live CPU for a Host

host_id = "10234"
r = requests.post(url, headers=headers, json={
    "jsonrpc": "2.0",
    "method": "item.get",
    "params": {
        "hostids": host_id,
        "search": {"key_": "system.cpu.util"},
        "output": ["itemid", "name", "lastvalue", "lastclock"]
    },
    "id": 2
})

Feasibility Verdict

Highly feasible. The API is mature, stable, provides all needed operations for a portal monitoring dashboard. Cloud migration is just changing the endpoint URL.