Skip to main content

python-glpi-utils

Tests PyPI version Python versions License: AGPL v3

Python client for GLPI that handles both of its APIs for you: the legacy REST API and the OAuth2 High-Level API, sync or async, with pagination and token refresh built in.

You write api.ticket.get_all_pages() instead of managing session tokens, Content-Range headers, OAuth2 expiry and the different URL layout of each API. Licensed under the AGPL-3.0-or-later since 2.0.0 (1.5.0 and earlier remain MIT). Python 3.9+, depends on requests (plus aiohttp for the async clients).

pip install glpi-utils      # imported as glpi_utils
from glpi_utils import GlpiAPI

with GlpiAPI(url="https://glpi.example.com") as api:      # logs out on exit
    api.login(username="glpi", password="glpi")
    print(api.version)                                     # GLPI server version: 12.0.0

    ticket = api.ticket.create({"name": "srv-db01 unreachable", "content": "ICMP loss 100%"})
    api.ticket.add_sub_item(ticket["id"], "ITILFollowup", {"content": "On-call notified"})

    for t in api.ticket.get_all_pages():                   # every page, fetched for you
        print(t["id"], t["name"])                          # one line per ticket, e.g. 7 srv-db01 unreachable

Why this one

The most used alternative on PyPI is glpi-api. Choose by what you need:

python-glpi-utils glpi-api
Legacy REST API (/apirest.php) yes yes
High-Level API with OAuth2 (/api.php, GLPI 11 and 12) yes, with API version pinning no
Async client (aiohttp) yes no
Fetch every page in one call get_all_pages() / iter_pages() no
Legacy search engine by field name (mapped to numeric search-option IDs) no, pass the IDs yes (field_id, list_search_options)
get_multiple_items, download_document no yes
License AGPL-3.0-or-later GPL-3.0

If you only call the legacy API synchronously and want to search it by field names, glpi-api is the more established choice. Use this library for async code or for the High-Level API of GLPI 11 and 12. Both libraries work with the legacy API on GLPI 12.

Install

pip install glpi-utils             # GlpiAPI, GlpiOAuthClient
pip install "glpi-utils[async]"    # adds AsyncGlpiAPI, AsyncGlpiOAuthClient

On the GLPI side, enable the API in Setup → General → API. For the legacy API, pass app_token= only if your GLPI API client defines one. For the High-Level API, add an OAuth client in Setup → OAuth clients with the Password grant and the api scope.

Clients

Sync / async GLPI API Auth GLPI versions
GlpiAPI / AsyncGlpiAPI legacy /apirest.php username + password, or personal user_token 10.0 and later
GlpiOAuthClient / AsyncGlpiOAuthClient High-Level /api.php OAuth2 password grant, token refreshed automatically 11.0.6 and later, 12
from glpi_utils.oauth import GlpiOAuthClient

with GlpiOAuthClient(url="https://glpi.example.com", client_id="...", client_secret="...",
                     username="svc-api", password="...", api_version="2.3") as api:
    api.authenticate()
    api.search("Ticket", filter="status.id==1;name=like=*srv*", limit=20)

Pin api_version on the OAuth2 clients. If you leave it out, the server picks its newest High-Level API version: 2.3 on GLPI 11, 3.0 on GLPI 12. The two return different schemas. Pinning "2.3" keeps code written for GLPI 11 working on 12 (12.0.0 only adds a few fields to 2.3 and drops the Plug dropdowns); you miss the endpoints added in 3.0, such as login-session management. filter takes RSQL expressions over field names. See the OAuth2 guide for the differences.

All clients share the same accessors (api.ticket, api.computer, api.user, … or api.item("AnyItemtype")), CRUD methods, sub-items, typed exceptions (GlpiAuthError, GlpiNotFoundError, GlpiPermissionError…) and debug logging with passwords and tokens masked. Settings can come from environment variables (GLPI_URL, GLPI_USER, GLPI_USER_TOKEN, GLPI_OAUTH_CLIENT_ID, GLPI_API_VERSION…).

Documentation

Guides and API reference: https://giovanny07.github.io/python-glpi-utils/

Status

Beta, actively maintained. Releases follow semantic versioning and every change is listed in the CHANGELOG. The legacy clients are the most stable part. The OAuth2 clients follow GLPI's High-Level API, which is still evolving, and their behaviour changed in 1.4 and 1.5.

The plan is to declare the library stable in 2.1.0. That needs four consecutive weeks of passing integration runs against GLPI 10, 11 and 12, counted from 2026-10-13, with no change to the public API in that time. From then on, the public API is every name exported by glpi_utils and glpi_utils.oauth that does not start with an underscore. Removing or changing any of those names will need a new major version, and will be preceded by at least one minor release in which the old form emits a DeprecationWarning.

Unit tests run in CI on Python 3.9 to 3.13. Integration tests run both clients, sync and async, against official glpi/glpi containers: the latest patch of GLPI 10.0 (legacy API), 11.0 and 12.0 (legacy API and every High-Level API version the server offers), on every pull request and weekly. GLPI 9.x is not supported.

Contributing

Bug reports with your GLPI version and a traceback are the most useful contribution: open an issue. For code, see the contributing guide.

License

Copyright (C) 2025-2026 Giovanny Rodriguez, Imagunet.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. It is distributed WITHOUT ANY WARRANTY; see the license for details.

Releases up to and including 1.5.0 were published under the MIT License and remain available under it.

Metadata

Release files for glpi-utils 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for glpi-utils 2.0.1
File Size Uploaded
glpi_utils-2.0.1.tar.gz 58.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for glpi-utils 2.0.1
File Interpreter ABI Platform
glpi_utils-2.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 102.8 kB

Release files / glpi_utils-2.0.1.tar.gz

Download URL glpi_utils-2.0.1.tar.gz
Size 58.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8584ecc8fcc82556f4419020c10a747bdfb3e512cdf5615843a587f6d45d6f8a
BLAKE2b-256 checksum
How to use checksums
974a3a1f0619a2897c383cd1008280491b63c6959e2a405e19a1d2bba082ce74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Release files / glpi_utils-2.0.1-py3-none-any.whl

Download URL glpi_utils-2.0.1-py3-none-any.whl
Size 44.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
20333d037ff75c2af1147d0ee663d148a800dedd50ba8c97dc26667b94efda3f
BLAKE2b-256 checksum
How to use checksums
7bebdec6081eae1edb3e407c95f53bf1e0d05d152926a72086694b674d142c07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Release history Release notifications | RSS feed

This release

2.0.1 This release

2 release files

2.0.0

2 release files

1.5.0

2 release files

1.4.5

2 release files

1.4.4

2 release files

1.4.3

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.9

2 release files

1.3.7

2 release files

1.3.6

2 release files

1.3.5

2 release files

1.3.4

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page