Skip to main content

Python client library for the OTOBO REST API

Project description

Python OTOBO Client Library

An asynchronous Python client for interacting with the OTOBO REST API. Built with httpx and pydantic for type safety and ease of use.

Features

  • Asynchronous HTTP requests using httpx.AsyncClient

  • Pydantic models for request and response data validation

  • Full CRUD operations for tickets:

    • TicketCreate
    • TicketSearch
    • TicketGet
    • TicketUpdate
    • TicketHistoryGet
  • Error handling via OTOBOError for API errors

  • Utility method search_and_get to combine search results with detailed retrieval

Installation

Install from PyPI:

pip install otobo

Quickstart

1. Configure the client

from otobo import TicketOperation, OTOBOClientConfig
from otobo import AuthData

config = OTOBOClientConfig(
    base_url="https://your-otobo-server/nph-genericinterface.pl",
    service="OTOBO",
    auth=AuthData(UserLogin="root@localhost", Password="1234"),
    operations={
        TicketOperation.CREATE.value:    "ticket-create",
        TicketOperation.SEARCH.value:    "ticket-search",
        TicketOperation.GET.value:       "ticket-get",
        TicketOperation.UPDATE.value:    "ticket-update",
        TicketOperation.HISTORY_GET.value: "ticket-history-get",
    }
)

2. Initialize the client

import logging
from httpx import AsyncClient
from otobo import OTOBOClient

logging.basicConfig(level=logging.INFO)

# Optionally inject your own AsyncClient
async_client = AsyncClient()

client = OTOBOClient(config, client=async_client)

3. Create a ticket

from models.request_models import TicketCreateParams
from models.response_models import OTOBOTicketCreateResponse

payload = TicketCreateParams(
    Ticket={
        "Title": "New Order",
        "Queue": "Sales",
        "State": "new",
        "Priority": "3 normal",
        "CustomerUser": "customer@example.com"
    },
    Article={
        "Subject":  "Product Inquiry",
        "Body":     "Please send pricing details...",
        "MimeType": "text/plain"
    }
)

response: OTOBOTicketCreateResponse = await client.create_ticket(payload)
print(response.TicketID, response.TicketNumber)

4. Search and retrieve tickets

from models.request_models import TicketSearchParams, TicketGetParams

search_params = TicketSearchParams(Title="%Order%")
search_res = await client.search_tickets(search_params)
ids = search_res.TicketID

for ticket_id in ids:
    get_params = TicketGetParams(TicketID=ticket_id, AllArticles=1)
    details = await client.get_ticket(get_params)
    print(details.Ticket[0])

5. Update a ticket

from models.request_models import TicketUpdateParams

update_params = TicketUpdateParams(
    TicketID=response.TicketID,
    Ticket={"State": "closed"}
)
await client.update_ticket(update_params)

6. Get ticket history

from models.request_models import TicketHistoryParams

history_params = TicketHistoryParams(TicketID=str(response.TicketID))
history_res = await client.get_ticket_history(history_params)
print(history_res.History)

7. Combined search and get

from models.response_models import FullTicketSearchResponse

full_res: FullTicketSearchResponse = await client.search_and_get(search_params)

License

MIT © Softoft, Tobias A. Bueck

Project details


Download files

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

Source Distribution

otobo-0.1.1.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

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

otobo-0.1.1-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file otobo-0.1.1.tar.gz.

File metadata

  • Download URL: otobo-0.1.1.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.16

File hashes

Hashes for otobo-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e276a213bef22deb25029b6d6583c39703b0fdf028f8f5e3c126b9e6981e91ad
MD5 ae0b6d3f8ac9101b293d5f562a99d2b4
BLAKE2b-256 e1a955de64d0b123dd70e6b83f57a08e30c612e0db045a56a429cb406a084334

See more details on using hashes here.

File details

Details for the file otobo-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: otobo-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.16

File hashes

Hashes for otobo-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a7480426ef2fa8e1d9fa467c3cd1ca6df460b5789f747631f8fa7a7fb351b52d
MD5 5ef1d2762550130826333eda8075881d
BLAKE2b-256 6c5a196a3662cc9de1272f56d74798c0cce7bd2cee20c23b702841637c4b9b0b

See more details on using hashes here.

Supported by

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