Skip to main content

glpi-python-client

CI Coverage License Python Docs

glpi-python-client is a typed Python client for the GLPI REST API.

The goal is to let GLPI integrations work with domain objects instead of raw JSON payloads. The package exposes Pydantic models for tickets, users, followups, documents, locations, and related records, while converting GLPI HTML content into Markdown for Python-side workflows and rendering Markdown back to HTML for outgoing payloads.

It currently focuses on ticket-centric workflows and exposes two high-level clients built on top of the GLPI v2 REST API:

  • GlpiClient — synchronous, blocking client.
  • AsyncGlpiClient — asynchronous client doing real non-blocking I/O on the event loop.

Neither wraps the other. The async tree is hand-written and the sync one is generated from it, so the two surfaces cannot drift apart.

Note that all integration tests using this package are made on GLPI 11. I cannot make any guarantee of the behaviour on previous versions.

While the package is preparing for 1.0, alot of potential breaking change might happen between versions. A deprecation policy will be put in place once 1.0 is out and the package have been stabilized.

Installation

pip install glpi-python-client

For local development:

python -m pip install -e .[dev]
python -m pytest

Quick Start

Create a client with your GLPI v2 API URL and at least one complete auth pair:

  • client_id and client_secret
  • username and password
  • both pairs together

Synchronous client

from glpi_python_client import GlpiClient, PostTicket

with GlpiClient(
    glpi_api_url="https://glpi.example.com/api.php/v2",
    server_timezone="Europe/Paris",
    client_id="oauth-client-id",
    client_secret="oauth-client-secret",
    username="api-user",
    password="api-password",
) as glpi:
    ticket_id = glpi.create_ticket(
        PostTicket(
            name="Printer issue",
            content="The printer is not reachable from the office network.",
        )
    )
    ticket = glpi.get_ticket(ticket_id)
    print(ticket.id, ticket.name)

Asynchronous client

import asyncio

from glpi_python_client import AsyncGlpiClient, PostTicket


async def main() -> None:
    async with AsyncGlpiClient(
        glpi_api_url="https://glpi.example.com/api.php/v2",
        server_timezone="Europe/Paris",
        client_id="oauth-client-id",
        client_secret="oauth-client-secret",
        username="api-user",
        password="api-password",
    ) as glpi:
        ticket_id = await glpi.create_ticket(
            PostTicket(
                name="Printer issue",
                content="The printer is not reachable from the office network.",
            )
        )
        ticket = await glpi.get_ticket(ticket_id)
        print(ticket.id, ticket.name)


asyncio.run(main())

GlpiClient.from_env() and AsyncGlpiClient.from_env() are also available when the credentials are already exposed as GLPI_-prefixed environment variables.

Sync or async?

Both clients expose the exact same endpoint surface and accept the same constructor arguments, because both are generated from one source: the async tree is hand-written and the sync one is produced from it by a build step that strips async/await. AsyncGlpiClient performs real non-blocking I/O on the event loop — there is no worker thread and no executor — and GlpiClient performs real blocking I/O with no coroutine scheduling. An auth lock serialises OAuth token acquisition on both surfaces, so concurrent fan-outs cannot race.

Pick GlpiClient for plain scripts, CLI tools, and synchronous services; pick AsyncGlpiClient when your application already runs an event loop or when you need concurrent fan-out (the aggregated get_ticket_context and per-ticket get_task_statistics helpers overlap their calls there, and run them one after another on the sync client).

Documentation

To build the Sphinx documentation locally:

python -m pip install -e .[docs]
python -m sphinx -b html docs docs/_build/html

Sponsoring & Professional services

The development of this package is indirectly supported by Novahé & Constellation.

If you need professional help or services around GLPI, we offer consulting and engineering services to install, maintain or upgarde GLPI instance, as an official GLPI partner.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

glpi_python_client-0.4.3.tar.gz (220.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

glpi_python_client-0.4.3-py3-none-any.whl (239.4 kB view details)

Uploaded Python 3

File details

Details for the file glpi_python_client-0.4.3.tar.gz.

File metadata

  • Download URL: glpi_python_client-0.4.3.tar.gz
  • Upload date:
  • Size: 220.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for glpi_python_client-0.4.3.tar.gz
Algorithm Hash digest
SHA256 98e7978edb7f3caf3b1ed3158245d575f9a3777a0e47da130925a07310aab7b6
MD5 cd37df8c599cd7c765f4fa2d5d6f911e
BLAKE2b-256 171124d043598aa1b02a2f2d307acc9ba78beffa6762c967c723d9d5996e4deb

See more details on using hashes here.

Provenance

The following attestation bundles were made for glpi_python_client-0.4.3.tar.gz:

Publisher: release.yml on baraline/glpi_python_client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file glpi_python_client-0.4.3-py3-none-any.whl.

File metadata

File hashes

Hashes for glpi_python_client-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f23e61e9a4d478fefae7a5a6bd31d5ff5532320d1d51232959aac3308a4ec8d5
MD5 9fbb29494bd2a4ba34045831bb55e943
BLAKE2b-256 5afd1c39db42a349e9ea19fbf8886d5651f7cfce50e12a60adbc72dc5fbb18ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for glpi_python_client-0.4.3-py3-none-any.whl:

Publisher: release.yml on baraline/glpi_python_client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page