Package: seatsio
seatsio-python, the official Seats.io Python SDKThis is the official Python client library for theSeats.io V2 REST API, supporting Python 3.7+.Installingpip install seatsioVersioningseatsio-python follows semver since v50.2.0.UsageGeneral instructionsTo use this library, you'll need to create aseatsio.Client:importseatsioclient=seatsio.Client(seatsio.Region.EU(),secret_key="my-workspace-secret-key")...You can find yourworkspace secret keyin thesettings section of the workspace.The region should correspond to the region of your account:seatsio.Region.EU(): Europeseatsio.Region.NA(): North-Americaseatsio.Region.SA(): South-Americaseatsio.Region.OC(): OceaniaIf you're unsure about your region, have a look at yourcompany settings page.Creating a chart and an eventimportseatsioclient=seatsio.Client(seatsio.Region.EU(),secret_key="my-workspace-secret-key")chart=client.charts.create()event=client.events.create(chart.key)Booking objectsimportseatsioclient=seatsio.Client(seatsio.Region.EU(),secret_key="my-workspace-secret-key")client.events.book(event.key,["A-1","A-2"])Releasing objectsimportseatsioclient=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 heldimportseatsioclient=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 statusimportseatsioclient=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)importseatsioclient=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 categoriesimportseatsioclient=seatsio.Client(seatsio.Region.EU(),secret_key="my-workspace-secret-key")category_list=client.charts.list_categories(<chartkey>)forcategoryincategory_list:print(category.label)Listing all chartsimportseatsioclient=seatsio.Client(seatsio.Region.EU(),secret_key="my-workspace-secret-key")charts=client.charts.list()forchartincharts:print("Chart: "+chart.key)Note:list()returns aPagedIterator, 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 pageE.g. to show charts in a paginated list on a dashboard.Each page contains anitemsarray of charts, andnext_page_starts_afterandprevious_page_ends_beforeproperties. 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()forchartinfirstPage.items:print("Chart: "+chart.key)# ... user clicks on 'next page' button ...nextPage=client.charts.list_page_after(firstPage.next_page_starts_after)forchartinnextPage.items:print("Chart: "+chart.key)# ... user clicks on 'previous page' button ...previousPage=client.charts.list_page_before(nextPage.previous_page_ends_before)forchartinpreviousPage.items:print("Chart: "+chart.key)Creating a workspaceimportseatsioclient=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 keyimportseatsio# 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-settingsclient=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 handlingWhen 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 backoffThis library supportsexponential backoff.When you send too many concurrent requests, the server returns an error429 - 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 error429, it waits a little longer, and try again. By default this happens 5 times, before giving up (after approximately 15 seconds).We throw aRateLimitExceededException(which is a subclass ofSeatsioException) when exponential backoff eventually fails.To change the maximum number of retries, create theClientas follows:importseatsioclient=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.