Transport for India

Transportation

Exploring Transport API on data.gov.in

data.gov.in provides a variety of APIs to access various public datasets. In this blog, we will explore the Transport API and learn how to use it to retrieve transport-related information.

Transport API

Transport API provides access to information related to transport in India. This includes data related to road transport, rail transport, air transport, and water transport. This API can be used to retrieve information such as vehicle registration details, train schedules, flight schedules, etc.

Getting Started

To get started using the Transport API, we need to first obtain an API key. The API key can be obtained by registering at https://api.data.gov.in/signup/. Once the API key is obtained, we can start using the API.

Let's consider an example of how to use the Transport API to retrieve vehicle registration details.

Retrieving Vehicle Registration Details

To retrieve vehicle registration details using the Transport API, we can send a GET request to the following endpoint:

https://api.data.gov.in/resource/416cce7b-9a1c-4c31-8622-221daeef640e?api-key=<api_key>&format=json&filters[registrationno]=<registration_number>

Here, <api_key> should be replaced with the actual API key obtained from the data.gov.in website. <registration_number> should be replaced with the actual vehicle registration number.

Here's how we can achieve this in JavaScript:

const api_key = '<api_key>';
const registration_number = '<registration_number>';
const endpoint = `https://api.data.gov.in/resource/416cce7b-9a1c-4c31-8622-221daeef640e?api-key=${api_key}&format=json&filters[registrationno]=${registration_number}`;

fetch(endpoint)
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

In the above code, we first define the api_key and registration_number variables. We then construct the endpoint by replacing the placeholders with actual values. We then use the fetch function to send a GET request to the endpoint. The response is then processed as JSON data.

Conclusion

In this blog, we learned how to use the Transport API provided by data.gov.in to retrieve vehicle registration details. Similar techniques can be applied to retrieve other transport-related information.

Related APIs in Transportation