RegioJet tickets

This folder exposes a small HTTP JSON API that reads tickets already bought on one RegioJet customer account.

There is no browser UI for the tickets themselves — only this documentation page and mcp.php.

The RegioJet calls and the ticket fields follow regiojet-mcp (list_my_tickets and get_my_ticket). Search, booking, payment, and cancellation from that package are not implemented here.

Security

Every call to mcp.php must present API_KEY from .env. Send it as the X-Api-Key header, as Authorization: Bearer …, or as api_key inside the JSON body. Leave it out of the query string.

While API_KEY is empty, the API answers 503 and does not call RegioJet. A wrong key answers 401.

RegioJet login lives in the same .env: REGIOJET_ACCOUNT_CODE and REGIOJET_PASSWORD. Each call logs in with those two values and sends the returned token as Bearer for that request only. The token is what regiojet-mcp calls REGIOJET_API_KEY. It is not stored in .env. Login returns an opaque token and no expiry, so this API does not reuse one across requests. Responses never include the password or the token.

Configuration (.env)

Endpoint: mcp.php (JSON API)

Use POST with a JSON body. Every request must include "action".

GET is supported for the same two actions. Put the API key in a header on GET, because the query string is not accepted as a key.

This API only reads. list and get are the only actions.

Actions

list — active tickets on the account, newest first. Canceled, deleted, and already used tickets are left out. Optional:

{"action":"list","api_key":"YOUR_API_KEY"}
{"action":"list","states":["VALID"],"from":"2026-05-01","to":"2026-05-31"}
{"action":"list","limit":20,"offset":0}

get — one active ticket by its numeric id. A canceled, deleted, or used id answers 404.

{"action":"get","id":123456789}

Ticket object

Each ticket is a short record: id, ticket_code, state, seat_class, price, currency, unpaid, expiration_date, passenger tariffs, and sections (line, stations, times, platform, seats). The field names match the trimmed ticket from regiojet-mcp.

When the train is already on its way, each section gains the current lateness from the public station board. The API matches the train number and the scheduled time on departures at the boarding station, then on arrivals at the alighting station if the train has already left. delay_minutes is that lateness (0 means the board currently reports on time). delay is the same value as HH:MM h (00:40 h is 40 minutes). arrival_time stays the scheduled time, and estimated_arrival_time is the scheduled arrival plus delay_minutes. A delay already printed on the ticket is kept when the board has no match. A section with no delay is not currently reporting one — the train has not started, or it is no longer on the board. That is not the same as confirmed on time.

Successful responses

JSON includes "ok": true. Errors return HTTP 4xx/5xx with "ok": false and an error field.