Skip to main content

Endpoint

method
string
default:"GET"
GET
path
string
/api/results

Description

Retrieves all race results from the database. Each result contains information about a driver’s position and points earned in a specific race.

Request

This endpoint does not require any parameters or request body.

Headers

No authentication or special headers required.

Response

data
array
Array of result objects

Success response

{
  "data": [
    {
      "resultId": 1,
      "raceId": 1100,
      "driverId": "max_verstappen",
      "position": 1,
      "points": 25
    },
    {
      "resultId": 2,
      "raceId": 1100,
      "driverId": "perez",
      "position": 2,
      "points": 18
    },
    {
      "resultId": 3,
      "raceId": 1100,
      "driverId": "hamilton",
      "position": 3,
      "points": 15
    }
  ]
}

Example request

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

Error responses

500 Internal Server Error

Returned when there is a database connection error or unexpected server issue.
{
  "statusCode": 500,
  "statusMessage": "Internal Server Error"
}

Implementation details

  • Built with Nitro.js event handler
  • Uses Prisma ORM to query the PostgreSQL database
  • Returns all results without pagination
  • No filtering or sorting applied by default
  • Relations to Drivers and Races tables are available in the database schema but not populated in the response

Database schema

The Results table has the following structure:
  • resultId: Primary key (auto-increment)
  • raceId: Foreign key to Races table (nullable)
  • driverId: Foreign key to Drivers table (nullable, VARCHAR 50)
  • position: Integer (required)
  • points: Integer (required)

Build docs developers (and LLMs) love