> ## 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 After-Hours Demand Analysis

> Analyze mobility demand occurring outside the standard operating hours of the station-based system. Returns hour-by-hour demand simulation, 24-hour demand patterns for comparison, station-level after-hours metrics with opportunity scores, summary metrics, and the current service hours configuration.

Use this to evaluate whether extending operating hours would capture significant additional demand.

**Failure Modes:**
- **401**: Token is missing or invalid
- **403**: Insufficient permissions
- **404**: `no_data_binding` when the provider or location is not enabled for your company, or no data for that location and period
- **422**: Invalid filter parameters
- **500**: Internal server error

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



## OpenAPI

````yaml /api-reference/openapi.json get /copilot/station-based/{provider}/after_hours_demand
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/station-based/{provider}/after_hours_demand:
    get:
      tags:
        - Station Based Analytics
      summary: Get After-Hours Demand Analysis
      description: >-
        Analyze mobility demand occurring outside the standard operating hours
        of the station-based system. Returns hour-by-hour demand simulation,
        24-hour demand patterns for comparison, station-level after-hours
        metrics with opportunity scores, summary metrics, and the current
        service hours configuration.


        Use this to evaluate whether extending operating hours would capture
        significant additional demand.


        **Failure Modes:**

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

        - **403**: Insufficient permissions

        - **404**: `no_data_binding` when the provider or location is not
        enabled for your company, or no data for that location and period

        - **422**: Invalid filter parameters

        - **500**: Internal server error


        **Required Auth Scopes:**

        - `copilot:analytics`
      operationId: get_after_hours_demand
      parameters:
        - name: provider
          in: path
          required: true
          schema:
            type: string
            description: >-
              Identifier of the mobility provider whose data you analyse, e.g.
              `acme-bikes`. It must be the provider of a data source enabled for
              your company's station-based analytics; any other value is refused
              with 404 `no_data_binding` (`kind: source`). Your SWITCH contact
              tells you the provider identifiers and locations enabled for your
              company.
            title: Provider
          description: >-
            Identifier of the mobility provider whose data you analyse, e.g.
            `acme-bikes`. It must be the provider of a data source enabled for
            your company's station-based analytics; any other value is refused
            with 404 `no_data_binding` (`kind: source`). Your SWITCH contact
            tells you the provider identifiers and locations enabled for your
            company.
        - name: geolabel
          in: query
          required: true
          schema:
            type: string
            description: >-
              Location to analyse, e.g. `milan`: one of the locations (or their
              geolabels) that your company's station-based analytics are enabled
              for with this provider. Any other value is refused with 404
              `no_data_binding` (`kind: location`).
            title: Geolabel
          description: >-
            Location to analyse, e.g. `milan`: one of the locations (or their
            geolabels) that your company's station-based analytics are enabled
            for with this provider. Any other value is refused with 404
            `no_data_binding` (`kind: location`).
        - name: start_date
          in: query
          required: true
          schema:
            type: string
            format: date-time
            description: >-
              Start of the analysis period, an ISO 8601 date-time with a time
              zone, e.g. `2026-10-01T00:00:00Z`.
            title: Start Date
          description: >-
            Start of the analysis period, an ISO 8601 date-time with a time
            zone, e.g. `2026-10-01T00:00:00Z`.
        - name: end_date
          in: query
          required: true
          schema:
            type: string
            format: date-time
            description: >-
              End of the analysis period, an ISO 8601 date-time with a time
              zone, e.g. `2026-10-31T23:59:59Z`. Must be after `start_date`, at
              most 366 days later.
            title: End Date
          description: >-
            End of the analysis period, an ISO 8601 date-time with a time zone,
            e.g. `2026-10-31T23:59:59Z`. Must be after `start_date`, at most 366
            days later.
        - name: start_hour
          in: query
          required: false
          schema:
            type:
              - integer
              - 'null'
            maximum: 23
            minimum: 0
            description: >-
              First hour of the day to include (0-23, local time of the city).
              Set together with `end_hour`; both bounds are included.
            title: Start Hour
          description: >-
            First hour of the day to include (0-23, local time of the city). Set
            together with `end_hour`; both bounds are included.
        - name: end_hour
          in: query
          required: false
          schema:
            type:
              - integer
              - 'null'
            maximum: 23
            minimum: 0
            description: >-
              Last hour of the day to include (0-23, local time of the city),
              not before `start_hour`. Set together with `start_hour`.
            title: End Hour
          description: >-
            Last hour of the day to include (0-23, local time of the city), not
            before `start_hour`. Set together with `start_hour`.
      responses:
        '200':
          description: >-
            After-hours demand data retrieved. Returns demand simulation, hourly
            patterns, station metrics, opportunity assessment, and service hours
            configuration.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AfterHoursDemandResponse'
        '401':
          description: Unauthorized. Token is missing or invalid.
        '403':
          description: Forbidden. Insufficient permissions.
        '422':
          description: Unprocessable Entity. Validation failed.
        '500':
          description: Internal Server Error.
      security:
        - HTTPBearer: []
        - HTTPBearer: []
