> For the complete documentation index, see [llms.txt](https://docs.sportmonks.com/v3/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sportmonks.com/v3/motorsport-api/tutorials-and-guides/tutorials/enrich-your-response/how-to-fetch-pit-stop-data-for-a-race.md).

# How to Fetch Pit Stop Data for a Race

> **✅ Included in All Plans**
>
> The pitstops endpoints are included at no additional cost.
>
> Plans differ only in leagues and API call limits.
>
> [Compare plans →](https://www.sportmonks.com/football-api/plans-pricing/)

This guide shows you how to retrieve pit stop data for a race - all stops across the full field, per-driver filtering, lap-level querying, and pit duration breakdown using the `details` include.

### When to use this

Use the pitstops endpoints when you want to:

* Display a pit stop timeline showing when each driver stopped
* Analyse team pit stop performance by stop duration
* Correlate pit stops with position changes during a race
* Build a strategy tracker showing each driver's stop sequence

### The pitstops endpoints

| Endpoint                                  | URL pattern                                   | Use case                                    |
| ----------------------------------------- | --------------------------------------------- | ------------------------------------------- |
| GET Pitstops by Fixture ID                | `/fixtures/{id}/pitstops`                     | All pit stops for every driver in the race  |
| GET Pitstops by Fixture ID and Driver ID  | `/fixtures/{id}/pitstops/drivers/{driver_id}` | All pit stops for one specific driver       |
| GET Latest Pitstops by Fixture ID         | `/fixtures/{id}/pitstops/latest`              | Most recent pit stop entries (live polling) |
| GET Pitstops by Fixture ID and Lap Number | `/fixtures/{id}/pitstops/{lap_number}`        | All pit stops that occurred on a given lap  |

None of these endpoints paginate - the full result set returns in one response.

### Base response fields

```json
{
  "data": [
    {
      "id": 77,
      "fixture_id": 19402069,
      "lap_number": 12,
      "driver_number": 6,
      "participant_id": 37920812,
      "is_latest": false
    },
    {
      "id": 78,
      "fixture_id": 19402069,
      "lap_number": 20,
      "driver_number": 27,
      "participant_id": 37920818,
      "is_latest": true
    }
  ]
}
```

`lap_number` is the lap on which the driver entered the pit lane. `participant_id` is the driver's ID - the same value as `player_id` in lineups and `participant_id` in standings responses. `driver_number` is the car number.

### Adding pit duration with the `details` include

The base response tells you when a stop happened but not how long it took. The `details` include adds timing data:

```
GET https://api.sportmonks.com/v3/motorsport/fixtures/19408487/pitstops
?api_token={your_token}&include=details
```

From the [Results and Live Data Type Reference](https://docs.sportmonks.com/v3/motorsport-api/welcome/results-and-live-data-type-reference), the pitstop detail types are:

| type\_id | Name          | Value                                               |
| -------- | ------------- | --------------------------------------------------- |
| `9727`   | Pit Timestamp | Unix timestamp when the driver entered the pit lane |
| `9728`   | Pit Duration  | Time spent in the pit lane in seconds               |

### Working with the data

#### Fetch all pit stops for a race

```javascript
const API_TOKEN = 'your_token';
const FIXTURE_ID = 19408487;

const response = await fetch(
  `https://api.sportmonks.com/v3/motorsport/fixtures/${FIXTURE_ID}/pitstops
?api_token=${API_TOKEN}&include=details`
);
const { data: pitstops } = await response.json();

function getDetail(details, typeId) {
  return details?.find(d => d.type_id === typeId)?.data ?? null;
}

const parsed = pitstops.map(stop => ({
  driverNumber: stop.driver_number,
  participantId: stop.participant_id,
  lapNumber: stop.lap_number,
  duration: getDetail(stop.details, 9728),
  timestamp: getDetail(stop.details, 9727)
}));

// Sort by lap number to get chronological stop order
parsed.sort((a, b) => a.lapNumber - b.lapNumber);
```

#### Fetch stops for a single driver

```javascript
const DRIVER_ID = 37920800;

const response = await fetch(
  `https://api.sportmonks.com/v3/motorsport/fixtures/${FIXTURE_ID}/pitstops/drivers/${DRIVER_ID}
?api_token=${API_TOKEN}&include=details`
);
const { data: driverStops } = await response.json();

console.log(`Driver made ${driverStops.length} stop(s)`);
driverStops.forEach(stop => {
  const duration = getDetail(stop.details, 9728);
  console.log(`Stop on lap ${stop.lap_number}: ${duration?.value ?? 'N/A'}s`);
});
```

#### Fetch all stops on a specific lap

```javascript
const LAP_NUMBER = 25;

const response = await fetch(
  `https://api.sportmonks.com/v3/motorsport/fixtures/${FIXTURE_ID}/pitstops/${LAP_NUMBER}
?api_token=${API_TOKEN}&include=details`
);
const { data: lapStops } = await response.json();

console.log(`${lapStops.length} driver(s) pitted on lap ${LAP_NUMBER}`);
```

This is useful for identifying undercut or overcut windows - when multiple drivers stop on the same lap or within one or two laps of each other.

#### Poll latest pit stops during a live race

```javascript
async function pollLatestPitstops(fixtureId, token) {
  const response = await fetch(
    `https://api.sportmonks.com/v3/motorsport/fixtures/${fixtureId}/pitstops/latest
?api_token=${token}`
  );
  const { data } = await response.json();
  return data;
}

setInterval(async () => {
  const latest = await pollLatestPitstops(FIXTURE_ID, API_TOKEN);
  // Check for new stops and update your strategy display
}, 15000);
```

### Common pitfalls

**`lap_number` is when the driver entered the pit lane, not when they exited.** The stop duration in `details` tells you how long the stop lasted. If you want to know which lap the driver rejoined on, add the duration to the lap timestamp.

**`participant_id` is the driver ID, not the team ID.** Cross-reference with the driver entity or lineups to display driver names. `driver_number` is the car number only.

**`details` can be absent for stops logged without timing.** Not every pit stop entry includes timing data, particularly for stops logged during safety car periods or for mechanical issues. Always handle `null` from `getDetail()`.

**`GET Latest Pitstops` returns the most recent stop entries across all drivers, not a per-driver latest.** During a live race this may return several entries if multiple drivers stopped on the same or consecutive laps.

**The pitstops endpoint covers all session types.** If you pass a practice fixture ID, you'll get pit lane entries from that practice session. Make sure you're passing the race fixture ID for race data.

### Advanced usage

To build a pit stop comparison table sorted by stop duration, fetch all stops with `?include=details`, extract `pit-duration` from each, and sort ascending. Highlight outliers (stops more than 1 second above the median) as indicators of potential issues.

To identify safety car windows, look for laps where 3 or more drivers stopped - these cluster around virtual or physical safety car deployments when teams bring cars in to minimise time loss.

### Common errors

| Status | Likely cause                                   |
| ------ | ---------------------------------------------- |
| `401`  | Missing or invalid `api_token`                 |
| `404`  | The `fixture_id` or `driver_id` does not exist |
| `422`  | Query complexity exceeded - remove includes    |

### See also

**Pitstops endpoints**

* [GET Pitstops by Fixture ID](https://docs.sportmonks.com/v3/motorsport-api/endpoints-and-entities/endpoints/pitstops/get-pitstops-by-fixture-id.md)
* [GET Pitstops by Fixture ID and Driver ID](https://docs.sportmonks.com/v3/motorsport-api/endpoints-and-entities/endpoints/pitstops/get-pitstops-by-fixture-id-and-driver-id.md)
* [GET Latest Pitstops by Fixture ID](https://docs.sportmonks.com/v3/motorsport-api/endpoints-and-entities/endpoints/pitstops/get-latest-pitstops-by-fixture-id.md)
* [GET Pitstops by Fixture ID and Lap Number](https://docs.sportmonks.com/v3/motorsport-api/endpoints-and-entities/endpoints/pitstops/get-pitstops-by-fixture-id-and-lap-number.md)

**Type references**

* [Results and Live Data Type Reference](https://docs.sportmonks.com/v3/motorsport-api/welcome/results-and-live-data-type-reference)

**Related entities**

* [Pitstop](https://docs.sportmonks.com/v3/motorsport-api/endpoints-and-entities/entities/pitstop.md)
* [Fixture](https://docs.sportmonks.com/v3/motorsport-api/endpoints-and-entities/entities/fixture.md)

**Related guides**

* [How to Track Lap-by-Lap Timing for a Race](https://docs.sportmonks.com/v3/motorsport-api/tutorials-and-guides/guides/how-to-track-lap-by-lap-timing-for-a-race.md)
* [How to Track Tyre Stints](https://docs.sportmonks.com/v3/motorsport-api/tutorials-and-guides/guides/how-to-track-tyre-stints.md)

### FAQ

**Do I need to paginate the pitstops endpoints?** No. All pitstops endpoints return the full result set in a single response.

**Can I see pit stop data during a live race?** Yes. Use `GET Latest Pitstops by Fixture ID` during a live session. The base `GET Pitstops by Fixture ID` endpoint also updates in real time as new stops are logged.

**Is pit duration available for all seasons?** Pit duration data availability varies. Check the [Results and Live Data Type Reference](https://docs.sportmonks.com/v3/motorsport-api/welcome/results-and-live-data-type-reference) for season availability notes on specific type IDs.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.sportmonks.com/v3/motorsport-api/tutorials-and-guides/tutorials/enrich-your-response/how-to-fetch-pit-stop-data-for-a-race.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
