This documentation provides the information for the type of API and act as a quick user guide for using our API service. There are a total of 3 API service provided by MTREC.
Make a GET request to https://api.mtrec.name.my/api/servicestatus
Query String : N/A
You can retrieve latest Rapid Rail Service Status via the API above without any query string.
Response : In JSON
1. Timestamp
Requested Time
2. IP_Address
Requested User IP Address
3. Status
API Status
{"status":"200"} / {"status":"503"}
200 if upstream (PULSE) operational
503 if upstream (PULSE) experiencing outage
4. Data
A JSON array contains 7 lines :
- MRT Putrajaya Line (PYL)
- MRT Kajang Line (KGL)
- KL Monorail Line (MRL)
- LRT Kelana Jaya Line (KJL)
- LRT Sri Petaling Line (SPL)
- LRT Ampang Line (AGL)
- KLIA Ekspres / Transit (ERL)
Example : {"LineID":"SPL","Line":"LRT Sri Petaling Line","Status":"Normal Service","Remark":""}
LineID : The route short name
Line : The route long name
Status : The service status of the current line
Remark : The remark of the service status of the current line
Make a GET request to https://api.mtrec.name.my/api/spottersstatus
Query String : N/A
You can retrieve latest Train Active Status via the API above without any query string.
Response : In JSON
1. Timestamp
Requested Time
2. IP_Address
Requested User IP Address
3. Status
API Status
{"status":200}
200 if our server is operational
4. Data
A JSON contains 5 lines :
- MRT Putrajaya Line (PYL)
- MRT Kajang Line (KGL)
- KL Monorail Line (MRL)
- LRT Kelana Jaya Line (KJL)
- LRT Ampang & Sri Petaling Line (AGSPL)
Example : {"Line":"MRL","Decommissioned":11,"Not Spotted":7,"In Service":6}
Line : The route name
Decommissioned : Trains that are not spotted in the past 365 days.
Not Spotted : Trains that are not spotted in the past 14 days.
In Service : Trains that are spotted within 14 days.
Data source : GTFS-R Transport API - OpenAPI by Malaysia Government
Make a GET request to https://api.mtrec.name.my/api/position
Frequency of Data Update :
Every 1 minute
Query String :
agency
You can retrieve latest Vehicle Position via the API above with query string agency :
Agency :
1. KTMB (Keretapi Tanah Melayu Berhad)https://api.mtrec.name.my/api/position?agency=ktmb
Response : In JSON
1. Timestamp
Requested Time
2. IP_Address
Requested User IP Address
3. Status
API Status
{"status":200}
200 if our server is operational
4. Message
Return the result of the API request
4. Data
A JSON contains several data of trains :
- Current location (Latitude and Longitude)
- Current bearing
- Current speed
- Current trip ID
*Credit to data.gov.my for the Vehicle Position API
Our API utilises rate limiting to limit network traffic on requesting API from our server within a certain timeframe to prevent malicious bot activity as well as reducing strain on our servers.
Details :
- Not more than 10 requests in 10 seconds per API endpoints.
- Equivalently as one requests per one second.
- HTTP 429 Too Many Requests and a JSON string contains your IP Address , Total Call Requests in 10 seconds will be returned if you exceed the rate limit.
- Rate limit will be reset each 10 seconds
- Redis will calculate the total request from your IP Address in 10 seconds and determine is your IP Address hit the limit
Our API service is only available to Malaysians and users who are residing in Malaysia using locally certified Internet Service Provider (ISP). If you are residing outside Malaysia, you are not allowed to use this service. MTREC does not bear the responsibilities and any consequences encountered by users outside Malaysia are at your own risk.