SGR Public Trip Search API
Comprehensive documentation for querying trip schedules and seat availability on Tanzania's Standard Gauge Railway
Created: 01 January 2026 | Updated: 07 January 2026
Introduction
This documentation provides a technical deep-dive into the unofficial public-facing API endpoint for querying trip schedules and seat availability on the Tanzania Railway Corporation (TRC) Standard Gauge Railway (SGR).
The information herein is derived from empirical analysis and is intended for developers and system architects building applications that integrate with the SGR ticketing system.
Live Seat Availability Checker
Test the API in real-time by checking seat availability for your desired route.
Overview
Endpoint
POST /TICIDIS/api/v1/Public/SearchTrip
Authentication
Not Required
Content Type
application/json
Base URL
sgrticket-api.trc.co.tz
Use Cases
Mobile Applications
Build native iOS or Android apps that allow users to check train schedules and seat availability on the go.
Web Portals
Create web-based booking systems or information portals for travel agencies and customers.
Chatbots & AI Assistants
Integrate with messaging platforms to provide real-time train information through conversational interfaces.
Analytics & Monitoring
Track seat availability trends, pricing patterns, and route popularity for business intelligence.
Requirements
HTTP Client
Any HTTP client capable of making POST requests (fetch, axios, curl, etc.)
JSON Support
Ability to serialize and deserialize JSON payloads
Date Handling
Support for ISO 8601 date format (YYYY-MM-DD and timestamps)
Error Handling
Robust error handling for network failures and API changes
How It Works
Send Request
POST JSON payload with search parameters to the API endpoint
API Processing
Server validates parameters and queries the SGR database
Data Retrieval
System fetches available trips and seat information
Receive Response
JSON response with trip details and seat availability
Step-by-Step Instructions
Prepare Request Headers
Set Content-Type and Accept headers to application/json
Build JSON Payload
Include all required fields: boarding/landing station IDs, date, passenger count, etc.
Format Dates Correctly
Use YYYY-MM-DD for date field and ISO 8601 UTC timestamp for departureDate and returnDate
Send POST Request
Make the HTTP POST request to the API endpoint
Parse Response
Extract trip data and aggregate seat availability by class type
Display Results
Present the information to users in a clear, organized format
Code Examples
cURL Example
curl -X POST https://sgrticket-api.trc.co.tz/TICIDIS/api/v1/Public/SearchTrip \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"boardingStationId": 1,
"landingStationId": 12,
"date": "2025-09-25",
"isOneWay": true,
"passengerCount": 1,
"departureDate": "2025-09-25T00:00:00.000Z",
"returnDate": "2025-09-25T00:00:00.000Z",
"isReservation": false,
"loginType": 2
}'
JavaScript (Fetch API)
async function searchSGRTrips(fromId, toId, date) {
const payload = {
boardingStationId: fromId,
landingStationId: toId,
date: date,
isOneWay: true,
passengerCount: 1,
departureDate: `${date}T00:00:00.000Z`,
returnDate: `${date}T00:00:00.000Z`,
isReservation: false,
loginType: 2
};
const response = await fetch(
'https://sgrticket-api.trc.co.tz/TICIDIS/api/v1/Public/SearchTrip',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify(payload)
}
);
const data = await response.json();
return data;
}
Python (Requests)
import requests
import json
def search_sgr_trips(from_id, to_id, date):
url = "https://sgrticket-api.trc.co.tz/TICIDIS/api/v1/Public/SearchTrip"
payload = {
"boardingStationId": from_id,
"landingStationId": to_id,
"date": date,
"isOneWay": True,
"passengerCount": 1,
"departureDate": f"{date}T00:00:00.000Z",
"returnDate": f"{date}T00:00:00.000Z",
"isReservation": False,
"loginType": 2
}
headers = {
"Content-Type": "application/json",
"Accept": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
return response.json()
Request Parameters
HTTP Headers
| Header | Value | Required | Description |
|---|---|---|---|
Content-Type |
application/json |
Yes | Specifies request body format |
Accept |
application/json |
Yes | Expected response format |
Payload Parameters
| Field | Type | Required | Description | Example |
|---|---|---|---|---|
boardingStationId |
Integer | Yes | Origin station ID | 1 |
landingStationId |
Integer | Yes | Destination station ID | 12 |
date |
String | Yes | Travel date (YYYY-MM-DD), within 7-day window | "2025-09-25" |
isOneWay |
Boolean | Yes | Must be true | true |
passengerCount |
Integer | Yes | Number of passengers | 1 |
departureDate |
String | Yes | ISO 8601 UTC timestamp | "2025-09-25T00:00:00.000Z" |
returnDate |
String | Yes | Same as departureDate (API quirk) | "2025-09-25T00:00:00.000Z" |
isReservation |
Boolean | Yes | Must be false | false |
loginType |
Integer | Yes | Public user type (static value) | 2 |
Station Reference
| ID | Station Name |
|---|---|
1 | Dar Es Salaam |
2 | Pugu |
3 | Soga |
4 | Ruvu |
5 | Ngerengere |
6 | Morogoro |
7 | Mkata |
8 | Kilosa |
9 | Kidete |
10 | Gulwe |
11 | Igandu |
12 | Dodoma |
Response Structure
Root Object
| Key | Type | Description |
|---|---|---|
ok |
Boolean | true for success, false otherwise |
code |
Integer | HTTP status code (typically 200) |
message |
String | Status message (e.g., "GNRL100 - Success.") |
data |
Array | Array of Trip objects (empty if no results) |
Trip Object
| Key | Type | Description | Example |
|---|---|---|---|
tripId |
Integer | Unique trip identifier | 88 |
tripName |
String | Service name | "DAR - DOM / ORDINARY LINE" |
date |
String | Departure date with timezone | "2025-10-02T00:00:00+03:00" |
startTime |
String | Departure time (HH:mm:ss) | "18:55:00" |
endTime |
String | Arrival time (HH:mm:ss) | "23:01:00" |
tripsPrice |
Float | Base fare amount | 31500.0 |
tripsPriceCurrency |
String | Currency code | "TZS" |
railwayCars |
Array | Array of Railway Car objects | [...] |
Railway Car Object
| Key | Type | Description | Example |
|---|---|---|---|
railwayCarId |
Integer | Car model ID | 19 |
typeId |
Integer | Class type ID | 151 |
typeName |
String | Class name (Royal/Economy) | "Royal Class" |
capacity |
Integer | Total seat capacity | 44 |
emptySeats |
Integer | Available seats (0 = full) | 24 |
hasSeat |
Boolean | Has assignable seats | true |
standardSeatCapacity |
Integer | Standard seat total | 44 |
disabledSeatCapacity |
Integer | Accessible seat total | 0 |
emptyStandardSeats |
Integer | Available standard seats | 24 |
emptyDisabledSeats |
Integer | Available accessible seats | 0 |
Errors & Troubleshooting
Common Errors
Empty Response (ok: true, data: [])
Causes:
- No trips available for the selected route and date
- Date is outside the 7-day booking window
- Invalid station ID combination
Solution: Try different dates or verify station IDs
400 Bad Request
Causes:
- Missing required fields in payload
- Invalid date format
- Incorrect data types (e.g., string instead of integer)
Solution: Validate all payload fields match the specification exactly
Rate Limiting / Timeouts
Causes:
- Too many requests from the same IP
- Server-side issues or maintenance
Solution: Implement exponential backoff and respect reasonable polling intervals
Important Notes
Data Aggregation Required
A single train may have multiple cars of the same class. You must iterate through all railwayCars and sum emptySeats by typeName to get accurate availability.
7-Day Booking Window
The API only returns results for dates within the next 7 days. Requests beyond this window will return empty results.
returnDate Field Quirk
Even though isOneWay is true, the returnDate field is mandatory. Use the same value as departureDate.
API Volatility
This is an unofficial endpoint. Field names, structure, and even the URL may change without notice. Build with defensive coding practices.
Backend Implementation
For production use, proxy API calls through your backend to avoid CORS issues and protect against client-side rate limiting.
Timezone Awareness
Times are in East Africa Time (EAT, UTC+3). The date field includes timezone offset (+03:00).
Changelog
- Updated documentation with latest empirical findings
- Added comprehensive station reference table
- Clarified returnDate field requirement
- Enhanced error handling guidelines
- Initial documentation release
- Documented core endpoint functionality
- Provided basic code examples
Disclaimer
This is unofficial documentation derived from empirical analysis of the Tanzania Railway Corporation's public API endpoints.
This documentation is not endorsed, maintained, or supported by Tanzania Railway Corporation (TRC) or any official government entity.
Use at your own risk:
- The API endpoint, data structures, and behavior may change without notice
- There is no guarantee of availability, accuracy, or stability
- Applications built on this endpoint should implement robust error handling
- For official booking and information, use sgrticket.trc.co.tz
The author and contributors assume no liability for any issues arising from the use of this documentation or the API it describes.