Transport for Manchester, England

Transportation

Using TFGM's Public API with JavaScript

If you are looking to build applications that contain information related to transport in the Greater Manchester area, the TFGM API can be a great resource to get started. In this article, we will show you how to use this API with JavaScript.

Getting Started

Before you can start using the TFGM API, you first need to sign up to create an account. Once you have registered and verified your account, you will receive an API key that you can use to access the various endpoints.

Endpoints

The TFGM API has several endpoints that you can use to retrieve information about transport in Greater Manchester. Below are some examples of how you can use these endpoints with JavaScript.

Bus Schedules

fetch('https://api.tfgm.com/odata/busstopschedules')
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error(error));

Train Schedules

fetch('https://api.tfgm.com/odata/trainschedules')
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error(error));

Tram Schedules

fetch('https://api.tfgm.com/odata/tramschedules')
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error(error));

Car Parks

fetch('https://api.tfgm.com/odata/carparks')
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error(error));

Travel Alerts

fetch('https://api.tfgm.com/odata/travelalerts')
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error(error));

Conclusion

In this article, we have demonstrated how to use TFGM's Public API with JavaScript. By using these endpoints, you can build applications that provide in-depth information related to transport in Greater Manchester. Get creative and build something amazing!

Related APIs