Skip to main content

A programmatic interface to OTRS SOAP API.

Project description

Python-OTRS : Python wrapper to OTRS SOAP API

Let you access the OTRS API a pythonic-way.


- Implements fully communication with the ``GenericTicketConnector``
provided as webservice example by OTRS;
- dynamic fields and attachments are supported;
- authentication is handled programmatically, per-request or per-session;
- calls are wrapped in OTRSClient methods;
- OTRS XML objects are mapped to Python-style objects see
objects.Article and objects.Ticket.

To be done

- Test for python3 compatibility and make resulting changes;
- improve and extend ````;

- Python 2.7;



pip install python-otrs


First make sure you installed the ``GenericTicketConnector`` webservice,
see `official documentation`_.


from otrs.client import GenericTicketConnector
from otrs.objects import Ticket, Article, DynamicField, Attachment

server_uri = r''
webservice_name = 'GenericTicketConnector'
client = GenericTicketConnector(server_uri, webservice_name)

Then authenticate, you have three choices :


# user session
client.user_session_register('login', 'password')

# customer_user session
client.customer_user_session_register('login' , 'password')

# save user in memory
client.register_credentials(user='login', 'password')

Play !

Create a ticket :


import mimetypes
import base64

t = Ticket(State='new', Priority='3 normal', Queue='Support',
Title='Problem test', CustomerUser='',
a = Article(Subject='UnitTest', Body='bla', Charset='UTF8',
df1 = DynamicField(Name='TestName1', Value='TestValue1')
df2 = DynamicField(Name='TestName2', Value='TestValue2')
att_path = r'C:\Temp\image001.png'
mimetype = mimetypes.guess_type(att_path)[0]
att_file = open(att_path , 'rb')
att_content = base64.b64encode(
att1 = Attachment(Content=att_content,
ContentType=mimetype, Filename="image001.png")

t_id, t_number = client.ticket_create(t, a, [df1, df2], [att1])

Update an article :


# changes the title of the ticket
t_upd = Ticket(Title='Updated ticket')
client.ticket_update(t_id, t_upd)

# appends a new article (attachments optional)
new_article = Article(Subject='Moar info', Body='blabla', Charset='UTF8',
client.update_ticket(article=new_article, attachments=None)

Search for tickets :


# returns all the tickets of customer 42
tickets = client.ticket_search(CustomerID=42)

# returns all tickets in queue Support
# for which Dynamic Field 'Project' starts with 'Pizza':
df2 = DynamicField(Name='Project', Value='Pizza%', Operator="Like")
client.ticket_search(Queues='Support', dynamic_fields=[df_search])

Retrieve a ticket :


ticket = client.ticket_get(138, get_articles=True, get_dynamic_fields=True, get_attachments=True)
article = ticket.articles()[0]

Many options are possible with requests, you can use all the options
available in `official documentation`_.

.. _official documentation:

Project details

Download files

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

Files for python-otrs, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size (13.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page