Skip to content

Tickets ​

Every method raises SkapiError with a code and a message, and can raise NETWORK_ERROR when no answer comes back. See Tickets.

consume_ticket ​

python
skapi.consume_ticket(ticket_id: str, method: str = "POST", data: dict | None = None, auth: bool = False) -> Any

Calls a ticket of the project, at https://<first 4 characters of the Project ID>.skapi.dev/.

argument
ticket_idLetters, digits, _ and -, up to 64 characters, starting with a letter or digit.
method"GET" or "POST", any case. GET sends data as the query string (/tg/ route); POST sends it as the JSON body (/tp/ route).
dataThe request data. Defaults to {}.
authTrue sends the call as the signed-in user (POST /tpa/ route, with the user's token). POST only.

Returns the receipt, or the body a Respond action of the ticket composed, as sent:

python
{
    "ticket_id": str,
    "consume_id": str,   # base62 of the time in milliseconds, then 4 random characters
    "user_id": str,      # the user with auth=True, else "<ip>(<user agent>)"
    "is_test": False,
    "timestamp": int,    # milliseconds, read from consume_id
    "hash": str,         # proof string of the consumption
    "queued": True,      # only when the call waits for a free slot; its actions run later
    "position": int,     # with queued: place in the line, 1 = next
}

Errors ​

codemessage
INVALID_PARAMETERTicket ID is required.
INVALID_PARAMETERInvalid "ticket_id". Use letters, digits, "_" and "-" (up to 64 chars, starting with a letter or digit).
INVALID_PARAMETERMethod is required. Should be either "GET" or "POST"
INVALID_PARAMETERMethod should be either "GET" or "POST".
INVALID_PARAMETERSigned-in consumption is POST only.
INVALID_REQUESTUser login is required. (auth=True, signed out)
TICKET_BUSYevery slot of a ticket with a concurrency limit is taken. Nothing was consumed; try again later. cause carries {"concurrency", "running", "waiting", "self_calling"} in its detail.
the ticket's codethe ticket's message. cause is the whole error body: {"code", "message", "stage", "action"?, "detail"?, "ticket_id"}. Raised whether the ticket answered 400 or 200. See When a consumption fails.

get_tickets ​

python
skapi.get_tickets(params: dict | None = None, fetch_options: dict | None = None) -> dict

The project's tickets. Signed-in users only. Returns {"list", "startKey", "endOfList", "startKeyHistory"}, up to 100 a page; see Paging.

keytype
ticket_idstrOnly this ticket.

Each row:

key
ticket_id
description
countconsumptions left, when the ticket has a count
time_to_livewhen it expires, milliseconds, when it has one
timestampwhen it was registered, milliseconds

Errors ​

codemessage
INVALID_REQUESTUser login is required.
INVALID_REQUESTInvalid ticket id. (ticket_id contains # or @)

get_consumed_tickets ​

python
skapi.get_consumed_tickets(params: dict | None = None, fetch_options: dict | None = None) -> dict

The signed-in user's own consumptions, the ones made with auth=True, oldest first. Returns {"list", "startKey", "endOfList", "startKeyHistory"}.

keytype
ticket_idstrOnly tickets whose ID starts with this.

Each row:

key
ticket_id, consume_id, timestampas in the receipt
user_id, regthe user's ID
is_testFalse (dry runs are anonymous, so they never appear here)
descriptionthe consumption log as JSON text, with data, method, headers, ip, user_agent, timestamp and outcome (ok, actions, error, ...)
hashproof string of the consumption

Errors ​

codemessage
INVALID_REQUESTUser login is required.

skapi-py 2.4.0