Getting started with the Ruter Public API

Ruter is a public transport operator in Norway. They provide a public API that developers can use to build applications that help users find their way around using public transport. This API is open to all developers, and you can get started with it by visiting the Ruter Public API documentation.

Getting the API key

Before you can start using the API, you need to obtain an API key. You can do this by visiting the Ruter API registration page. Once you have registered, you'll receive an email containing your API key.

Making a simple API request

To make a simple API request, you can use the following JavaScript code:

fetch('https://reisapi.ruter.no/Place/GetPlaces/?id=3010010')
  .then(response => response.json())
  .then(data => console.log(data));

In this example, we are requesting information about the location with ID 3010010. The fetch function is used to make the API request, and the response is parsed as JSON and logged to the console.

Retrieving real-time information

One of the features of the Ruter API is the ability to retrieve real-time information about public transport services. This information can be used to build applications that help users plan their journeys more effectively.

To retrieve real-time information about a specific stop, you can use the following code:

fetch('https://reisapi.ruter.no/StopVisit/GetDepartures/3010010?linenames=31')
  .then(response => response.json())
  .then(data => console.log(data));

In this example, we are requesting real-time information about the stop with ID 3010010, with a filter for buses with the line name 31.

Conclusion

The Ruter Public API is a powerful tool that developers can use to create applications that help users navigate public transport in Norway. By following the instructions in this guide, you can get started with the API and make your first API request.

Related APIs

Public APIs — A directory of free and public apis

Built by @mddanishyusuf