data-api-docs

PAJ Data API Documentation

Paj banner

Overview

The documentation to assist you with on how to use PAJ Data API to intergrate it with you apps.

Perbadanan Pengangkutan Awam Johor provides an open API service to any third parties whose need it. These data can be used as tools such as data analysis, creating reporting and understanding vehicle workflow.

Most of available open API provided is related to Bas Muafakat Johor (BMJ) which is bus services working directly under Perbadanan Pengangkutan Awam Johor.

Contact

If you have any questions regarding our guides or suggestion, please contact PAJ Support at official@paj.com.my.

Available API

Below are available API options that available by public users

Get Your API Key

You can get your key from https://dataapi.paj.com.my. A valid account are needed to get the key.

Using API Key

  1. Get your API Key here

  2. To get the response, you will need to pass ‘api-key’ header with the given key. Same key can be use to make consicutive request from the server.

Request example using Python:

import requests

api_key = 'YOUR_API_KEY'
headers = {'api-key': api_key}
response = requests.get('https://dataapi.paj.com.my/api/v1/route/name/P101', headers=headers)
if response.status_code == 200:
    print(response.json())
else:
    print('Error:', response.status_code)

Example of success response:

{
    "status": "success",
    "data": [
        {
            "name": "P101",
            "bus_vendor_id": 1,
            "distance": 21.5,
            "special_Line": 0,
            "total_trip": 33,
            "active": 1
        }
    ]
}

Example of error response:

{
    "status": "error",
    "message": "Invalid API Key"
}

Rate Limit

Error Message

In case you get an error message, below is description why it is happening

Error Message Description
API Key Required No header with ‘api-key’ detected
Invalid API Key There is no such api-key exist in data api database
Invalid parameter or endpoint Make sure that your url endpoint is correct or make sure that url parameter is correct
Rate limit reach Reach 1 minute request call. You will need to wait another 1 minute for a cooldown

Empty Valid Response

In the case of zero data available for particular reponse. The system will simply reply with an empty array like example below

{
    "status": "success",
    "data": []
}

Acknowledgement

   
Thanks for support from Perbadanan Pengangkutan Awam Johor for making this public API possible

License

The patches published as part of the PAJ Data API are released under GNU GPL v3.