/trips-api

Trips API

Primary LanguagePythonMIT LicenseMIT

Trips API

A web API to make CRUD operations for a system that handles trips and passengers.

Built using









Installation

Source code

    pip install -r requirements.txt

Via Docker

    docker-compose up

Endpoints

Passenger

  • GET /api/passenger : Returns all passengers *
  • POST /api/passenger : Creates new passenger. Expects passenger object as json from request body.
  • GET /api/passenger/< id > : Returns single passenger with the specified id *
  • PUT /api/passenger/< id > : Updates the passenger with the specified id. Expects passenger object from body.
  • DELETE /api/passenger/< id > : Deletes the passenger with the specified id.



Trip

  • GET /api/trip : Returns all trips *
  • POST /api/trip : Creates new trip. Expects trip object as json from request body.
  • GET /api/trip/< id > : Returns single passenger with the specified id *
  • PUT /api/trip/< id > : Updates the trip with the specified id. Expects trip object from body.
  • DELETE /api/trip/< id > : Deletes the trip with the specified id.


[*] : GET endpoints can accept detailed=< true | false > query parameter. This parameter controls whether the bound objects will be returned or not with the query.

GET /api/passenger?detailed=true

will return passengers with their trip objects.

Similarly,

GET /api/trip?detailed=true

will return trips with their passenger objects.

Models

Passenger

firstName : CharField(50)
lastName : CharField(50)
email : EmailField
created : DateTimeField (internal)

Trip

passenger : ForeignKey
startTime : DateTimeField
endTime : DateTimeField
startLocation : CharField(100)
endLocation = CharField(100)
totalDistance = FloatField(10)