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
Response
Returns a success response with an array of driver objects, each including their team name and total points calculated from all race results.
Indicates whether the request was successful
A descriptive message about the operation result
Array of driver objects sorted by total points in descending order Unique identifier for the driver
Three-letter driver code (e.g., “VER”, “HAM”)
Driver’s permanent racing number
Driver’s date of birth in ISO 8601 format
URL to driver’s profile or additional information
URL to the driver’s image
ID of the team the driver belongs to
Name of the team the driver belongs to
Array of race result objects for the driver Points earned in a specific race
Total championship points calculated from all race results. This is computed by summing all points from the Results array.
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
}
]
}