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

# Get Transit Line Details

> One line of the transit network, from its timetable: names and colour, and for each direction its headsign, ordered stops and route shapes (GeoJSON). Use it to draw a line from the punctuality or service delivery results.

**Failure Modes:**
- **401**: Token is missing or invalid
- **403**: Insufficient permissions, service delivery analytics not enabled, or the location is not configured for it
- **404**: No line with this `route_id` in the timetable
- **422**: Invalid `route_id` or `location`
- **503**: The timetable is unavailable

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



## OpenAPI

````yaml /api-reference/openapi.json get /copilot/analytics/transit/lines/{route_id}
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://stage-api.getswitch.io
    description: Stage
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/lines/{route_id}:
    get:
      tags:
        - Transit Analytics
      summary: Get Transit Line Details
      description: >-
        One line of the transit network, from its timetable: names and colour,
        and for each direction its headsign, ordered stops and route shapes
        (GeoJSON). Use it to draw a line from the punctuality or service
        delivery results.


        **Failure Modes:**

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

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

        - **404**: No line with this `route_id` in the timetable

        - **422**: Invalid `route_id` or `location`

        - **503**: The timetable is unavailable


        **Required Auth Scopes:**

        - `copilot:analytics`
      operationId: get_transit_analytics_line
      parameters:
        - name: route_id
          in: path
          required: true
          schema:
            type: string
            minLength: 1
            maxLength: 64
            description: >-
              GTFS `route_id` of the line, as in `by_line[].key` of punctuality
              or `by_line[].route_id` of service delivery, e.g. `R90`.
            title: Route Id
          description: >-
            GTFS `route_id` of the line, as in `by_line[].key` of punctuality or
            `by_line[].route_id` of service delivery, e.g. `R90`.
        - 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.
      responses:
        '200':
          description: Line retrieved. Directions with stops and shapes.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TransitLineResponse'
        '401':
          description: Unauthorized. Token is missing or invalid.
        '403':
          description: Forbidden. Transit analysis not enabled for location.
        '404':
          description: Not Found. Line not found.
        '422':
          description: Unprocessable Entity. Validation failed.
        '503':
          description: Service Unavailable. Transit schedule unavailable.
      security:
        - HTTPBearer: []
        - HTTPBearer: []
components:
  schemas:
    TransitLineResponse:
      properties:
        route_id:
          type: string
          title: Route Id
        route_short_name:
          type:
            - string
            - 'null'
          title: Route Short Name
        route_long_name:
          type:
            - string
            - 'null'
          title: Route Long Name
        route_color:
          type:
            - string
            - 'null'
          title: Route Color
        directions:
          items:
            $ref: '#/components/schemas/TransitLineDirection'
          type: array
          title: Directions
      type: object
      required:
        - route_id
        - route_short_name
        - route_long_name
        - route_color
        - directions
      title: TransitLineResponse
      examples:
        - directions:
            - direction_id: 0
              headsign: Lotto
              shapes:
                - coordinates:
                    - - 9.1673
                      - 45.4437
                    - - 9.1897
                      - 45.4452
                    - - 9.2101
                      - 45.4469
                  type: LineString
              stops:
                - latitude: 45.4437
                  longitude: 9.1673
                  name: Romolo
                  sequence: 1
                  stop_id: S1120
                - latitude: 45.4469
                  longitude: 9.2101
                  name: Piazzale Lodi
                  sequence: 2
                  stop_id: S1123
          route_color: C8102E
          route_id: R90
          route_long_name: Circolare Destra
          route_short_name: '90'
    TransitLineDirection:
      properties:
        direction_id:
          type:
            - integer
            - 'null'
          title: Direction Id
        headsign:
          type:
            - string
            - 'null'
          title: Headsign
        stops:
          items:
            $ref: '#/components/schemas/TransitLineStop'
          type: array
          title: Stops
        shapes:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Shapes
      type: object
      required:
        - direction_id
        - headsign
        - stops
        - shapes
      title: TransitLineDirection
    TransitLineStop:
      properties:
        stop_id:
          type: string
          title: Stop Id
        name:
          type: string
          title: Name
        latitude:
          type: number
          title: Latitude
        longitude:
          type: number
          title: Longitude
        sequence:
          type: integer
          title: Sequence
      type: object
      required:
        - stop_id
        - name
        - latitude
        - longitude
        - sequence
      title: TransitLineStop
  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.