NAV Navbar
  • Introduction
  • Project Description
  • Trips
  • Stats
  • Introduction

    1. Your task is to implement an API based on this documentation.
    2. The API can be written in any framework you feel most comfortable with.
    3. Take your time and write the best code you can.
    4. Provide the solution with complete Git commits history.

    Things we care about

    1. Code maintainability.

    Project Description

    Imagine you are a bike courier and you want to build a system that will help you track your rides during delivery of packages: how many kilometers did you ride on each day and how much did customer pay for delivery. The app will help you to control your work. The codename for the app is: "Bikeramp" :)

    Trips

    Create Trip

    This endpoint logs the trip and automatically calculates the distance between start and destination addresses.

    HTTP Request

    POST http://example.com/api/trips

    Query Parameters

    Parameter Description
    start_address Start address in format: "Plac Europejski 2, Warszawa, Polska"
    destination_address Destination address in format: "Plac Europejski 2, Warszawa, Polska"
    price Package price in PLN
    date Date of delivery

    Stats

    Get Weekly Stats

    curl "http://example.com/api/stats/weekly"
    

    The above command returns JSON structured like this:

    {
      "total_distance": "40km",
      "total_price":    "49.75PLN"
    }
    

    This endpoint retrieves how many kilometers did courier rode during current week and how much money he received on the rides.

    HTTP Request

    GET http://example.com/api/stats/weekly

    Get Monthly Stats

    curl "http://example.com/api/stats/monthly"
    

    The above command returns JSON structured like this:

    [
      {
        "day":            "July, 4th",
        "total_distance": "12km",
        "avg_ride":       "4km",
        "avg_price":      "22.75PLN"
      },
      {
        "day":            "July, 5th",
        "total_distance": "3km",
        "avg_ride":       "3km",
        "avg_price":      "15.5PLN"
      }
    ]
    

    This endpoint retrieves summary of ride distances from current month, grouped by day. The summary should include sum of all rides distances from given day, average ride distance and average price for the ride.

    HTTP Request

    GET http://example.com/api/stats/monthly