{
  "openapi": "3.1.0",
  "info": {
    "title": "TransparentDOT Open Machine API",
    "version": "1.0.0",
    "description": "Static, machine-readable access to public FMCSA-derived artifacts. Consult the manifest for the release vintage, row counts, hashes and byte sizes; read the actual Parquet schema for available columns.\n\nDuckDB and other compatible engines can query Parquet using HTTP range requests where the configured artifact host supports them. Transfer volume and latency depend on the query, network, cache and row-group layout; this API makes no sub-50ms or zero-compute-cost guarantee.\n\nAddress correspondence is not present mailbox control, delegation or approval of a load/payout. BEC and endpoint compromise can affect any participant. Historical inspection records are not current driver identity or operating authority. Bulk missing fields must not be converted into adverse verdicts.\n\nCorrection (2026-11-22): removed unsupported per-record competitor pricing, fixed row counts and sub-50ms/$0-compute claims. The former GitHub Pages live-origin assertion was not revalidated. Select the artifact origin actually configured for your deployment; this document does not establish a live deployment.\n\nThe allowed_to_operate column is deliberately nullable in the bulk artifact; this static API does not execute a live FMCSA QCMobile lookup. A sourced live result and its freshness remain separate from bulk fields.",
    "contact": {
      "name": "TransparentDOT Community",
      "url": "https://github.com/TransparentDOT/transparentdot"
    },
    "license": {
      "name": "AGPL-3.0",
      "url": "https://www.gnu.org/licenses/agpl-3.0.html"
    }
  },
  "servers": [
    {
      "url": "/",
      "description": "Same-origin artifact layout when deployed here. External-artifact deployments must select their configured data origin."
    }
  ],
  "tags": [
    {
      "name": "Metadata & Freshness",
      "description": "Dataset manifests, row counts, and synchronization timestamps"
    },
    {
      "name": "Columnar Parquet Datasets",
      "description": "Direct HTTP range-request targets for DuckDB, Polars, and analytical runtimes"
    },
    {
      "name": "Insights & Leaderboards",
      "description": "Precomputed scope leaderboards and monthly time series. Fetched by /stats."
    }
  ],
  "paths": {
    "/data/meta.json": {
      "get": {
        "tags": [
          "Metadata & Freshness"
        ],
        "summary": "Dataset Manifest & Freshness Check",
        "description": "Returns the active dataset release timestamp, SHA-256 hashes, exact row counts, and byte sizes.",
        "operationId": "getDatasetMeta",
        "responses": {
          "200": {
            "description": "Current release metadata",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DatasetMeta"
                }
              }
            }
          }
        }
      }
    },
    "/data/change-feed-meta.json": {
      "get": {
        "tags": [
          "Metadata & Freshness"
        ],
        "summary": "30-Day Change Ledger Metadata",
        "description": "Returns update windows, source dataset IDs, and latest timestamps feeding the observed change ledger.",
        "operationId": "getChangeFeedMeta",
        "responses": {
          "200": {
            "description": "Change feed configuration and upstream source states",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "change_feed_window_days": {
                      "type": "integer",
                      "example": 30
                    },
                    "sources": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/data/carriers_details.parquet": {
      "get": {
        "tags": [
          "Columnar Parquet Datasets"
        ],
        "summary": "Full Carrier Profile Dataset (row count & bytes published in /data/meta.json)",
        "description": "Hyper-compressed ZSTD-19 Parquet containing census, contact, operating authority, insurance filings, CDL counts, and out-of-service orders. **The served column set is trimmed and versioned: `meta.json` publishes `dataset_version`, per-file `sha256`, `row_counts`, `bytes`, and the `derived_fields` map — quote the manifest, never a column list remembered from prose. The full served column list is NOT published in `meta.json`; read it from the Parquet schema.**",
        "operationId": "getCarriersDetailsParquet",
        "parameters": [
          {
            "name": "Range",
            "in": "header",
            "required": false,
            "description": "Standard HTTP Range request header (e.g. `bytes=0-4096`). Required for partial columnar scans.",
            "schema": {
              "type": "string",
              "example": "bytes=0-1024"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Full Parquet binary stream",
            "content": {
              "application/vnd.apache.parquet": {}
            }
          },
          "206": {
            "description": "Partial byte-range response",
            "content": {
              "application/vnd.apache.parquet": {}
            }
          }
        }
      }
    },
    "/data/safety.parquet": {
      "get": {
        "tags": [
          "Columnar Parquet Datasets"
        ],
        "summary": "Rolling 24-Month Safety & Crash Summaries (row count published in /data/meta.json)",
        "description": "Inspections (total, driver, vehicle, hazmat), violation counts, rolling crashes (fatal, injury, tow-away), and driver/vehicle OOS rates derived per row. **A national-average OOS comparison baseline is NOT derived from the data: any `nat_*_oos_avg` value carried in the artifact is a hand-typed historical stand-in (a 2009–2010 figure), not a population mean — treat it as `Unverified` and never present it as a benchmark. Comparisons should stay disabled until a derived baseline replaces it.**",
        "operationId": "getSafetyParquet",
        "parameters": [
          {
            "name": "Range",
            "in": "header",
            "required": false,
            "description": "Standard HTTP Range request header (e.g. `bytes=0-4096`). Required for partial columnar scans.",
            "schema": {
              "type": "string",
              "example": "bytes=0-1024"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Full Parquet binary stream",
            "content": {
              "application/vnd.apache.parquet": {}
            }
          },
          "206": {
            "description": "Partial byte-range response",
            "content": {
              "application/vnd.apache.parquet": {}
            }
          }
        }
      }
    },
    "/data/changes.parquet": {
      "get": {
        "tags": [
          "Columnar Parquet Datasets"
        ],
        "summary": "Observed change events (window and counts in release metadata)",
        "description": "Field-level change events across safety, insurance, authority, and status observed over the last 30 days.",
        "operationId": "getChangesParquet",
        "responses": {
          "200": {
            "description": "Changes Parquet binary stream",
            "content": {
              "application/vnd.apache.parquet": {}
            }
          }
        }
      }
    },
    "/data/inspections_history.parquet": {
      "get": {
        "tags": [
          "Columnar Parquet Datasets"
        ],
        "summary": "Inspection history from the published snapshot",
        "description": "Compressed historical roadside inspection records with Level 1-6 inspection dates, state, facility type, duration, gross weight, and OOS outcomes.",
        "operationId": "getInspectionsHistoryParquet",
        "parameters": [
          {
            "name": "Range",
            "in": "header",
            "required": false,
            "description": "HTTP Range request header for partial columnar scans.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Inspections History binary stream",
            "content": {
              "application/vnd.apache.parquet": {}
            }
          },
          "206": {
            "description": "Partial byte-range response",
            "content": {
              "application/vnd.apache.parquet": {}
            }
          }
        }
      }
    },
    "/data/carrier_shippers.parquet": {
      "get": {
        "tags": [
          "Columnar Parquet Datasets"
        ],
        "summary": "Shipper names recorded on inspection rows in the published snapshot",
        "description": "Aggregated carrier-to-shipper relationships extracted from verified roadside bills of lading (MCMIS fx4q), showing load volume and latest sighting date.",
        "operationId": "getCarrierShippersParquet",
        "parameters": [
          {
            "name": "Range",
            "in": "header",
            "required": false,
            "description": "HTTP Range request header for partial columnar scans.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Carrier Shippers binary stream",
            "content": {
              "application/vnd.apache.parquet": {}
            }
          },
          "206": {
            "description": "Partial byte-range response",
            "content": {
              "application/vnd.apache.parquet": {}
            }
          }
        }
      }
    },
    "/data/broker_bonds.parquet": {
      "get": {
        "tags": [
          "Columnar Parquet Datasets"
        ],
        "summary": "Active $75,000 Broker BMC-84/BMC-85 Surety Bonds & Trust Funds",
        "description": "Complete federal registry of active broker financial security filings: guarantor surety company name, bond/policy number, and effective dates for claim recovery.",
        "operationId": "getBrokerBondsParquet",
        "parameters": [
          {
            "name": "Range",
            "in": "header",
            "required": false,
            "description": "HTTP Range request header for partial columnar scans.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Broker Bonds binary stream",
            "content": {
              "application/vnd.apache.parquet": {}
            }
          },
          "206": {
            "description": "Partial byte-range response",
            "content": {
              "application/vnd.apache.parquet": {}
            }
          }
        }
      }
    },
    "/data/stats/index.json": {
      "get": {
        "tags": [
          "Insights & Leaderboards"
        ],
        "summary": "Compiled insights index",
        "description": "Scope manifest for the precomputed leaderboards: per-scope filename, SHA-256 and byte size, plus methodology notes and the monthly inspection/crash time series. Clients fetch this first, then only the scope they display.",
        "operationId": "getStatsIndex",
        "responses": {
          "200": {
            "description": "Scope index",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatsIndex"
                }
              }
            }
          }
        }
      }
    },
    "/data/stats/{scopeFile}": {
      "get": {
        "tags": [
          "Insights & Leaderboards"
        ],
        "summary": "One compiled scope",
        "description": "Leaderboards for a single scope. `scopeFile` is the `file` value from the index for that scope (for example `ALL-8f55....json`), not a state code. Verify the SHA-256 before use.",
        "operationId": "getStatsScope",
        "parameters": [
          {
            "name": "scopeFile",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Exact filename from /data/stats/index.json -> scopes[scope].file"
          }
        ],
        "responses": {
          "200": {
            "description": "Scope leaderboards",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/StatLeaderItem"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such scope file in this release"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "DatasetMeta": {
        "type": "object",
        "required": [
          "dataset_version",
          "generated_at",
          "sha256",
          "row_counts",
          "bytes"
        ],
        "properties": {
          "dataset_version": {
            "type": "string",
            "example": "2026-10-23"
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          },
          "sha256": {
            "type": "object"
          },
          "row_counts": {
            "type": "object"
          },
          "bytes": {
            "type": "object"
          },
          "derived_fields": {
            "type": "object",
            "description": "Column name -> DuckDB type for every build-time derived field. A client can use this to detect a schema change before querying.",
            "additionalProperties": {
              "type": "string"
            }
          },
          "email_coverage": {
            "type": [
              "object",
              "null"
            ],
            "description": "Derived contact-coverage counts, computed from the same parquet the manifest describes. Present so the UI never hardcodes a figure that a refresh invalidates.",
            "properties": {
              "total_carriers": {
                "type": "integer",
                "example": 2244301
              },
              "publishing_email": {
                "type": "integer",
                "example": 1708730
              },
              "no_email": {
                "type": "integer",
                "example": 535571
              },
              "unique_addresses": {
                "type": "integer",
                "example": 1588633
              }
            }
          }
        }
      },
      "StatLeaderItem": {
        "type": "object",
        "description": "One derived leaderboard row. value may be a reported count or a documented derived metric; rank orders that metric within its scope, not character, guilt or transaction safety.",
        "properties": {
          "rank": {
            "type": "integer"
          },
          "dot": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "subtext": {
            "type": "string"
          },
          "value": {
            "oneOf": [
              {
                "type": "integer"
              },
              {
                "type": "string"
              }
            ]
          },
          "metricLabel": {
            "type": "string"
          },
          "st": {
            "type": "string"
          },
          "key": {
            "type": "string"
          }
        }
      },
      "StatsIndex": {
        "type": "object",
        "required": [
          "schema_version",
          "generated_at",
          "scopes"
        ],
        "properties": {
          "schema_version": {
            "type": "integer",
            "example": 1
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          },
          "population": {
            "type": "object",
            "properties": {
              "total_records": {
                "type": "integer"
              },
              "active_records": {
                "type": "integer"
              },
              "active_dedup_dot": {
                "type": "integer"
              },
              "scopes_count": {
                "type": "integer"
              }
            }
          },
          "methodology": {
            "type": "object",
            "description": "How each figure was derived, including the clean-fleet definition and the privacy note that these keys are normalised, not anonymised."
          },
          "scopes": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "file": {
                  "type": "string"
                },
                "sha256": {
                  "type": "string"
                },
                "bytes": {
                  "type": "integer"
                }
              }
            }
          },
          "time_series": {
            "type": "object"
          }
        }
      }
    }
  }
}
