Skip to content

RESTful API

isabelle-dr edited this page Jan 3, 2022 · 1 revision

Introduction

The web client of the gtfs-realtime-validator uses a web service. A series of calls to an REST API made to start and monitor the feeds.

HTTP Request

All calls are made to the endpoint at localhost:8080/api/.
The request body should contain the parameters required in the JSON format.

The required parameters for each request is given in the Rest-API.

Response

Responses will be in the JSON format. The response would differ from the resource that is being accessed. This can be viwed in detail in the Rest-API

Errors

The API uses standard HTTP error codes to present errors.

Response Code Status
2xx These codes indicate success. The body section if present is the object returned by the request. The body will contain the associated json data for the request
4xx Error caused by the client. (ex - Invalid parameters)
5xx Server side error. In which the server is aware of the error

REST API

###/gtfs ####GET

Option Description
Title Get all GTFS feeds in the database.
URL http://localhost:8080/api/gtfs
URL Params *Required:* `id=[integer]` (example: id=12)

Optional:
id=[integer]
(example: id=12)

Data Params
{ "u" : 
    {   'email' : "string",
        name : [string], 
        current_password : [alphanumeric] 
        password : [alphanumeric], 
        password_confirmation : [alphanumeric] 
    } 
}
Response **Code:** 200
**Content:**
{ "u" : 
    {   'email' : "string",
        name : [string], 
        current_password : [alphanumeric] 
        password : [alphanumeric], 
        password_confirmation : [alphanumeric] 
    } 
}

####POST ####PUT ####DELETE

###/gtfs-rt ###/gtfs ####GET ####POST ####PUT ####DELETE

Quick Start: Basic RESTful calls

In order to monitor a feed the following methods must be invocated in order

  1. POST /gtfs This method will download the GTFS feed to the server and return an gtfs-feed object. This object will contain an ID for the given feed. This will be used later when starting to monitor the GTFS-Realtime Feed.

  2. POST /gtfs-rt An URL of a real-time feed is sent to the server. This is added to the database and the corresponding ID is returned. You must associate an GTFS id with any real-time feed this can be gotten from the previous step.

  3. GET /gtfs-rt/{id}/monitor Once the rt feed is added, we trigger the monitor action(a background task) for the given feed Id. This will monitor for any errors and logs them in the database.

  4. GET /gtfs-rt/{id} If the monitoring has started, a call to this resource will return the errors and warnings of the feed.

Clone this wiki locally