> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getswitch.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Transit Punctuality

> Punctuality of a transit network over a period, from its realtime stop events matched with the timetable. Returns the overall shares of early, on-time and late stop events with average and 90th-percentile delay, and the same figures by hour, line, stop and day. An event is on time inside `definition.on_time_window_seconds` (by default 1 minute early to 3 minutes late) and very late beyond `very_late_seconds`.

`coverage` lists the requested days without realtime data and the days with only partial data (caveat `partial_realtime_days`).

**Failure Modes:**
- **401**: Token is missing or invalid
- **403**: Insufficient permissions, transit analytics not enabled, or the location is not configured for it
- **422**: Invalid filters (dates in the wrong order, more than 31 days, `hour_from` after `hour_to`), or too much data: narrow the date range
- **502**: Transit data unavailable
- **503**: The timetable is unavailable

**Required Auth Scopes:**
- `copilot:analytics`



## OpenAPI

````yaml /api-reference/openapi.json get /copilot/analytics/transit/punctuality
openapi: 3.1.0
info:
  title: SWITCH API
  version: '1.0'
  description: >-
    The SWITCH API gives mobility and logistics teams programmatic access to
    SWITCH forecasts, fleet operations, routing and analytics. Every request is
    authenticated with an API key sent as a bearer token.
servers:
  - url: https://api.getswitch.io
    description: Production
security: []
tags:
  - name: Forecast
    description: Demand forecasts per zone and time window.
  - name: Operations
    description: Fleet imbalance, rebalancing suggestions and generated tasks.
  - name: Routing
    description: Route optimisation for single and multiple fleets.
  - name: Routing Sessions
    description: Saved routing sessions, their routes and drivers.
  - name: Routing Operations
    description: Complete, undo and re-route the stops of a route.
  - name: Fleet Management
    description: Your depots, stations, drivers and cargo vehicles.
  - name: Integrations
    description: Vehicles, statuses and commands on your fleet platform.
  - name: Station Based Analytics
    description: Analytics for station-based (docked) services.
  - name: Zone Based Analytics
    description: Analytics for free-floating services, by zone.
  - name: Free Float Analytics
    description: Trip history for free-floating services.
  - name: Transit Analytics
    description: Punctuality and service delivery for public transit.
  - name: Live
    description: Real-time fleet, delivery and transit status.
  - name: Grids
    description: Spatial grids used by forecasts and analytics.
  - name: API Keys
    description: Create and manage the API keys you call this API with.
paths:
  /copilot/analytics/transit/punctuality:
    get:
      tags:
        - Transit Analytics
      summary: Get Transit Punctuality
      description: >-
        Punctuality of a transit network over a period, from its realtime stop
        events matched with the timetable. Returns the overall shares of early,
        on-time and late stop events with average and 90th-percentile delay, and
        the same figures by hour, line, stop and day. An event is on time inside
        `definition.on_time_window_seconds` (by default 1 minute early to 3
        minutes late) and very late beyond `very_late_seconds`.


        `coverage` lists the requested days without realtime data and the days
        with only partial data (caveat `partial_realtime_days`).


        **Failure Modes:**

        - **401**: Token is missing or invalid

        - **403**: Insufficient permissions, transit analytics not enabled, or
        the location is not configured for it

        - **422**: Invalid filters (dates in the wrong order, more than 31 days,
        `hour_from` after `hour_to`), or too much data: narrow the date range

        - **502**: Transit data unavailable

        - **503**: The timetable is unavailable


        **Required Auth Scopes:**

        - `copilot:analytics`
      operationId: get_transit_punctuality
      parameters:
        - name: location
          in: query
          required: true
          schema:
            type: string
            minLength: 1
            description: >-
              Transit network location, e.g. `milan`: one of the locations
              configured for this transit analysis in your company.
            title: Location
          description: >-
            Transit network location, e.g. `milan`: one of the locations
            configured for this transit analysis in your company.
        - name: start_date
          in: query
          required: true
          schema:
            type: string
            format: date
            description: First service day, ISO 8601 date, e.g. `2026-10-01`.
            title: Start Date
          description: First service day, ISO 8601 date, e.g. `2026-10-01`.
        - name: end_date
          in: query
          required: true
          schema:
            type: string
            format: date
            description: >-
              Last service day, included (ISO 8601 date, e.g. `2026-10-31`). Not
              before `start_date`; at most 31 days in all.
            title: End Date
          description: >-
            Last service day, included (ISO 8601 date, e.g. `2026-10-31`). Not
            before `start_date`; at most 31 days in all.
        - name: lines
          in: query
          required: false
          schema:
            type: array
            items:
              type: string
            maxItems: 40
            description: >-
              Line names to keep, case-insensitive, e.g. `lines=1&lines=12`; a
              name covers every route that carries it. Combined with `route_ids`
              as a union. Empty = all lines.
            default: []
            title: Lines
          description: >-
            Line names to keep, case-insensitive, e.g. `lines=1&lines=12`; a
            name covers every route that carries it. Combined with `route_ids`
            as a union. Empty = all lines.
        - name: route_ids
          in: query
          required: false
          schema:
            type: array
            items:
              type: string
            maxItems: 40
            description: >-
              Exact GTFS `route_id`s to keep, e.g. `route_ids=R90`. Combined
              with `lines` as a union. Empty = all lines.
            default: []
            title: Route Ids
          description: >-
            Exact GTFS `route_id`s to keep, e.g. `route_ids=R90`. Combined with
            `lines` as a union. Empty = all lines.
        - name: direction
          in: query
          required: false
          schema:
            type:
              - integer
              - 'null'
            maximum: 1
            minimum: 0
            description: GTFS `direction_id` to keep (0 or 1). Omit for both.
            title: Direction
          description: GTFS `direction_id` to keep (0 or 1). Omit for both.
        - name: hour_from
          in: query
          required: false
          schema:
            type: integer
            maximum: 23
            minimum: 0
            description: >-
              First hour of the day to include (0-23, local time of the
              network), by scheduled time.
            default: 0
            title: Hour From
          description: >-
            First hour of the day to include (0-23, local time of the network),
            by scheduled time.
        - name: hour_to
          in: query
          required: false
          schema:
            type: integer
            maximum: 23
            minimum: 0
            description: >-
              Last hour of the day to include (0-23, local time), not before
              `hour_from`.
            default: 23
            title: Hour To
          description: >-
            Last hour of the day to include (0-23, local time), not before
            `hour_from`.
        - name: day_type
          in: query
          required: false
          schema:
            enum:
              - all
              - weekday
              - saturday
              - sunday
            type: string
            description: >-
              Days to keep: `all`, `weekday` (Monday to Friday), `saturday` or
              `sunday`.
            default: all
            title: Day Type
          description: >-
            Days to keep: `all`, `weekday` (Monday to Friday), `saturday` or
            `sunday`.
      responses:
        '200':
          description: Punctuality computed. Summary, breakdowns and coverage.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PunctualityResult'
        '401':
          description: Unauthorized. Token is missing or invalid.
        '403':
          description: Forbidden. Transit analysis not enabled for location.
        '422':
          description: Unprocessable Entity. Validation failed.
        '502':
          description: Bad Gateway. Transit data unavailable.
        '503':
          description: Service Unavailable. Transit schedule unavailable.
      security:
        - HTTPBearer: []
        - HTTPBearer: []
