Skip to main content
Retrieves a list of all Formula 1 drivers including their associated team and calculated total points from all race results. The response is automatically sorted by total points in descending order.

Endpoint

GET /api/drivers

Response

Returns a success response with an array of driver objects, each including their team name and total points calculated from all race results.
success
boolean
required
Indicates whether the request was successful
message
string
required
A descriptive message about the operation result
data
array
required
Array of driver objects sorted by total points in descending order

Points calculation logic

The totalPoints field is calculated using the following logic:
driver.Results.reduce((sum, result) => sum + (result.points || 0), 0)
This sums all points from each race result, treating null or undefined values as 0.

Example request

curl -X GET https://api.example.com/api/drivers

Example response

{
  "success": true,
  "message": "Successfully fetched drivers with total points and sorted by total points",
  "data": [
    {
      "driverId": "max_verstappen",
      "code": "VER",
      "permanentNumber": 1,
      "givenName": "Max",
      "familyName": "Verstappen",
      "dateOfBirth": "1997-09-30T00:00:00.000Z",
      "nationality": "Dutch",
      "url": "http://en.wikipedia.org/wiki/Max_Verstappen",
      "driverImage": "https://example.com/images/verstappen.jpg",
      "teamId": "red_bull",
      "team": "Red Bull Racing",
      "Teams": {
        "name": "Red Bull Racing"
      },
      "Results": [
        { "points": 25 },
        { "points": 18 },
        { "points": 25 }
      ],
      "totalPoints": 68
    },
    {
      "driverId": "lewis_hamilton",
      "code": "HAM",
      "permanentNumber": 44,
      "givenName": "Lewis",
      "familyName": "Hamilton",
      "dateOfBirth": "1985-01-07T00:00:00.000Z",
      "nationality": "British",
      "url": "http://en.wikipedia.org/wiki/Lewis_Hamilton",
      "driverImage": "https://example.com/images/hamilton.jpg",
      "teamId": "mercedes",
      "team": "Mercedes",
      "Teams": {
        "name": "Mercedes"
      },
      "Results": [
        { "points": 18 },
        { "points": 15 },
        { "points": 12 }
      ],
      "totalPoints": 45
    }
  ]
}

Build docs developers (and LLMs) love