{
  "openapi": "3.1.0",
  "info": {
    "title": "ProyektoPH public API",
    "version": "1.0.0",
    "summary": "Read-only JSON for DPWH infrastructure projects, contractors and local officials.",
    "description": "DPWH data from the DPWH Transparency Portal, as published. Citizen posts are never returned, only counted, and are not verified. No ratings. Cite as: ProyektoPH, data from the DPWH Transparency Portal as of the source.data_date in each response. No key needed. Rate limit: 60 requests burst, then 1 per second per IP.",
    "contact": {
      "name": "ProyektoPH",
      "url": "https://proyektoph.com/contact"
    }
  },
  "externalDocs": {
    "description": "Developer guide",
    "url": "https://proyektoph.com/developers"
  },
  "servers": [
    {
      "url": "https://proyektoph.com/api/v1"
    }
  ],
  "paths": {
    "/projects": {
      "get": {
        "operationId": "searchProjects",
        "summary": "Search and filter projects",
        "description": "Same results and order as the project table on the home page. 50 results per page.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Search text: place, contract ID, contractor or words in the description"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "Completed",
                "On-Going",
                "Not Yet Started",
                "For Procurement",
                "Terminated"
              ]
            }
          },
          {
            "name": "overdue",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            },
            "description": "Projected completion before today (Manila) and progress under 100%"
          },
          {
            "name": "prov",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Province PSGC code (Metro Manila: 1300000000)"
          },
          {
            "name": "city",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "City or municipality PSGC code (needs prov)"
          },
          {
            "name": "brgy",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Barangay PSGC code (needs city)"
          },
          {
            "name": "admin",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "aquino",
                "duterte",
                "marcos",
                "none"
              ]
            },
            "description": "Administration in office at award"
          },
          {
            "name": "outcome",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "ontime",
                "late",
                "pastdue",
                "terminated",
                "below"
              ]
            }
          },
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "DPWH category, e.g. Roads"
          },
          {
            "name": "year",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Infra year, e.g. 2024"
          },
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "budget",
                "start",
                "end",
                "progress",
                "location",
                "project"
              ]
            }
          },
          {
            "name": "dir",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ]
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2000,
              "default": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page of projects",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProjectList"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests (60 burst, then 1 per second per IP). See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/projects/{contract_id}": {
      "get": {
        "operationId": "getProject",
        "summary": "One project",
        "description": "DPWH facts, ProyektoPH location match, local officials in office at the time (public records, with sources) and citizen post counts. Add format=md for Markdown.",
        "parameters": [
          {
            "name": "contract_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9-]{4,24}$"
            },
            "example": "23HN0016"
          },
          {
            "name": "format",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "json",
                "md"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Project record",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Project"
                }
              },
              "text/markdown": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests (60 burst, then 1 per second per IP). See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/contractors/{pcab_id}": {
      "get": {
        "operationId": "getContractor",
        "summary": "One contractor by PCAB license number",
        "parameters": [
          {
            "name": "pcab_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "22729"
          }
        ],
        "responses": {
          "200": {
            "description": "Contractor with contracts won",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contractor"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests (60 burst, then 1 per second per IP). See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/officials/{id}": {
      "get": {
        "operationId": "getOfficial",
        "summary": "One local official term record",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "example": 109748
          }
        ],
        "responses": {
          "200": {
            "description": "Official term on record with source",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Official"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests (60 burst, then 1 per second per IP). See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "status": {
                "type": "integer"
              },
              "message": {
                "type": "string"
              }
            }
          },
          "docs": {
            "type": "string"
          }
        }
      },
      "Source": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "publisher": {
            "type": "string"
          },
          "data_date": {
            "type": "string",
            "format": "date"
          },
          "data_date_label": {
            "type": "string"
          },
          "note": {
            "type": "string"
          },
          "cite_as": {
            "type": "string"
          }
        }
      },
      "ProjectSummary": {
        "type": "object",
        "properties": {
          "contract_id": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "api_url": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": [
              "string",
              "null"
            ]
          },
          "progress_percent": {
            "type": [
              "number",
              "null"
            ]
          },
          "contract_amount_php": {
            "type": [
              "number",
              "null"
            ]
          },
          "region": {
            "type": [
              "string",
              "null"
            ]
          },
          "province": {
            "type": [
              "string",
              "null"
            ]
          },
          "implementing_office": {
            "type": [
              "string",
              "null"
            ]
          },
          "start_date": {
            "type": [
              "string",
              "null"
            ]
          },
          "expiry_date": {
            "type": [
              "string",
              "null"
            ]
          },
          "completion_date": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "ProjectList": {
        "type": "object",
        "properties": {
          "api_version": {
            "type": "string"
          },
          "source": {
            "$ref": "#/components/schemas/Source"
          },
          "query": {
            "type": "object"
          },
          "total": {
            "type": "integer"
          },
          "page": {
            "type": "integer"
          },
          "page_count": {
            "type": "integer"
          },
          "per_page": {
            "type": "integer"
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProjectSummary"
            }
          },
          "links": {
            "type": "object",
            "properties": {
              "self": {
                "type": "string"
              },
              "next": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "web": {
                "type": "string"
              }
            }
          }
        }
      },
      "Project": {
        "type": "object",
        "properties": {
          "api_version": {
            "type": "string"
          },
          "source": {
            "$ref": "#/components/schemas/Source"
          },
          "contract_id": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "markdown_url": {
            "type": "string"
          },
          "dpwh": {
            "type": "object",
            "description": "DPWH data as published"
          },
          "derived": {
            "type": "object",
            "description": "Administration and outcome computed from DPWH dates"
          },
          "location_match": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "place": {
                "type": "string"
              },
              "method": {
                "type": "string"
              },
              "confidence": {
                "type": "string"
              }
            }
          },
          "officials_in_office": {
            "type": "object",
            "description": "Public records; being in office does not mean an official approved, funded or ran the project"
          },
          "citizen_posts": {
            "type": "object",
            "description": "Counts only, not verified",
            "properties": {
              "total": {
                "type": "integer"
              },
              "status_reports": {
                "type": "integer"
              },
              "comments": {
                "type": "integer"
              },
              "by_observed_status": {
                "type": "object"
              },
              "read_them_at": {
                "type": "string"
              }
            }
          }
        }
      },
      "Contractor": {
        "type": "object",
        "properties": {
          "api_version": {
            "type": "string"
          },
          "source": {
            "$ref": "#/components/schemas/Source"
          },
          "pcab_id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "other_names": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "url": {
            "type": "string"
          },
          "dpwh": {
            "type": "object"
          }
        }
      },
      "Official": {
        "type": "object",
        "properties": {
          "api_version": {
            "type": "string"
          },
          "source": {
            "type": "object"
          },
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "office": {
            "type": "string"
          },
          "office_key": {
            "type": "string"
          },
          "area": {
            "type": "string"
          },
          "area_detail": {
            "type": [
              "string",
              "null"
            ]
          },
          "term_start": {
            "type": "string"
          },
          "term_end": {
            "type": [
              "string",
              "null"
            ]
          },
          "party": {
            "type": [
              "string",
              "null"
            ]
          },
          "url": {
            "type": "string"
          },
          "record": {
            "type": "object"
          },
          "terms_on_record": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      }
    }
  }
}