components:
  schemas:
    PunctualityResult:
      properties:
        summary:
          $ref: '#/components/schemas/PunctualitySummary'
        by_hour:
          items:
            $ref: '#/components/schemas/PunctualityGroup'
          type: array
          title: By Hour
        by_line:
          items:
            $ref: '#/components/schemas/PunctualityGroup'
          type: array
          title: By Line
        by_stop:
          items:
            $ref: '#/components/schemas/PunctualityGroup'
          type: array
          title: By Stop
        by_day:
          items:
            $ref: '#/components/schemas/PunctualityGroup'
          type: array
          title: By Day
        coverage:
          $ref: '#/components/schemas/Coverage'
        definition:
          $ref: '#/components/schemas/Definition'
        caveats:
          items:
            type: string
          type: array
          title: Caveats
          default: []
      type: object
      required:
        - summary
        - by_hour
        - by_line
        - by_stop
        - by_day
        - coverage
        - definition
      title: PunctualityResult
      description: >-
        Stop-event punctuality.


        ``partial_realtime_days`` caveat: some days in ``coverage.partial_days``

        have realtime data for only part of the timetable, so their figures
        cover

        only the observed hours.
      examples:
        - by_day:
            - average_delay_seconds: 92
              early_pct: 4
              events: 43120
              key: '2026-10-01'
              label: '2026-10-01'
              late_3_10_pct: 14.6
              on_time_pct: 79
              p90_delay_seconds: 301
              very_late_pct: 2.4
            - average_delay_seconds: 99
              early_pct: 4.3
              events: 42870
              key: '2026-10-02'
              label: '2026-10-02'
              late_3_10_pct: 15.9
              on_time_pct: 77.4
              p90_delay_seconds: 318
              very_late_pct: 2.4
          by_hour:
            - average_delay_seconds: 142
              early_pct: 3
              events: 98210
              key: '8'
              label: '8'
              late_3_10_pct: 22.1
              on_time_pct: 71.2
              p90_delay_seconds: 420
              very_late_pct: 3.7
            - average_delay_seconds: 71
              early_pct: 4.6
              events: 87455
              key: '13'
              label: '13'
              late_3_10_pct: 11.4
              on_time_pct: 82.5
              p90_delay_seconds: 255
              very_late_pct: 1.5
          by_line:
            - average_delay_seconds: 151
              early_pct: 2.9
              events: 142380
              key: R90
              label: '90'
              late_3_10_pct: 23
              on_time_pct: 69.8
              p90_delay_seconds: 446
              very_late_pct: 4.3
            - average_delay_seconds: 58
              early_pct: 5.2
              events: 61220
              key: R73
              label: '73'
              late_3_10_pct: 9.6
              on_time_pct: 84.1
              p90_delay_seconds: 221
              very_late_pct: 1.1
          by_stop:
            - average_delay_seconds: 172
              early_pct: 1.8
              events: 8410
              key: S1123
              label: Piazzale Lodi
              late_3_10_pct: 26.4
              latitude: 45.4469
              longitude: 9.2101
              on_time_pct: 66.3
              p90_delay_seconds: 498
              very_late_pct: 5.5
          caveats:
            - partial_realtime_days
          coverage:
            days_requested: 31
            days_with_data: 30
            days_without_data:
              - '2026-10-12'
            first_available_date: '2026-06-02'
            partial_days:
              - '2026-10-20'
            saturdays_with_data: 5
            sundays_with_data: 4
            weekdays_with_data: 21
          definition:
            on_time_window_seconds:
              - -60
              - 180
            very_late_seconds: 600
          summary:
            average_delay_seconds: 96
            early_events: 52665
            early_pct: 4.1
            events: 1284500
            late_events: 184967
            late_pct: 17.3
            matched_pct: 93.4
            on_time_events: 1009617
            on_time_pct: 78.6
            p90_delay_seconds: 312
            unmatched_events: 90733
            very_late_events: 37251
    PunctualitySummary:
      properties:
        events:
          type: integer
          title: Events
        matched_pct:
          type:
            - number
            - 'null'
          title: Matched Pct
        on_time_pct:
          type:
            - number
            - 'null'
          title: On Time Pct
        early_pct:
          type:
            - number
            - 'null'
          title: Early Pct
        late_pct:
          type:
            - number
            - 'null'
          title: Late Pct
        average_delay_seconds:
          type:
            - integer
            - 'null'
          title: Average Delay Seconds
        p90_delay_seconds:
          type:
            - integer
            - 'null'
          title: P90 Delay Seconds
        early_events:
          type: integer
          title: Early Events
          default: 0
        on_time_events:
          type: integer
          title: On Time Events
          default: 0
        late_events:
          type: integer
          title: Late Events
          default: 0
        very_late_events:
          type: integer
          title: Very Late Events
          default: 0
        unmatched_events:
          type: integer
          title: Unmatched Events
          default: 0
      type: object
      required:
        - events
        - matched_pct
        - on_time_pct
        - early_pct
        - late_pct
        - average_delay_seconds
        - p90_delay_seconds
      title: PunctualitySummary
    PunctualityGroup:
      properties:
        key:
          type: string
          title: Key
        label:
          type: string
          title: Label
        events:
          type: integer
          title: Events
        on_time_pct:
          type:
            - number
            - 'null'
          title: On Time Pct
        early_pct:
          type:
            - number
            - 'null'
          title: Early Pct
        late_3_10_pct:
          type:
            - number
            - 'null'
          title: Late 3 10 Pct
        very_late_pct:
          type:
            - number
            - 'null'
          title: Very Late Pct
        average_delay_seconds:
          type:
            - integer
            - 'null'
          title: Average Delay Seconds
        p90_delay_seconds:
          type:
            - integer
            - 'null'
          title: P90 Delay Seconds
        latitude:
          type:
            - number
            - 'null'
          title: Latitude
        longitude:
          type:
            - number
            - 'null'
          title: Longitude
      type: object
      required:
        - key
        - label
        - events
        - on_time_pct
        - average_delay_seconds
        - p90_delay_seconds
      title: PunctualityGroup
    Coverage:
      properties:
        first_available_date:
          type:
            - string
            - 'null'
          format: date
          title: First Available Date
        days_without_data:
          items:
            type: string
            format: date
          type: array
          title: Days Without Data
        partial_days:
          items:
            type: string
            format: date
          type: array
          title: Partial Days
          default: []
        days_requested:
          type: integer
          title: Days Requested
          default: 0
        days_with_data:
          type: integer
          title: Days With Data
          default: 0
        weekdays_with_data:
          type: integer
          title: Weekdays With Data
          default: 0
        saturdays_with_data:
          type: integer
          title: Saturdays With Data
          default: 0
        sundays_with_data:
          type: integer
          title: Sundays With Data
          default: 0
      type: object
      required:
        - first_available_date
        - days_without_data
      title: Coverage
      description: >-
        Requested days vs days with realtime data.


        ``partial_days`` are days with data whose realtime feed covers only part

        of the timetable (see ``_partial_days``); they are also days with data.

        The trip-share part of that rule is relative to the requested range: it

        compares each day with the median day of the same request, so a range
        made

        only of equally thin days is not flagged by it.
    Definition:
      properties:
        on_time_window_seconds:
          prefixItems:
            - type: integer
            - type: integer
          type: array
          maxItems: 2
          minItems: 2
          title: On Time Window Seconds
        very_late_seconds:
          type: integer
          title: Very Late Seconds
          default: 600
      type: object
      required:
        - on_time_window_seconds
      title: Definition
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer
      description: >-
        An API key, sent as `Authorization: Bearer <key>`. Create one in the
        SWITCH Copilot under **Settings → API keys** (needs the API keys
        permission in your company), or with `POST /auth/api-keys`. The key is
        shown once, at creation.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.