{
  "openapi": "3.1.0",
  "info": {
    "title": "NearbyNotary Directory API",
    "version": "1.0.0",
    "description": "Read-only public-professional directory of Singapore Notary Publics and Commissioners for Oaths. Data is sourced from the Singapore Academy of Law Directory and enriched with published Google business information. Responses expose public listing and freshness fields, not internal update telemetry. Cite a result using canonical_url and verify availability directly with the listed professional.",
    "termsOfService": "https://www.nearbynotary.sg/developers"
  },
  "servers": [
    {
      "url": "https://www.nearbynotary.sg"
    }
  ],
  "paths": {
    "/api/v1/commissioners": {
      "get": {
        "operationId": "searchProfessionals",
        "summary": "Search notaries and commissioners",
        "description": "Returns factual public directory records. Coordinates must be supplied together. Use open_now=true to return only professionals whose published Google opening periods indicate they are currently open. Use canonical_url when citing a result.",
        "parameters": [
          {
            "name": "search",
            "in": "query",
            "schema": { "type": "string", "maxLength": 100 },
            "description": "Professional or firm name"
          },
          {
            "name": "location",
            "in": "query",
            "schema": { "type": "string", "maxLength": 100 },
            "description": "Address, firm, or Singapore postal-code text"
          },
          {
            "name": "type",
            "in": "query",
            "schema": { "type": "string", "enum": ["CO", "NP", "BOTH", "commissioner", "notary", "both", "all"] },
            "description": "CO and NP also include records offering both services; BOTH returns only dual-service records"
          },
          {
            "name": "language",
            "in": "query",
            "schema": { "type": "string", "maxLength": 40 },
            "description": "Spoken or written language. Repeat the parameter or use comma-separated values."
          },
          {
            "name": "spoken_language",
            "in": "query",
            "schema": { "type": "string", "maxLength": 40 },
            "description": "Required spoken language. Repeat the parameter or use comma-separated values."
          },
          {
            "name": "written_language",
            "in": "query",
            "schema": { "type": "string", "maxLength": 40 },
            "description": "Required written language. Repeat the parameter or use comma-separated values."
          },
          {
            "name": "latitude",
            "in": "query",
            "schema": { "type": "number", "minimum": -90, "maximum": 90 }
          },
          {
            "name": "longitude",
            "in": "query",
            "schema": { "type": "number", "minimum": -180, "maximum": 180 }
          },
          {
            "name": "radius_km",
            "in": "query",
            "schema": { "type": "number", "minimum": 0.1, "maximum": 100 },
            "description": "Maximum straight-line distance; requires coordinates"
          },
          {
            "name": "open_now",
            "in": "query",
            "schema": { "type": "boolean" },
            "description": "Set true to include only records currently shown as open"
          },
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": ["name", "distance", "rating"]
            }
          },
          {
            "name": "order",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": ["asc", "desc"]
            },
            "description": "Defaults to desc for rating and asc for other sorts"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1500,
              "default": 20
            },
            "description": "Use 100 or fewer for normal agent queries"
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100000,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Directory results",
            "headers": {
              "RateLimit-Limit": { "schema": { "type": "integer" } },
              "RateLimit-Remaining": { "schema": { "type": "integer" } },
              "RateLimit-Reset": { "schema": { "type": "integer" } },
              "X-Request-Id": { "schema": { "type": "string", "format": "uuid" } }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/SearchResponse" }
              }
            }
          },
          "400": {
            "description": "Invalid query",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          },
          "500": {
            "description": "Directory temporarily unavailable",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Commissioner": {
        "type": "object",
        "required": ["id", "serial_number", "type", "name", "firm_name", "firm_and_address", "address", "postal_code", "telephone", "phone", "email", "services", "service_type", "spoken_languages", "written_languages", "latitude", "longitude", "google_rating", "google_reviews_count", "website", "profile_url", "canonical_url", "open_now"],
        "additionalProperties": false,
        "properties": {
          "id": { "type": "string" },
          "serial_number": { "type": "integer" },
          "type": { "type": "string", "enum": ["CO", "NP", "BOTH"] },
          "name": { "type": "string" },
          "firm_name": { "type": "string" },
          "firm_and_address": { "type": "string" },
          "address": { "type": "string" },
          "postal_code": { "type": "string" },
          "telephone": { "type": "string" },
          "phone": { "type": "string" },
          "email": { "type": "string", "description": "Reserved compatibility field; currently empty." },
          "services": { "type": "array", "items": { "type": "string" } },
          "service_type": { "type": "string", "enum": ["commissioner", "notary", "both"] },
          "spoken_languages": { "type": "array", "items": { "type": "string" } },
          "written_languages": { "type": "array", "items": { "type": "string" } },
          "latitude": { "type": "number" },
          "longitude": { "type": "number" },
          "distance_km": { "type": "number" },
          "coordinates_estimated": { "type": "boolean" },
          "google_place_id": { "type": "string" },
          "google_rating": { "type": ["number", "null"] },
          "google_reviews_count": { "type": "integer" },
          "google_opening_hours": { "type": "object", "additionalProperties": true },
          "website": { "type": ["string", "null"], "format": "uri" },
          "last_rating_update": { "type": "string", "format": "date-time" },
          "updated_at": { "type": "string", "format": "date-time" },
          "profile_url": { "type": "string", "format": "uri" },
          "canonical_url": { "type": "string", "format": "uri" },
          "open_now": { "type": "boolean" }
        }
      },
      "SearchResponse": {
        "type": "object",
        "required": ["metadata", "statistics", "pagination", "data"],
        "additionalProperties": false,
        "properties": {
          "metadata": {
            "type": "object",
            "required": ["source", "url", "extraction_date", "description", "last_update", "api_version", "request_id", "total_records", "terms_url"],
            "additionalProperties": false,
            "properties": {
              "source": { "type": "string" },
              "url": { "type": "string", "format": "uri" },
              "extraction_date": { "type": "string" },
              "description": { "type": "string" },
              "last_update": {
                "type": "object",
                "required": ["timestamp"],
                "additionalProperties": false,
                "properties": {
                  "timestamp": { "type": "string" }
                }
              },
              "api_version": { "type": "string" },
              "request_id": { "type": "string", "format": "uuid" },
              "total_records": { "type": "integer" },
              "terms_url": { "type": "string", "format": "uri" }
            }
          },
          "statistics": {
            "type": "object",
            "required": ["total", "commissioners_only", "notaries_only", "both_services", "total_commissioners", "total_notaries", "with_ratings", "with_websites"],
            "additionalProperties": false,
            "properties": {
              "total": { "type": "integer" },
              "commissioners_only": { "type": "integer" },
              "notaries_only": { "type": "integer" },
              "both_services": { "type": "integer" },
              "total_commissioners": { "type": "integer" },
              "total_notaries": { "type": "integer" },
              "with_ratings": { "type": "integer" },
              "with_websites": { "type": "integer" }
            }
          },
          "pagination": {
            "type": "object",
            "required": ["total", "limit", "offset", "has_more"],
            "additionalProperties": false,
            "properties": {
              "total": { "type": "integer" },
              "limit": { "type": "integer" },
              "offset": { "type": "integer" },
              "has_more": { "type": "boolean" }
            }
          },
          "data": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/Commissioner" }
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "required": ["error", "request_id"],
        "additionalProperties": false,
        "properties": {
          "error": {
            "type": "object",
            "required": ["code", "message"],
            "additionalProperties": false,
            "properties": {
              "code": { "type": "string" },
              "message": { "type": "string" },
              "details": {}
            }
          },
          "request_id": { "type": "string", "format": "uuid" }
        }
      }
    }
  }
}