components:
  schemas:
    AfterHoursDemandResponse:
      properties:
        simulation_df:
          items:
            $ref: '#/components/schemas/AfterHoursSimulationData'
          type: array
          title: Simulation Df
          description: Hour-by-hour simulation of after-hours demand and availability
        hourly_patterns:
          items:
            $ref: '#/components/schemas/HourlyDemandData'
          type: array
          title: Hourly Patterns
          description: 24-hour demand patterns for context and comparison
        station_analysis:
          items:
            $ref: '#/components/schemas/StationAfterHoursMetrics'
          type: array
          title: Station Analysis
          description: Station-level after-hours metrics including ebike ratios
        after_hours_metrics:
          $ref: '#/components/schemas/AfterHoursMetrics'
          description: Summary metrics and opportunity assessment
        service_hours:
          $ref: '#/components/schemas/ServiceHours'
          description: Service hours configuration for the bike sharing system
      type: object
      required:
        - simulation_df
        - hourly_patterns
        - station_analysis
        - after_hours_metrics
        - service_hours
      title: AfterHoursDemandResponse
      description: >-
        After hours demand analysis response with comprehensive demand
        simulation.
      examples:
        - after_hours_metrics:
            avg_after_hours_availability: 7.3
            demand_vs_avg_hourly: 38.5
            opportunity_ratio: 0.27
            total_estimated_demand: 118
          hourly_patterns:
            - avg_trips: 6.1
              demand_level: 58
              hour: 23
              peak_indicator: false
            - avg_trips: 14.8
              demand_level: 131
              hour: 18
              peak_indicator: true
          service_hours:
            end_hour: 23
            is_24_hour: false
            start_hour: 6
          simulation_df:
            - current_availability: 7.2
              estimated_demand: 42
              hour: 0
            - current_availability: 7.4
              estimated_demand: 25
              hour: 1
          station_analysis:
            - avg_after_hours_availability: 6.3
              ebike_ratio: 0.4
              estimated_after_hours_demand: 11.5
              opportunity_score: 1.83
              station_id: 318
              station_latitude: 45.4532
              station_longitude: 9.176
              station_name: Darsena
            - avg_after_hours_availability: 9
              ebike_ratio: 0.35
              estimated_after_hours_demand: 8.2
              opportunity_score: 0.91
              station_id: 101
              station_latitude: 45.4642
              station_longitude: 9.19
              station_name: Duomo
    AfterHoursSimulationData:
      properties:
        hour:
          type: integer
          maximum: 5
          minimum: 0
          title: Hour
          description: Hour of day during after-hours period (0-5)
          examples:
            - 0
            - 2
            - 4
        estimated_demand:
          type: number
          minimum: 0
          title: Estimated Demand
          description: Estimated missed demand based on late evening patterns
          examples:
            - 5.2
            - 8.7
            - 12.3
        current_availability:
          type: number
          minimum: 0
          title: Current Availability
          description: Current vehicle availability during this hour
          examples:
            - 8.5
            - 12
            - 15.7
      type: object
      required:
        - hour
        - estimated_demand
        - current_availability
      title: AfterHoursSimulationData
      description: After-hours demand simulation data for individual hours.
    HourlyDemandData:
      properties:
        hour:
          type: integer
          maximum: 23
          minimum: 0
          title: Hour
          description: Hour of day (0-23)
          examples:
            - 8
            - 14
            - 20
        demand_level:
          type: number
          minimum: 0
          title: Demand Level
          description: >-
            Estimated missed demand level for this hour based on shortage
            patterns
          examples:
            - 12.5
            - 8.7
            - 25.3
        avg_trips:
          type: number
          minimum: 0
          title: Avg Trips
          description: Average estimated trips that could have occurred during this hour
          examples:
            - 5.2
            - 3.8
            - 9.1
        peak_indicator:
          type: boolean
          title: Peak Indicator
          description: Whether this hour represents above-average demand
          examples:
            - true
            - false
      type: object
      required:
        - hour
        - demand_level
        - avg_trips
        - peak_indicator
      title: HourlyDemandData
      description: Hourly demand pattern data with demand estimation and peak detection.
    StationAfterHoursMetrics:
      properties:
        station_id:
          anyOf:
            - type: integer
            - type: string
          title: Station Id
          description: Unique identifier for the bike sharing station
          examples:
            - 123
            - station_456
            - ST_789
        station_name:
          type: string
          minLength: 1
          title: Station Name
          description: Human-readable name of the station
          examples:
            - Central Station
            - Park Avenue
            - Main Square
        station_latitude:
          type: number
          maximum: 90
          minimum: -90
          title: Station Latitude
          description: Station latitude in decimal degrees
          examples:
            - 45.464664
            - 40.7128
            - 51.5074
        station_longitude:
          type: number
          maximum: 180
          minimum: -180
          title: Station Longitude
          description: Station longitude in decimal degrees
          examples:
            - 9.18854
            - -74.006
            - -0.1278
        avg_after_hours_availability:
          type: number
          minimum: 0
          title: Avg After Hours Availability
          description: Average vehicle availability during after-hours (0-5)
          examples:
            - 8.5
            - 12.3
            - 15.7
        estimated_after_hours_demand:
          type: number
          minimum: 0
          title: Estimated After Hours Demand
          description: Estimated missed demand at this station during after-hours
          examples:
            - 5.2
            - 8.7
            - 12.3
        ebike_ratio:
          type: number
          maximum: 1
          minimum: 0
          title: Ebike Ratio
          description: >-
            Average proportion of available bikes that are e-bikes at this
            station
          examples:
            - 0.32
            - 0.45
            - 0.67
        opportunity_score:
          type: number
          minimum: 0
          title: Opportunity Score
          description: After-hours opportunity score for this station (higher is better)
          examples:
            - 0.25
            - 0.58
            - 0.83
      type: object
      required:
        - station_id
        - station_name
        - station_latitude
        - station_longitude
        - avg_after_hours_availability
        - estimated_after_hours_demand
        - ebike_ratio
        - opportunity_score
      title: StationAfterHoursMetrics
      description: Station-level after-hours demand metrics with ebike information.
    AfterHoursMetrics:
      properties:
        total_estimated_demand:
          type: number
          minimum: 0
          title: Total Estimated Demand
          description: Total estimated after-hours demand across all hours
          examples:
            - 45.2
            - 78.5
            - 123.7
        avg_after_hours_availability:
          type: number
          minimum: 0
          title: Avg After Hours Availability
          description: Average vehicle availability during after-hours (0-5)
          examples:
            - 12.5
            - 18.3
            - 25.1
        opportunity_ratio:
          type: number
          minimum: 0
          title: Opportunity Ratio
          description: Ratio of demand to availability (higher indicates opportunity)
          examples:
            - 0.75
            - 1.25
            - 2.1
        demand_vs_avg_hourly:
          type: number
          minimum: 0
          title: Demand Vs Avg Hourly
          description: After-hours demand as percentage of average hourly demand
          examples:
            - 15.5
            - 23.8
            - 35.2
      type: object
      required:
        - total_estimated_demand
        - avg_after_hours_availability
        - opportunity_ratio
        - demand_vs_avg_hourly
      title: AfterHoursMetrics
      description: Summary metrics for after-hours demand analysis.
    ServiceHours:
      properties:
        start_hour:
          type: integer
          title: Start Hour
        end_hour:
          type: integer
          title: End Hour
        is_24_hour:
          type: boolean
          title: Is 24 Hour
      type: object
      required:
        - start_hour
        - end_hour
        - is_24_hour
      title: ServiceHours
      description: Service hours configuration.
  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.