python-glpi-utils¶
python-glpi-utils is a Python library for working with the GLPI REST API.
Features¶
- 🔄 Synchronous client (
GlpiAPI) powered byrequests - ⚡ Asynchronous client (
AsyncGlpiAPI) powered byaiohttp - 🔐 OAuth2 clients (
GlpiOAuthClient/AsyncGlpiOAuthClient) for the GLPI 11 and 12 high-level API (HL API 2.x and 3.0) with automatic token refresh - 📄 Auto-pagination — fetch every item across all pages with a single call (
get_all_pages/iter_pages) - 🧩 Fluent accessors — write
api.ticket.get(1)instead of building raw HTTP calls - 🔒
SensitiveFilter— masks passwords and tokens in debug logs automatically - 📦 Clean exception hierarchy — catch exactly what you need
- ✅ 262 tests across Python 3.9 – 3.13
GLPI compatibility¶
| Client | Endpoint | GLPI version |
|---|---|---|
GlpiAPI |
/apirest.php |
10.0, 11.x, 12.x |
AsyncGlpiAPI |
/apirest.php |
10.0, 11.x, 12.x |
GlpiOAuthClient |
/api.php |
11.0.6+, 12.x |
AsyncGlpiOAuthClient |
/api.php |
11.0.6+, 12.x |
The legacy REST API (/apirest.php) works the same on GLPI 10.0, 11.x and 12.x. GLPI 9.x is not supported. Tested in CI against real servers: the latest patch of GLPI 10.0, 11.0 and 12.0, on every pull request and weekly.
The high-level OAuth2 API (/api.php) was introduced in GLPI 11 (HL API 2.x); GLPI 12 adds HL API 3.0.
Installation¶
With async support:
Quick example¶
from glpi_utils import GlpiAPI
with GlpiAPI(url="https://glpi.example.com", app_token="YOUR_APP_TOKEN") as api:
api.login(username="glpi", password="glpi")
print("GLPI:", api.version) # GLPIVersion('10.0.19')
print("Is 10+:", api.version > 10) # True
# All tickets — automatic pagination
tickets = api.ticket.get_all_pages()
print(f"Total tickets: {len(tickets)}")
# Create a ticket
new = api.ticket.create({
"name": "Service degraded",
"content": "Users report slow response times.",
"type": 1,
"status": 1,
})
print(f"Created ticket #{new['id']}")