openapi: 3.1.0
info:
  title: FPDS-NG MCP (x402)
  version: 0.1.0
  description: |
    Pay-per-call x402 endpoints for the U.S. Federal Procurement Data System
    (FPDS-NG). Two endpoints: search and by_vendor. No signup, no API key —
    pay USDC on Base. Each first call returns HTTP 402 with an x402 envelope;
    sign X-PAYMENT and retry.
  contact:
    name: 
    url: 
    email: hello@
servers:
  - url: https://fpds-mcp.mtree.workers.dev
x-pricing:
  - path: /v1/contracts/search
    method: POST
    price: $0.04
    amount: "0.04"
    asset: USDC
    network: base
  - path: /v1/contracts/by_vendor
    method: POST
    price: $0.05
    amount: "0.05"
    asset: USDC
    network: base
paths:
  /v1/contracts/search:
    post:
      operationId: contractsSearch
      summary: Search FPDS-NG contract actions
      description: |
        $0.04/call. Search U.S. federal contract actions in FPDS-NG by description
        keyword, contracting agency code, NAICS, and signing-date window.
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                keyword:
                  type: string
                  description: Substring match against description-of-requirement (optional)
                  example: satellite
                agencyCode:
                  type: string
                  description: Contracting agency 4-digit code (optional)
                  example: "9700"
                naics:
                  type: string
                  description: Principal NAICS code (optional)
                  example: "517410"
                signedFromDays:
                  type: number
                  description: Look back this many days for signed contract actions (1–3650)
                  example: 365
                limit:
                  type: number
                  description: Max results (1–50)
                  example: 25
      responses:
        "200":
          description: Search results
        "402":
          description: x402 payment required
        "502":
          description: FPDS upstream error
  /v1/contracts/by_vendor:
    post:
      operationId: contractsByVendor
      summary: Recent FPDS contracts for a single vendor + aggregate
      description: |
        $0.05/call. Pull recent FPDS contract actions for a single vendor (by name
        substring, case-insensitive) and return both the rows and a quick
        aggregate (total obligated $, distinct agencies, distinct NAICS).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [vendor]
              properties:
                vendor:
                  type: string
                  description: Vendor name substring (case-insensitive)
                  example: Lockheed Martin
                signedFromDays:
                  type: number
                  description: Look back this many days (1–3650)
                  example: 1825
                limit:
                  type: number
                  description: Max results (1–50)
                  example: 25
      responses:
        "200":
          description: Vendor contracts + aggregate
        "402":
          description: x402 payment required
        "502":
          description: FPDS upstream error
components:
  securitySchemes:
    x402:
      type: http
      scheme: x402
      description: |
        Pay-per-call via x402 (USDC on Base). On first request, the API returns
        HTTP 402 with an "accepts" array. Sign and submit X-PAYMENT to retry.
security:
  - x402: []
