Skip to main content

Ticket Scanning API

The Ticket Scanning API allows you to scan and validate tickets using mobile devices. This API is designed to be used with the TiBillet mobile scanning application.

Endpoints​

Pair a Device​

GET /scan/{token}/pair

This endpoint is used to pair a mobile device with the TiBillet system. The token is generated when creating a new scanning device in the admin interface.

Response​

{
"success": true,
"message": "Device successfully paired",
"api_key": "YOUR_API_KEY",
"device_uuid": "12345678-1234-5678-1234-567812345678",
"device_name": "Entrance Scanner"
}

Test API Connection​

GET /scan/test_api/

This endpoint is used to test if the API key is valid and the connection to the server is working.

Headers​

NameRequiredDescription
AuthorizationYesAPI key in the format: Api-Key YOUR_API_KEY

Response​

{
"success": true,
"message": "API key is valid",
"device_info": {
"uuid": "12345678-1234-5678-1234-567812345678",
"name": "Entrance Scanner",
"claimed": true,
"archived": false
},
"server_info": {
"tenant": "Example Organization",
"domain": "example.tibillet.org",
"timestamp": "2023-06-15T14:30:45.123456+00:00"
}
}

Check Ticket Status​

POST /scan/check_ticket/

This endpoint is used to check the status of a ticket without scanning it.

Headers​

NameRequiredDescription
AuthorizationYesAPI key in the format: Api-Key YOUR_API_KEY
Content-TypeYesMust be application/json

Request Body​

{
"qrcode_data": "BASE64_ENCODED_DATA:SIGNATURE"
}

Response​

{
"success": true,
"message": "Ticket information retrieved",
"ticket": {
"uuid": "12345678-1234-5678-1234-567812345678",
"status": "Valid and not scanned",
"is_scanned": false,
"event": "Example Event",
"first_name": "John",
"last_name": "Doe",
"price": "General Admission",
"product": "Concert Ticket",
"scanned_by": null
},
"reservation": {
"uuid": "87654321-8765-4321-8765-432187654321",
"tickets_count": 2
}
}

Scan Ticket​

POST /scan/ticket/

This endpoint is used to scan and validate a ticket.

Headers​

NameRequiredDescription
AuthorizationYesAPI key in the format: Api-Key YOUR_API_KEY
Content-TypeYesMust be application/json

Request Body​

{
"qrcode_data": "BASE64_ENCODED_DATA:SIGNATURE"
}

Response (Success)​

{
"success": true,
"message": "Ticket successfully scanned",
"ticket": {
"uuid": "12345678-1234-5678-1234-567812345678",
"status": "Valid and scanned",
"event": "Example Event",
"first_name": "John",
"last_name": "Doe",
"price": "General Admission",
"product": "Concert Ticket"
},
"reservation": {
"uuid": "87654321-8765-4321-8765-432187654321",
"tickets_count": 2
}
}

Response (Already Scanned)​

{
"success": false,
"message": "Ticket already scanned",
"ticket": {
"uuid": "12345678-1234-5678-1234-567812345678",
"status": "Valid and scanned",
"event": "Example Event",
"first_name": "John",
"last_name": "Doe",
"price": "General Admission",
"product": "Concert Ticket",
"scanned_by": "98765432-9876-5432-9876-543298765432"
},
"reservation": {
"uuid": "87654321-8765-4321-8765-432187654321",
"tickets_count": 2
}
}

Code Examples​

Pairing a Device​

# The token is obtained from the QR code in the admin interface
TOKEN="your_token_here"

curl -X GET "https://example.tibillet.org/scan/${TOKEN}/pair"

Testing API Connection​

API_KEY="your_api_key_here"

curl -X GET "https://example.tibillet.org/scan/test_api/" \
-H "Authorization: Api-Key ${API_KEY}"

Checking Ticket Status​

API_KEY="your_api_key_here"
QRCODE_DATA="base64_encoded_data:signature"

curl -X POST "https://example.tibillet.org/scan/check_ticket/" \
-H "Authorization: Api-Key ${API_KEY}" \
-H "Content-Type: application/json" \
-d "{\"qrcode_data\": \"${QRCODE_DATA}\"}"

Scanning a Ticket​

API_KEY="your_api_key_here"
QRCODE_DATA="base64_encoded_data:signature"

curl -X POST "https://example.tibillet.org/scan/ticket/" \
-H "Authorization: Api-Key ${API_KEY}" \
-H "Content-Type: application/json" \
-d "{\"qrcode_data\": \"${QRCODE_DATA}\"}"