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

Version 1.1 No Auth Required RESTful API

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.

Important: This is not official documentation. All endpoints and data structures are subject to unannounced changes by TRC.

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

1

Send Request

POST JSON payload with search parameters to the API endpoint

2

API Processing

Server validates parameters and queries the SGR database

3

Data Retrieval

System fetches available trips and seat information

4

Receive Response

JSON response with trip details and seat availability

Step-by-Step Instructions

1

Prepare Request Headers

Set Content-Type and Accept headers to application/json

2

Build JSON Payload

Include all required fields: boarding/landing station IDs, date, passenger count, etc.

3

Format Dates Correctly

Use YYYY-MM-DD for date field and ISO 8601 UTC timestamp for departureDate and returnDate

4

Send POST Request

Make the HTTP POST request to the API endpoint

5

Parse Response

Extract trip data and aggregate seat availability by class type

6

Display Results

Present the information to users in a clear, organized format

Code Examples

cURL Example

bash
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)

javascript
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)

python
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
1Dar Es Salaam
2Pugu
3Soga
4Ruvu
5Ngerengere
6Morogoro
7Mkata
8Kilosa
9Kidete
10Gulwe
11Igandu
12Dodoma

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

Pro Tip: Always implement comprehensive error handling and logging in production applications to track API changes and issues.

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

v1.1 January 07, 2026
  • Updated documentation with latest empirical findings
  • Added comprehensive station reference table
  • Clarified returnDate field requirement
  • Enhanced error handling guidelines
v1.0 January 01, 2026
  • 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.

Author

Isaiah P. Nyalali

Isaiah P. Nyalali

Software Developer & Technical Writer

Connect on LinkedIn

If you find this documentation helpful or have suggestions for improvements, feel free to reach out. Contributions and feedback are always welcome!