mikesol / countries

🌎 Public GraphQL API for information about countries

Home Page:https://countries.trevorblades.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

globe

Countries GraphQL API

Build Status Contributor Covenant Twitter Follow

A public GraphQL API for information about countries, continents, and languages. This project uses Countries List and provinces as data sources, so the schema follows the shape of that data, with a few exceptions:

  1. The codes used to key the objects in the original data are available as a code property on each item returned from the API.
  2. The country.continent and country.languages are now objects and arrays of objects, respectively.
  3. Each Country has an array of states populated by their states/provinces, if any.

Writing queries

{
  country(code: "BR") {
    name
    native
    capital
    emoji
    currency
    languages {
      code
      name
    }
  }
}

The above GraphQL query will produce the following JSON response:

{
  "data": {
    "country": {
      "name": "Brazil",
      "native": "Brasil",
      "capital": "Brasília",
      "emoji": "🇧🇷",
      "currency": "BRL",
      "languages": [
        {
          "code": "pt",
          "name": "Portuguese"
        }
      ]
    }
  }
}

Docs

Check out the playground to explore the schema and test out some queries.

Examples

License

MIT

About

🌎 Public GraphQL API for information about countries

https://countries.trevorblades.com

License:MIT License


Languages

Language:JavaScript 100.0%