openapi: 3.1.0
info:
  title: Pathcast
  version: 2.0.0
  description: |
    Pathcast is movement intelligence for out-of-home media: how many vehicles and pedestrians travel the paths that lead to and past a display, hour by hour. Three libraries share the base path `/v2/pathcast/*`:

    - **Path Library** — the reference record for every measured path: its geometry, its vehicle and pedestrian measurement gates, travel mode, roadway class and audit status. Paths are custom linear segments defined for a specific display, not generic road links.
    - **Viewshed Library** — the polygon from which a display can be seen (its *display exposure zone*) together with the face's location, orientation and dimensions. Every face has one viewshed and one or more paths.
    - **Pathcast by Date** — hourly vehicle and pedestrian volumes on each path, by month, day type (`1` Mon–Thu, `2` Fri, `3` Sat, `4` Sun) and hour, monthly since January 2019. Vehicle metrics are the primary, fully validated tier; pedestrian fields are a research preview.

    Authenticate with an org-scoped API key (`X-API-Key: mw_…`). Every endpoint will cost 100 credits per call when live. Prose guides: [Pathcast Path Library](https://www.mworks.com/docs/pathcast-path-library/), [Viewshed Library](https://www.mworks.com/docs/pathcast-viewshed-library/) and [Pathcast by Date](https://www.mworks.com/docs/pathcast-by-date/).

    **Availability:** not yet live — calls currently return 501 `NOT_YET_AVAILABLE`.

    For vector-tile delivery of Pathcast data (drop tiles directly into MapLibre or Mapbox GL), see the [Paths Maptiles reference](./paths/).
  contact:
    name: Motionworks AI
    url: https://mworks.com
    email: api@mworks.com
servers:
  - url: https://api2.mworks.com/v2
    description: Production
security:
  - apiKey: []
components:
  securitySchemes:
    apiKey:
      type: apiKey
      name: X-API-Key
      in: header
  schemas:
    GeoJSONLineString:
      type: object
      additionalProperties: false
      required:
        - type
        - coordinates
      description: GeoJSON `LineString` geometry (RFC 7946), positions longitude-first `[longitude, latitude]`.
      properties:
        type:
          type: string
          enum:
            - LineString
        coordinates:
          type: array
          minItems: 2
          items:
            type: array
            minItems: 2
            maxItems: 2
            items:
              type: number
    GeoJSONPolygon:
      type: object
      additionalProperties: false
      required:
        - type
        - coordinates
      description: GeoJSON `Polygon` geometry (RFC 7946), positions longitude-first; holes as additional rings.
      properties:
        type:
          type: string
          enum:
            - Polygon
        coordinates:
          type: array
          minItems: 1
          items:
            type: array
            minItems: 4
            items:
              type: array
              minItems: 2
              maxItems: 2
              items:
                type: number
    GeoJSONMultiPolygon:
      type: object
      additionalProperties: false
      required:
        - type
        - coordinates
      description: GeoJSON `MultiPolygon` geometry (RFC 7946), positions longitude-first; holes as additional rings.
      properties:
        type:
          type: string
          enum:
            - MultiPolygon
        coordinates:
          type: array
          minItems: 1
          items:
            type: array
            minItems: 1
            items:
              type: array
              minItems: 4
              items:
                type: array
                minItems: 2
                maxItems: 2
                items:
                  type: number
    Path:
      type: object
      additionalProperties: false
      required:
        - place_id
        - path_id
        - audit_status_id
        - audit_status
        - mode
        - funcclass
        - path
        - gate_veh
        - gate_ped
        - modified
      x-motionworks-status: production
      x-motionworks-source: pathcast-path-library
      x-motionworks-source-doc: https://docs.mworks.com/docs/pathcast-path-library
      properties:
        place_id:
          type: integer
          description: |
            The face this record belongs to — the `place_id` of a Motionworks Face place. In the Viewshed Library a face and its viewshed share one id.
        path_id:
          type: string
          description: Unique, persistent id of the path (32 hex characters).
        audit_status_id:
          type: integer
          enum:
            - 0
            - 4
            - 7
            - 9
            - 12
            - 14
          description: |
            Audit status of the path: `0` Assigned (customer-provided, awaiting validation), `4` Audited (professionally audited — highest confidence), `7` Removed from Audit, `9` Automated (system-generated for every significant roadway in the viewshed), `12` Published - Third Party (customer path extended to the viewshed boundary with automated gates), `14` Removed from Publishing (travel in the opposite direction).
        audit_status:
          type: string
          enum:
            - Assigned
            - Audited
            - Removed from Audit
            - Automated
            - Published - Third Party
            - Removed from Publishing
          description: The audit status as a label; pairs with `audit_status_id`.
        mode:
          type: string
          enum:
            - B
            - P
          description: 'Travel mode measured on the path: `B` vehicles and pedestrians, `P` pedestrians only.'
        funcclass:
          type: integer
          description: |
            Functional class of the underlying roadway, from `1` (highest-capacity highways) to `5` (local streets).
        path:
          $ref: '#/components/schemas/GeoJSONLineString'
          description: The path geometry as a GeoJSON `LineString` (WGS84, longitude-first), clipped to the viewshed.
        gate_veh:
          $ref: '#/components/schemas/GeoJSONLineString'
          description: The vehicle measurement gate — the line vehicles must cross to be counted — as a GeoJSON `LineString`.
        gate_ped:
          $ref: '#/components/schemas/GeoJSONLineString'
          description: The pedestrian measurement gate as a GeoJSON `LineString`.
        modified:
          type: string
          description: When the path record was last updated.
      description: |
        One measured path from the Path Library: a custom linear segment with visual exposure to a display, its measurement gates and its audit status.
    Viewshed:
      type: object
      additionalProperties: false
      required:
        - place_id
        - audit_status_id
        - lon
        - lat
        - orientation
        - height_in
        - width_in
        - digital
        - modified
        - max_distance_m
        - geography
      x-motionworks-status: production
      x-motionworks-source: pathcast-viewshed-library
      x-motionworks-source-doc: https://docs.mworks.com/docs/pathcast-viewshed-library
      properties:
        place_id:
          type: integer
          description: The face's `place_id`. A face and its viewshed share one id.
        audit_status_id:
          type: integer
          description: 'Audit status of the face (same code set as paths: `0`, `4`, `7`, `9`, `12`, `14`).'
        lon:
          type: number
          format: double
          description: Longitude of the face (WGS84).
        lat:
          type: number
          format: double
          description: Latitude of the face (WGS84).
        orientation:
          type: number
          description: Compass direction the face points toward, in degrees clockwise from north (`0` north, `180` south).
        height_in:
          type: number
          description: Display height in inches.
        width_in:
          type: number
          description: Display width in inches.
        digital:
          type: boolean
          description: Whether the display is digital (`true`) or static (`false`).
        modified:
          type: string
          description: When the viewshed record was last updated.
        max_distance_m:
          type: number
          description: |
            Maximum distance from the face, in meters, at which it can still be seen — the reach of the viewshed.
        geography:
          oneOf:
            - $ref: '#/components/schemas/GeoJSONPolygon'
            - $ref: '#/components/schemas/GeoJSONMultiPolygon'
          description: The viewshed polygon as a GeoJSON `Polygon` or `MultiPolygon` (WGS84, longitude-first).
      description: A face's viewshed (its display exposure zone) and the display attributes it was calculated from.
    PathTraffic:
      type: object
      additionalProperties: false
      required:
        - place_id
        - path_id
        - audit_status_id
        - year
        - month
        - day_type
        - hour
        - days
        - vehicles
        - vehicle_observations
        - average_speed
        - pedestrians
        - pedestrian_observations
        - is_active
      x-motionworks-status: production
      x-motionworks-source: pathcast-by-date
      x-motionworks-source-doc: https://docs.mworks.com/docs/pathcast-by-date
      properties:
        place_id:
          type: integer
          description: |
            The face this record belongs to — the `place_id` of a Motionworks Face place. In the Viewshed Library a face and its viewshed share one id.
        path_id:
          type: string
          description: The path this row measures.
        audit_status_id:
          type: integer
          enum:
            - 0
            - 4
            - 7
            - 9
            - 12
            - 14
          description: Audit status of the path (see `Path.audit_status_id`).
        year:
          type: integer
          description: Calendar year of the measurement.
        month:
          type: integer
          minimum: 1
          maximum: 12
          description: Month of the measurement (1–12).
        day_type:
          type: integer
          enum:
            - 1
            - 2
            - 3
            - 4
          description: 'Day type: `1` Monday–Thursday, `2` Friday, `3` Saturday, `4` Sunday.'
        hour:
          type: integer
          minimum: 0
          maximum: 23
          description: 'Local hour the row summarizes: `0` = 00:00–00:59 … `23` = 23:00–23:59.'
        days:
          type: integer
          description: Number of days of this day type in the month (for example 5 when the month has five Sundays).
        vehicles:
          type: integer
          description: Estimated vehicles travelling the path that cross the vehicle gate during this hour and day type.
        vehicle_observations:
          type: integer
          description: Number of observed vehicles the estimate was built from.
        average_speed:
          type: integer
          description: Average speed of vehicles along the whole path during this hour and day type, in miles per hour.
        pedestrians:
          type: integer
          nullable: true
          x-motionworks-status: research-preview
          description: |
            Research preview. Estimated pedestrians crossing the pedestrian gate during this hour and day type. `null` for periods after April 2022 while the methodology is refined.
        pedestrian_observations:
          type: integer
          nullable: true
          x-motionworks-status: research-preview
          description: |
            Research preview. Number of observed pedestrians the estimate was built from. `null` for periods after April 2022.
        is_active:
          type: boolean
          description: Whether the path is currently active and available.
      description: |
        One hourly traffic row for a path: estimated vehicles and pedestrians crossing the measurement gates for a given year, month, day type and hour.
    Pagination:
      type: object
      properties:
        cursor:
          type: string
          nullable: true
          description: Opaque cursor for the next page. Pass it back as `cursor` to continue; absent on the last page.
        has_more:
          type: boolean
          description: Whether another page follows.
        total:
          type: integer
          description: Total matching results, when the endpoint reports one.
    Provenance:
      type: object
      if:
        required:
          - is_focused
          - measurement_method
      then:
        oneOf:
          - properties:
              is_focused:
                const: true
              measurement_method:
                const: direct
          - properties:
              is_focused:
                const: false
              measurement_method:
                const: estimated
      properties:
        source:
          type: string
          description: The Motionworks dataset or model the result came from.
        source_doc:
          type: string
          format: uri
          description: Link to the methodology or dataset documentation for this result.
        methodology_version:
          type: string
          description: Version of the methodology that produced the result.
        data_vintage:
          type: string
          format: date
          description: The date the underlying data represents.
        data_freshness:
          type: string
          enum:
            - hourly
            - daily
            - weekly
            - monthly
            - annually
            - on-demand
            - static
          description: How often the underlying data is refreshed (for example `daily`, `monthly`, `annually`).
        data_latency_days:
          type: integer
          description: Typical days between an observation and its availability in the API.
        data_maturity:
          type: string
          enum:
            - production
            - research-preview
            - synthetic-only
            - roadmap
          description: |
            Maturity of the data behind the result: `production` (supported and stable), `research-preview` (available, subject to change), or a pre-release value (`roadmap`, or generated placeholder data not yet backed by production measurement).
        is_focused:
          type: boolean
          description: |
            Whether the place is directly measured (`true`) rather than estimated from its peer group (`false`). When present alongside `measurement_method`, the two agree.
        measurement_method:
          type: string
          enum:
            - direct
            - estimated
          description: |
            `direct` when the place is measured directly; `estimated` when its statistics come from peer-group inference. When present alongside `is_focused`, the two agree (`true` ↔ `direct`).
    Meta:
      type: object
      properties:
        request_id:
          type: string
          description: Unique id for this request. Quote it when contacting support.
        credits_used:
          type: integer
          description: Credits charged for this call.
        credits_remaining:
          type: integer
          description: Credits remaining on your account after this call.
        product:
          type: string
          description: The Motionworks product that served the call (`pathcast`).
        version:
          type: string
          description: API version that served the call.
        provenance:
          $ref: '#/components/schemas/Provenance'
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Stable machine-readable error code.
            message:
              type: string
              description: Human-readable explanation of the error.
            status:
              type: integer
              description: HTTP status code, repeated in the body.
            request_id:
              type: string
              description: Unique id for this request. Quote it when contacting support.
            product:
              type: string
              description: The Motionworks product that produced the error.
            docs_url:
              type: string
              description: Link to the documentation for this error code.
          description: 'The error: a stable `code`, a human-readable `message`, and the HTTP `status`.'
paths:
  /pathcast/paths/{path_id}:
    get:
      operationId: getPath
      summary: Read one path
      tags:
        - Path Library
      description: |
        Returns one path by `path_id`: the face it serves, its geometry, the vehicle and pedestrian measurement gates, travel mode, roadway functional class and audit status. Authenticate with an org-scoped API key (`X-API-Key: mw_…`). 100 credits per call when live.

        **Availability:** not yet live — calls currently return 501 `NOT_YET_AVAILABLE`.
      x-credit-cost: 100
      x-motionworks-status: production
      x-motionworks-source-doc: https://docs.mworks.com/docs/pathcast-path-library
      parameters:
        - name: path_id
          in: path
          required: true
          schema:
            type: string
          description: The path's `path_id` (32 hex characters).
      responses:
        '200':
          description: The path.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/Path'
                  meta:
                    $ref: '#/components/schemas/Meta'
        '404':
          description: Unknown `path_id`.
  /pathcast/faces/{place_id}/paths:
    get:
      operationId: listFacePaths
      summary: List the paths for a face
      tags:
        - Path Library
      description: |
        Returns every path measured for one face, by `place_id`. A face's viewshed is composed of one or more paths, each a distinct travel route with visual exposure to the display. Authenticate with an org-scoped API key (`X-API-Key: mw_…`). 100 credits per call when live.

        **Availability:** not yet live — calls currently return 501 `NOT_YET_AVAILABLE`.
      x-credit-cost: 100
      x-motionworks-status: production
      x-motionworks-source-doc: https://docs.mworks.com/docs/pathcast-path-library
      parameters:
        - name: place_id
          in: path
          required: true
          schema:
            type: integer
          description: The face's `place_id`.
      responses:
        '200':
          description: The face's paths.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Path'
                  meta:
                    $ref: '#/components/schemas/Meta'
  /pathcast/faces/{place_id}/viewshed:
    get:
      operationId: getFaceViewshed
      summary: Read a face's viewshed
      tags:
        - Viewshed Library
      description: |
        Returns the viewshed for one face, by `place_id`: the polygon from which the display can be seen, plus the face's location, orientation, height and width, whether it is digital, its maximum viewing distance and audit status. Authenticate with an org-scoped API key (`X-API-Key: mw_…`). 100 credits per call when live.

        **Availability:** not yet live — calls currently return 501 `NOT_YET_AVAILABLE`.
      x-credit-cost: 100
      x-motionworks-status: production
      x-motionworks-source-doc: https://docs.mworks.com/docs/pathcast-viewshed-library
      parameters:
        - name: place_id
          in: path
          required: true
          schema:
            type: integer
          description: The face's `place_id`.
      responses:
        '200':
          description: The viewshed.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/Viewshed'
                  meta:
                    $ref: '#/components/schemas/Meta'
  /pathcast/paths/{path_id}/traffic:
    get:
      operationId: getPathTraffic
      summary: Read hourly traffic for a path
      description: |
        Returns hourly vehicle and pedestrian volumes for one path — one row per year × month × day type × hour. Narrow the result with `year`, `month`, `day_type` and `hour`; omit a filter to receive every value on that axis (for example, omit `hour` to get all 24 hours). Authenticate with an org-scoped API key (`X-API-Key: mw_…`). 100 credits per call when live.

        **Availability:** not yet live — calls currently return 501 `NOT_YET_AVAILABLE`.
      tags:
        - Pathcast by Date
      x-credit-cost: 100
      x-motionworks-status: production
      x-motionworks-source-doc: https://docs.mworks.com/docs/pathcast-by-date
      parameters:
        - name: path_id
          in: path
          required: true
          schema:
            type: string
          description: The path's `path_id`.
        - name: year
          in: query
          schema:
            type: integer
          description: Calendar year to return. Omit for every available year.
        - name: month
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 12
          description: Month to return (1–12). Omit for every month.
        - name: day_type
          in: query
          schema:
            type: integer
            enum:
              - 1
              - 2
              - 3
              - 4
          description: 'Day type: `1` Monday–Thursday, `2` Friday, `3` Saturday, `4` Sunday. Omit for all four.'
        - name: hour
          in: query
          schema:
            type: integer
            minimum: 0
            maximum: 23
          description: Local hour of day to return (0–23). Omit for all 24 hours.
      responses:
        '200':
          description: The traffic rows matching the filters.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/PathTraffic'
                  meta:
                    $ref: '#/components/schemas/Meta'
  /pathcast/paths/{path_id}/history:
    get:
      operationId: getPathHistory
      summary: Read traffic history for a path
      tags:
        - Pathcast by Date
      description: |
        Returns the hourly traffic rows for one path across a date range, for trend analysis over many months. Bound the range with `start_date` and `end_date`. Authenticate with an org-scoped API key (`X-API-Key: mw_…`). 100 credits per call when live.

        **Availability:** not yet live — calls currently return 501 `NOT_YET_AVAILABLE`.
      x-credit-cost: 100
      x-motionworks-status: production
      x-motionworks-source-doc: https://docs.mworks.com/docs/pathcast-by-date
      parameters:
        - name: path_id
          in: path
          required: true
          schema:
            type: string
          description: The path's `path_id`.
        - name: start_date
          in: query
          schema:
            type: string
            format: date
          description: First month to include (`YYYY-MM-DD`).
        - name: end_date
          in: query
          schema:
            type: string
            format: date
          description: Last month to include (`YYYY-MM-DD`).
      responses:
        '200':
          description: The traffic rows across the date range.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/PathTraffic'
                  meta:
                    $ref: '#/components/schemas/Meta'
x-tagGroups:
  - name: Paths & Viewsheds
    tags:
      - Path Library
      - Viewshed Library
  - name: Traffic
    tags:
      - Pathcast by Date
tags:
  - name: Path Library
    description: |
      The reference record for every measured path — geometry, measurement gates, travel mode, roadway class and audit status. 100 credits per call when live. Not yet live — calls currently return 501 `NOT_YET_AVAILABLE`.
  - name: Viewshed Library
    description: |
      The viewshed polygon and display attributes for a face. 100 credits per call when live. Not yet live — calls currently return 501 `NOT_YET_AVAILABLE`.
  - name: Pathcast by Date
    description: |
      Hourly vehicle and pedestrian volumes on a path by month, day type and hour, monthly since January 2019. 100 credits per call when live. Not yet live — calls currently return 501 `NOT_YET_AVAILABLE`.
x-customer-voice: true
