# API spec for communicating between the frontend and the backend

## List of routes
- `/trips/`
- `/trips/{id}`
- `/stops/{id}`
- `/path?start_lat={latitude}&start_lon={longitude}&end_lat={latitude}&end_lon={longitude}&time={unix_epoch}`


## `/trips`
being a json list of urls to each of all the trips over the course of the week, probably won't be used for core functionality but it'll be trivial to implement so might as well

## `/trips/{id}`
json object describing a route, I'm planning on this having an infinite cache time, if a route changes a new id will be made for the route after the change
```yaml
{
  "_links":{
    "self":{
      "href":"https://$base_domain/trips/{id}"
    },
    # stops in order of when the bus reaches them
    "stops": [{
        "href":"https://$base_domain/stops/{id}",
        "latitude":{latitude},
        "longitude":{longitude},
          "times":[
            {"dotw": "Mo, Tu, We, Th, Fr, Sa or Su", "time": "HH:MM"},
          ]
        },
        ...
    ]
  },
  "name": "name of the route",
  "abbr": "shortened name of the route or null",
  "polyline": "whatever the route's polyline is",
}
```

## `GET /stops`

```yaml
[
  {
    "name": {name},
    "longitude": {longitude},
    "latitude": {latitude},
    # "provider": {occt|bc},
    "routeID":
  }
]

## `/stops/{id}`

```yaml
{
  "_links":{
    "self":{
      "href":"https://$base_domain/stops/{id}"
    },
    # trips that make use of the stop in arbitrary order
    "trips": [
      {
        "href":"https://$base_domain/trips/{id}",
      }
    ]
  }
  "latitude": {latitude},
  "longitude": {longitude}
}
```

`/path?start_lat={latitude}&start_lon={longitude}&end_lat={latitude}&end_lon={longitude}&time={unix_epoch}`
```yaml
{
  "_links":{
    "self":{
      "href": "https://$base_domain/path?start_lat={latitude}&start_lon={longitude}&end_lat={latitude}&end_lon={longitude}&time={unix_epoch}"
    }
    "path":[
      {
        "trip":{
            "href":"https://$base_domain/trips/{id}",
            "polyline": "{polyline}"
        },
        "enter_bus":{
            "href":"https://$base_domain/stops/{id}",
            "latitude": # {latitude},
            "longitude": # {longitude},
            "time": "same format as above",
        },
        "exit_bus":{
            "href":"https://$base_domain/stops/{id}",
            "latitude": # {latitude},
            "longitude": # {longitude},
            "time": "same format as above",
        },
      }
    ]
  },
}
```
