{
  "components": {
    "schemas": {
      "CountriesSearchResponse": {
        "properties": {
          "query": {
            "type": "string"
          },
          "results": {
            "items": {
              "$ref": "#/components/schemas/CountryListItem"
            },
            "type": "array"
          },
          "success": {
            "type": "boolean"
          },
          "version": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "Country": {
        "properties": {
          "age_structure": {
            "additionalProperties": true,
            "type": "object"
          },
          "air_pollutants": {
            "additionalProperties": true,
            "type": "object"
          },
          "airports": {
            "type": "string"
          },
          "area_total": {
            "type": "string"
          },
          "birth_rate": {
            "type": "string"
          },
          "broadband_subscriptions": {
            "type": "string"
          },
          "capital": {
            "type": "string"
          },
          "climate": {
            "type": "string"
          },
          "coordinates": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "death_rate": {
            "type": "string"
          },
          "economic_overview": {
            "type": "string"
          },
          "electricity_access": {
            "type": "string"
          },
          "electricity_generation_sources": {
            "additionalProperties": true,
            "type": "object"
          },
          "energy_consumption_per_capita": {
            "type": "string"
          },
          "environment_issues": {
            "type": "string"
          },
          "ethnic_groups": {
            "type": "string"
          },
          "exports": {
            "type": "string"
          },
          "flag_url": {
            "format": "uri",
            "type": "string"
          },
          "gdp_per_capita": {
            "type": "string"
          },
          "gec_code": {
            "type": "string"
          },
          "government_type": {
            "type": "string"
          },
          "imports": {
            "type": "string"
          },
          "independence_date": {
            "type": "string"
          },
          "internet_users": {
            "type": "string"
          },
          "iso_code": {
            "type": "string"
          },
          "languages": {
            "type": "string"
          },
          "life_expectancy": {
            "type": "string"
          },
          "literacy_rate": {
            "type": "string"
          },
          "location": {
            "type": "string"
          },
          "military_expenditure": {
            "type": "string"
          },
          "military_service_age": {
            "type": "string"
          },
          "mobile_phones": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "natural_resources": {
            "type": "string"
          },
          "official_name": {
            "type": "string"
          },
          "population": {
            "type": "string"
          },
          "ports": {
            "type": "string"
          },
          "railways": {
            "type": "string"
          },
          "religions": {
            "type": "string"
          },
          "unemployment_rate": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "CountryCodes": {
        "properties": {
          "flag_url": {
            "format": "uri",
            "type": "string"
          },
          "gec_code": {
            "type": "string"
          },
          "iso_code": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "CountryCodesResponse": {
        "properties": {
          "codes": {
            "$ref": "#/components/schemas/CountryCodes"
          },
          "country_code": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "success": {
            "type": "boolean"
          },
          "version": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "CountryField": {
        "oneOf": [
          {
            "type": "string"
          },
          {
            "type": "number"
          },
          {
            "type": "boolean"
          },
          {
            "additionalProperties": true,
            "type": "object"
          },
          {
            "items": {},
            "type": "array"
          },
          {
            "type": "null"
          }
        ]
      },
      "CountryFieldResponse": {
        "properties": {
          "country_code": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "path": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "success": {
            "type": "boolean"
          },
          "value": {
            "$ref": "#/components/schemas/CountryField"
          },
          "version": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "CountryListItem": {
        "properties": {
          "gec_code": {
            "type": "string"
          },
          "iso_code": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "CountryRawResponse": {
        "properties": {
          "country_code": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "raw": {
            "additionalProperties": true,
            "type": "object"
          },
          "success": {
            "type": "boolean"
          },
          "version": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "CountryResponse": {
        "properties": {
          "country": {
            "$ref": "#/components/schemas/Country"
          },
          "links": {
            "additionalProperties": {
              "type": "string"
            },
            "type": "object"
          },
          "success": {
            "type": "boolean"
          },
          "version": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "CountrySearchResponse": {
        "properties": {
          "country": {
            "type": "string"
          },
          "country_code": {
            "type": "string"
          },
          "query": {
            "type": "string"
          },
          "results": {
            "items": {
              "properties": {
                "path": {
                  "items": {
                    "type": "string"
                  },
                  "type": "array"
                },
                "value": {
                  "type": "string"
                }
              },
              "type": "object"
            },
            "type": "array"
          },
          "success": {
            "type": "boolean"
          },
          "version": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "CountrySection": {
        "additionalProperties": true,
        "type": "object"
      },
      "CountrySectionResponse": {
        "properties": {
          "country_code": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "section": {
            "$ref": "#/components/schemas/CountrySection"
          },
          "section_name": {
            "type": "string"
          },
          "success": {
            "type": "boolean"
          },
          "version": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "CountrySummary": {
        "properties": {
          "area_total": {
            "type": "string"
          },
          "capital": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "flag_url": {
            "format": "uri",
            "type": "string"
          },
          "gdp_per_capita": {
            "type": "string"
          },
          "gec_code": {
            "type": "string"
          },
          "government_type": {
            "type": "string"
          },
          "iso_code": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "official_name": {
            "type": "string"
          },
          "population": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "CountrySummaryResponse": {
        "properties": {
          "links": {
            "additionalProperties": {
              "type": "string"
            },
            "type": "object"
          },
          "success": {
            "type": "boolean"
          },
          "summary": {
            "$ref": "#/components/schemas/CountrySummary"
          },
          "version": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "ErrorResponse": {
        "properties": {
          "error": {
            "type": "string"
          },
          "success": {
            "type": "boolean"
          }
        },
        "type": "object"
      }
    }
  },
  "info": {
    "description": "Country-level CIA World Factbook data with JSON and curl-friendly text endpoints.",
    "title": "CountryPuff API",
    "version": "1.0.0"
  },
  "openapi": "3.0.3",
  "paths": {
    "/api/v1/countries": {
      "get": {
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "countries": {
                      "items": {
                        "$ref": "#/components/schemas/CountryListItem"
                      },
                      "type": "array"
                    },
                    "success": {
                      "type": "boolean"
                    },
                    "version": {
                      "type": "string"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Country catalog"
          }
        },
        "summary": "List available countries",
        "tags": [
          "JSON API"
        ]
      }
    },
    "/api/v1/countries/search": {
      "get": {
        "parameters": [
          {
            "example": "united",
            "in": "query",
            "name": "q",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CountriesSearchResponse"
                }
              }
            },
            "description": "Matching countries"
          }
        },
        "summary": "Search countries by name",
        "tags": [
          "JSON API"
        ]
      }
    },
    "/api/v1/country/{country_code}": {
      "get": {
        "parameters": [
          {
            "description": "ISO alpha-2, ISO alpha-3, GEC code, or country name.",
            "example": "US",
            "in": "path",
            "name": "country_code",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CountryResponse"
                }
              }
            },
            "description": "Country data"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Country not found"
          }
        },
        "summary": "Get country data as JSON",
        "tags": [
          "JSON API"
        ]
      }
    },
    "/api/v1/country/{country_code}/codes": {
      "get": {
        "parameters": [
          {
            "example": "US",
            "in": "path",
            "name": "country_code",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CountryCodesResponse"
                }
              }
            },
            "description": "Country codes"
          }
        },
        "summary": "Get code mappings for a country",
        "tags": [
          "JSON API"
        ]
      }
    },
    "/api/v1/country/{country_code}/field": {
      "get": {
        "parameters": [
          {
            "example": "US",
            "in": "path",
            "name": "country_code",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "example": "Government,Capital,name,text",
            "in": "query",
            "name": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CountryFieldResponse"
                }
              }
            },
            "description": "One nested field value"
          }
        },
        "summary": "Get a single nested field from a country record",
        "tags": [
          "JSON API"
        ]
      }
    },
    "/api/v1/country/{country_code}/flag": {
      "get": {
        "parameters": [
          {
            "description": "ISO alpha-2, ISO alpha-3, GEC code, or country name.",
            "example": "US",
            "in": "path",
            "name": "country_code",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "country_code": {
                      "type": "string"
                    },
                    "flag_url": {
                      "format": "uri",
                      "type": "string"
                    },
                    "iso_code": {
                      "type": "string"
                    },
                    "success": {
                      "type": "boolean"
                    },
                    "version": {
                      "type": "string"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Flag URL"
          }
        },
        "summary": "Get the flag source URL as JSON",
        "tags": [
          "JSON API"
        ]
      }
    },
    "/api/v1/country/{country_code}/raw": {
      "get": {
        "parameters": [
          {
            "example": "US",
            "in": "path",
            "name": "country_code",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CountryRawResponse"
                }
              }
            },
            "description": "Raw country JSON"
          }
        },
        "summary": "Get raw factbook JSON for a country",
        "tags": [
          "JSON API"
        ]
      }
    },
    "/api/v1/country/{country_code}/search": {
      "get": {
        "parameters": [
          {
            "example": "BR",
            "in": "path",
            "name": "country_code",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "example": "oil",
            "in": "query",
            "name": "q",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CountrySearchResponse"
                }
              }
            },
            "description": "Field matches in a country record"
          }
        },
        "summary": "Search within one country record",
        "tags": [
          "JSON API"
        ]
      }
    },
    "/api/v1/country/{country_code}/section/{section_name}": {
      "get": {
        "parameters": [
          {
            "example": "US",
            "in": "path",
            "name": "country_code",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "example": "Geography",
            "in": "path",
            "name": "section_name",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CountrySectionResponse"
                }
              }
            },
            "description": "One section of country data"
          }
        },
        "summary": "Get one top-level factbook section",
        "tags": [
          "JSON API"
        ]
      }
    },
    "/api/v1/country/{country_code}/summary": {
      "get": {
        "parameters": [
          {
            "example": "US",
            "in": "path",
            "name": "country_code",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CountrySummaryResponse"
                }
              }
            },
            "description": "Country summary"
          }
        },
        "summary": "Get a short country summary",
        "tags": [
          "JSON API"
        ]
      }
    },
    "/curl/v1/countries/search": {
      "get": {
        "parameters": [
          {
            "example": "united",
            "in": "query",
            "name": "q",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "Matching countries as plain text"
          }
        },
        "summary": "Search countries by name as plain text",
        "tags": [
          "Curl API"
        ]
      }
    },
    "/curl/v1/country/{country_code}": {
      "get": {
        "parameters": [
          {
            "example": "US",
            "in": "path",
            "name": "country_code",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "Plain text country data"
          }
        },
        "summary": "Get country data as plain text",
        "tags": [
          "Curl API"
        ]
      }
    },
    "/curl/v1/country/{country_code}/codes": {
      "get": {
        "parameters": [
          {
            "example": "US",
            "in": "path",
            "name": "country_code",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "Country codes"
          }
        },
        "summary": "Get code mappings as plain text",
        "tags": [
          "Curl API"
        ]
      }
    },
    "/curl/v1/country/{country_code}/field": {
      "get": {
        "parameters": [
          {
            "example": "US",
            "in": "path",
            "name": "country_code",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "example": "Government,Capital,name,text",
            "in": "query",
            "name": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "One nested field value"
          }
        },
        "summary": "Get one nested field as formatted plain text",
        "tags": [
          "Curl API"
        ]
      }
    },
    "/curl/v1/country/{country_code}/flag": {
      "get": {
        "parameters": [
          {
            "example": "US",
            "in": "path",
            "name": "country_code",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "Plain text flag URL"
          }
        },
        "summary": "Get the flag source URL as plain text",
        "tags": [
          "Curl API"
        ]
      }
    },
    "/curl/v1/country/{country_code}/raw": {
      "get": {
        "parameters": [
          {
            "example": "US",
            "in": "path",
            "name": "country_code",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "Raw country data"
          }
        },
        "summary": "Get raw factbook JSON as formatted plain text",
        "tags": [
          "Curl API"
        ]
      }
    },
    "/curl/v1/country/{country_code}/search": {
      "get": {
        "parameters": [
          {
            "example": "BR",
            "in": "path",
            "name": "country_code",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "example": "oil",
            "in": "query",
            "name": "q",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "Field matches in a country record"
          }
        },
        "summary": "Search within one country record as plain text",
        "tags": [
          "Curl API"
        ]
      }
    },
    "/curl/v1/country/{country_code}/section/{section_name}": {
      "get": {
        "parameters": [
          {
            "example": "US",
            "in": "path",
            "name": "country_code",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "example": "Geography",
            "in": "path",
            "name": "section_name",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "One section of country data"
          }
        },
        "summary": "Get one factbook section as formatted plain text",
        "tags": [
          "Curl API"
        ]
      }
    },
    "/curl/v1/country/{country_code}/summary": {
      "get": {
        "parameters": [
          {
            "example": "US",
            "in": "path",
            "name": "country_code",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "Country summary"
          }
        },
        "summary": "Get a short country summary as plain text",
        "tags": [
          "Curl API"
        ]
      }
    }
  },
  "servers": [
    {
      "url": "http://dev.countrypuff.org"
    }
  ],
  "tags": [
    {
      "description": "Structured API responses.",
      "name": "JSON API"
    },
    {
      "description": "Plain text responses for terminal use.",
      "name": "Curl API"
    }
  ]
}
