Skip to main content

The official Seats.io Python client library

Project description

seatsio-python, the official Seats.io Python client library

Build Status

This is the official Python client library for the Seats.io V2 REST API, supporting python 2.7, and python 3.3 - 3.7.

Installing

pip install seatsio

Versioning

seatsio-python only uses major version numbers: v5, v6, v7 etc. Each release - backwards compatible or not - receives a new major version number.

The reason: we want to play safe and assume that each release might break backwards compatibility.

Examples

Creating a chart and an event

import seatsio
client = seatsio.Client(secret_key="my-secret-key") # can be found on https://app.seats.io/settings
chart = client.charts.create()
event = client.events.create(chart.key)

Booking objects

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

Releasing objects

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

Booking objects that have been held

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

Changing object status

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

Listing all charts

import seatsio
client = seatsio.Client(secret_key="my-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(secret_key="my-company-admin-key")
client.workspaces.create("a workspace")

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.

Project details


Release history Release notifications | RSS feed

This version

50

Download files

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

Source Distribution

seatsio-50.tar.gz (13.2 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: seatsio-50.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.3

File hashes

Hashes for seatsio-50.tar.gz
Algorithm Hash digest
SHA256 7cdefc1acd3f7afb9270618969b15ace9c75422a182c8bc22e4ca8cdc4fed8c8
MD5 1a8c5feaf90441887aa1a4d89f536b1b
BLAKE2b-256 a1c13aece330b407143bc718acdc218b4d419e2bb5c83d4752c5a9c822a604dd

See more details on using hashes here.

Supported by

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