Skip to content

python-glpi-utils

Tests PyPI version Python versions License: MIT

python-glpi-utils is a Python library for working with the GLPI REST API.


Features

  • 🔄 Synchronous client (GlpiAPI) powered by requests
  • Asynchronous client (AsyncGlpiAPI) powered by aiohttp
  • 🔐 OAuth2 clients (GlpiOAuthClient / AsyncGlpiOAuthClient) for the GLPI 11+ high-level API 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 ≥ 9.1 (tested on 10.x and 11.x)
AsyncGlpiAPI /apirest.php ≥ 9.1 (tested on 10.x and 11.x)
GlpiOAuthClient /api.php 11+ only
AsyncGlpiOAuthClient /api.php 11+ only

The legacy REST API (/apirest.php) has been stable since GLPI 9.1 and works without changes across 9.x, 10.x and 11.x. The high-level OAuth2 API (/api.php) was introduced in GLPI 11.


Installation

pip install glpi-utils

With async support:

pip install glpi-utils[async]

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']}")

Next steps