{
  "openapi": "3.0.1",
  "info": {
    "title": "UK NHS Providers Scraper — ODS Organisation Registry",
    "description": "Search the official NHS Organisation Data Service (ODS) registry of UK healthcare providers — GP practices, pharmacies, dentists, NHS trusts, hospices, care homes. Filter by name, postcode, type, status; optional full address/contacts/roles. Official open-data API (OGL v3), no login, no proxies.",
    "version": "0.1",
    "x-build-id": "BA9aYYGf06UiBtgmS"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/nomad-agent~uk-nhs-ods-providers-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-nomad-agent-uk-nhs-ods-providers-scraper",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/acts/nomad-agent~uk-nhs-ods-providers-scraper/runs": {
      "post": {
        "operationId": "runs-sync-nomad-agent-uk-nhs-ods-providers-scraper",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor and returns information about the initiated run in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/runsResponseSchema"
                }
              }
            }
          }
        }
      }
    },
    "/acts/nomad-agent~uk-nhs-ods-providers-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-nomad-agent-uk-nhs-ods-providers-scraper",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "inputSchema": {
        "type": "object",
        "properties": {
          "mode": {
            "title": "Mode",
            "enum": [
              "search",
              "detail"
            ],
            "type": "string",
            "description": "<code>search</code> queries the registry with the filters below. <code>detail</code> fetches full records for the ODS codes listed in odsCodes.",
            "default": "search"
          },
          "name": {
            "title": "Name contains",
            "type": "string",
            "description": "Case-insensitive substring match on the organisation name (e.g. <code>pharmacy</code>, <code>surgery</code>, <code>st thomas</code>)."
          },
          "postCode": {
            "title": "Postcode",
            "type": "string",
            "description": "Full or partial UK postcode (e.g. <code>BS1</code>, <code>SW1A 1AA</code>, <code>LS</code>). Prefix match on the registered address."
          },
          "providerType": {
            "title": "Provider type",
            "enum": [
              "any",
              "gp_practice",
              "pharmacy",
              "dental_practice",
              "nhs_trust",
              "nhs_trust_site",
              "hospice",
              "care_home",
              "optical_site",
              "independent_provider",
              "branch_surgery"
            ],
            "type": "string",
            "description": "Common healthcare provider types, mapped to official ODS role codes. Use roleId below for any other role.",
            "default": "any"
          },
          "specialty": {
            "title": "Specialty (free text)",
            "type": "string",
            "description": "Free-text provider specialty, matched against the official ODS role vocabulary (e.g. <code>pharmacy</code>, <code>hospice</code>, <code>dental</code>, <code>optical</code>). A convenience alternative to the <code>Provider type</code> enum for roles it doesn't list. Ignored if <code>Provider type</code> (non-Any) or <code>Role ID</code> is set."
          },
          "roleId": {
            "title": "Role ID (advanced)",
            "type": "string",
            "description": "Any official ODS role code (e.g. <code>RO177</code>). Overrides providerType and specialty. Full list: https://directory.spineservices.nhs.uk/ORD/2-0-0/roles"
          },
          "status": {
            "title": "Status",
            "enum": [
              "active",
              "inactive",
              "all"
            ],
            "type": "string",
            "description": "Registration status filter.",
            "default": "active"
          },
          "lastChangeDate": {
            "title": "Changed since",
            "type": "string",
            "description": "Only organisations whose record changed on or after this date — useful for incremental syncs. Note: the registry itself rejects dates more than ~185 days in the past (HTTP 406). For automatic incremental syncs without picking a date by hand, use <code>Only new since last run</code> below instead."
          },
          "onlyNewSinceLastRun": {
            "title": "Only new since last run",
            "type": "boolean",
            "description": "Search only organisations changed since this Actor's own last successful run (uses the registry's LastChangeDate filter under the hood — cheaper and more accurate than caching every id ever seen across ~280k organisations). Overrides <code>Changed since</code> once a prior run exists. Search mode only — no-op in detail mode. Every returned record is tagged isNew: true.",
            "default": false
          },
          "odsCodes": {
            "title": "ODS codes (detail mode)",
            "type": "array",
            "description": "Organisation ODS codes to fetch in detail mode (e.g. L81008, RA7, FLM49).",
            "items": {
              "type": "string"
            }
          },
          "includeDetails": {
            "title": "Include full details",
            "type": "boolean",
            "description": "In search mode, enrich every hit with the full registry record (address, contacts, all roles, operational dates). One extra API call per organisation — slower on big result sets.",
            "default": false
          },
          "includeGeo": {
            "title": "Add lat/long geocoding",
            "type": "boolean",
            "description": "Geocode each organisation's postcode to <code>latitude</code>/<code>longitude</code> using the free, open postcodes.io service (Ordnance Survey / ONS open data). Best-effort — postcodes that can't be resolved return null coordinates. Adds a small batch of extra lookups; no per-record cost.",
            "default": false
          },
          "includeRelationshipNames": {
            "title": "Resolve relationship target names",
            "type": "boolean",
            "description": "Fill in each relationship's <code>targetName</code> (e.g. the parent NHS trust an org site is operated by). Requires detail data (detail mode, or <code>Include full details</code> in search mode) — costs one extra API call per unique related organisation. Off by default: relationships still carry <code>targetOdsCode</code>, just with <code>targetName</code> null.",
            "default": false
          },
          "maxItems": {
            "title": "Max items",
            "minimum": 0,
            "type": "integer",
            "description": "Hard cap on organisations returned. Each returned organisation is a billed result, so keep this low while testing filters — raise it once you know your filter returns the right set. 0 = no cap (the full register is ~280k organisations — set a cap or a filter).",
            "default": 100
          },
          "concurrency": {
            "title": "Concurrency",
            "minimum": 1,
            "maximum": 16,
            "type": "integer",
            "description": "How many detail records (detail mode / includeDetails) to fetch in parallel. Higher is faster but hits the registry API harder — leave the default unless you know you need to change it.",
            "default": 8
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}