Skip to main content

The official Seats.io Python SDK

Project description

seatsio-python, the official Seats.io Python SDK

Build PyPI version

This is the official Python SDK for the Seats.io V2 REST API, supporting Python 3.10 or newer.

Installing

pip install seatsio

Or:

uv add seatsio

Versioning

seatsio-python follows semver since v50.2.0.

Usage

General instructions

To use this library, you'll need to create a seatsio.Client:

import seatsio
client = seatsio.Client(seatsio.Region.EU(), secret_key="my-workspace-secret-key")
...

You can find your workspace secret key in the settings section of the workspace.

The region should correspond to the region of your account:

  • seatsio.Region.EU(): Europe
  • seatsio.Region.NA(): North-America
  • seatsio.Region.SA(): South-America
  • seatsio.Region.OC(): Oceania

If you're unsure about your region, have a look at your company settings page.

Creating a chart and an event

import seatsio
client = seatsio.Client(seatsio.Region.EU(), secret_key="my-workspace-secret-key")
chart = client.charts.create()
event = client.events.create(chart.key)

Booking objects

import seatsio
client = seatsio.Client(seatsio.Region.EU(), secret_key="my-workspace-secret-key")
client.events.book(event.key, ["A-1", "A-2"])

Releasing objects

import seatsio
client = seatsio.Client(seatsio.Region.EU(), secret_key="my-workspace-secret-key")
client.events.release(event.key, ["A-1", "A-2"])

Booking objects that have been held

import seatsio
client = seatsio.Client(seatsio.Region.EU(), secret_key="my-workspace-secret-key")
client.events.book(event.key, ["A-1", "A-2"], hold_token="a-hold-token")

Changing object status

import seatsio
client = seatsio.Client(seatsio.Region.EU(), secret_key="my-workspace-secret-key")
client.events.change_object_status("<EVENT KEY>", ["A-1", "A-2"], "my-custom-status")

Retrieving object category and status (and other information)

import seatsio
client = seatsio.Client(seatsio.Region.EU(), secret_key="my-workspace-secret-key")
object_infos = client.events.retrieve_object_infos(event.key, ["A-1", "A-2"])

print(object_infos["A-1"].category_key)
print(object_infos["A-1"].category_label)
print(object_infos["A-1"].status)

print(object_infos["A-2"].category_key)
print(object_infos["A-2"].category_label)
print(object_infos["A-2"].status)

Listing a chart's categories

import seatsio
client = seatsio.Client(seatsio.Region.EU(), secret_key="my-workspace-secret-key")
category_list = client.charts.list_categories(<chart key>)
for category in category_list:
  print(category.label)

Updating a category

import seatsio
client = seatsio.Client(seatsio.Region.EU(), secret_key="my-workspace-secret-key")
client.charts.update_category(chart_key=chart.key, category_key=1, label="Updated label", color="#bbbbbb", accessible=True)

Listing all charts

import seatsio
client = seatsio.Client(seatsio.Region.EU(), secret_key="my-workspace-secret-key")
charts = client.charts.list()
for chart in charts:
  print("Chart: " + chart.key)

Note: list() returns a PagedIterator, which under the hood calls the seats.io API to fetch charts page by page. So multiple API calls may be done underneath to fetch all charts.

Listing charts page by page

E.g. to show charts in a paginated list on a dashboard.

Each page contains an items array of charts, and next_page_starts_after and previous_page_ends_before properties. Those properties are the chart IDs after which the next page starts or the previous page ends.

# ... user initially opens the screen ...

firstPage = client.charts.list_first_page()
for chart in firstPage.items:
  print("Chart: " + chart.key)
# ... user clicks on 'next page' button ...

nextPage = client.charts.list_page_after(firstPage.next_page_starts_after)
for chart in nextPage.items:
  print("Chart: " + chart.key)
# ... user clicks on 'previous page' button ...

previousPage = client.charts.list_page_before(nextPage.previous_page_ends_before)
for chart in previousPage.items:
  print("Chart: " + chart.key)

Creating a workspace

import seatsio
client = seatsio.Client(seatsio.Region.EU(), secret_key="my-company-admin-key")
client.workspaces.create("a workspace")

Creating a chart and an event with the company admin key

import seatsio
# company admin key can be found on https://app.seats.io/company-settings
# workspace public key can be found on https://app.seats.io/workspace-settings
client = seatsio.Client(seatsio.Region.EU(), secret_key="my-company-admin-key", workspace_key="my-workspace-public-key")
chart = client.charts.create()
event = client.events.create(chart.key)

Error handling

When an API call results in a 4xx or 5xx error (e.g. when a chart could not be found), a SeatsioException is raised.

This exception contains a message string describing what went wrong, and also two other properties:

  • Errors: a list of errors (containing a code and a message) that the server returned. In most cases, this list will contain only one element.
  • RequestId: the identifier of the request you made. Please mention this to us when you have questions, as it will make debugging easier.

Rate limiting - exponential backoff

This library supports exponential backoff.

When you send too many concurrent requests, the server returns an error 429 - Too Many Requests. The client reacts to this by waiting for a while, and then retrying the request. If the request still fails with an error 429, it waits a little longer, and try again. By default this happens 5 times, before giving up (after approximately 15 seconds).

We throw a RateLimitExceededException (which is a subclass of SeatsioException) when exponential backoff eventually fails.

To change the maximum number of retries, create the Client as follows:

import seatsio
client = seatsio.Client(seatsio.Region.EU(), secret_key="my-workspace-secret-key", max_retries=3)

Passing in 0 disables exponential backoff completely. In that case, the client will never retry a failed request.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

seatsio-83.12.0.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

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

seatsio-83.12.0-py3-none-any.whl (33.8 kB view details)

Uploaded Python 3

File details

Details for the file seatsio-83.12.0.tar.gz.

File metadata

  • Download URL: seatsio-83.12.0.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for seatsio-83.12.0.tar.gz
Algorithm Hash digest
SHA256 caab938b2297e9ae13bc3ff805dd6b35b479183f351a9266a6683117ab6a0531
MD5 93db9323c98e3aedcf00b05e9972371d
BLAKE2b-256 c93588f4be1a02b1dbb783d504d320280d545c16538bfd686b3b8b564723e2af

See more details on using hashes here.

File details

Details for the file seatsio-83.12.0-py3-none-any.whl.

File metadata

  • Download URL: seatsio-83.12.0-py3-none-any.whl
  • Upload date:
  • Size: 33.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for seatsio-83.12.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ca28ddeea10080d6d4123fe8a06a7a9b338526bccf5b36f6f8df35c82c89b9a9
MD5 f318352a7e958ca305bedde92e15d302
BLAKE2b-256 c0bef503bebc35d330b699c9d2b606f4df92c2454a0640adf45330d8986746ea

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