{"id":13624079,"url":"https://github.com/trevorblades/countries","last_synced_at":"2025-04-04T19:12:09.728Z","repository":{"id":35335682,"uuid":"152529586","full_name":"trevorblades/countries","owner":"trevorblades","description":"🌎 Public GraphQL API for information about countries","archived":false,"fork":false,"pushed_at":"2024-01-03T21:29:49.000Z","size":1974,"stargazers_count":489,"open_issues_count":5,"forks_count":69,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-03-28T18:14:25.020Z","etag":null,"topics":["api","apollo","continents","countries","free","graphql","graphql-api","languages","provinces","public","public-api","schema","states"],"latest_commit_sha":null,"homepage":"https://countries.trevorblades.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trevorblades.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-11T04:08:50.000Z","updated_at":"2025-03-20T12:42:48.000Z","dependencies_parsed_at":"2023-01-15T18:36:57.337Z","dependency_job_id":"89864b4f-a735-4c75-9c5b-19d9dd89b30b","html_url":"https://github.com/trevorblades/countries","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trevorblades%2Fcountries","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trevorblades%2Fcountries/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trevorblades%2Fcountries/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trevorblades%2Fcountries/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trevorblades","download_url":"https://codeload.github.com/trevorblades/countries/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247234923,"owners_count":20905854,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","apollo","continents","countries","free","graphql","graphql-api","languages","provinces","public","public-api","schema","states"],"created_at":"2024-08-01T21:01:38.624Z","updated_at":"2025-04-04T19:12:09.711Z","avatar_url":"https://github.com/trevorblades.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./logo.png\" alt=\"globe\" width=\"150\"\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003eCountries GraphQL API\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![Build Status](https://github.com/trevorblades/countries/workflows/Node%20CI/badge.svg)](https://github.com/trevorblades/countries/actions)\n[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)\n[![Twitter Follow](https://img.shields.io/twitter/follow/trevorblades?style=social)](https://twitter.com/trevorblades)\n\n\u003c/div\u003e\n\nA public GraphQL API for information about countries, continents, and languages. This project uses [Countries List](https://annexare.github.io/Countries/) and [`provinces`](https://www.npmjs.com/package/provinces) as data sources, so the schema follows the shape of that data, with a few exceptions:\n\n1. The codes used to key the objects in the original data are available as a `code` property on each item returned from the API.\n1. The `Country.continent` and `Country.languages` are now objects and arrays of objects, respectively.\n1. The `Country.currency` and `Country.phone` fields _sometimes_ return a comma-separated list of values. For this reason, this API also exposes `currencies` and `phones` fields that are arrays of all currencies and phone codes for a country.\n1. Each `Country` has an array of `states` populated by their states/provinces, if any.\n1. Each `Country` also has an `awsRegion` field that shows its nearest AWS region, powered by [`country-to-aws-region`](https://github.com/Zeryther/country-to-aws-region).\n\n## Writing queries\n\n```graphql\nquery GetCountry {\n  country(code: \"BR\") {\n    name\n    native\n    capital\n    emoji\n    currency\n    languages {\n      code\n      name\n    }\n  }\n}\n```\n\nThe above GraphQL query will produce the following JSON response:\n\n```json\n{\n  \"data\": {\n    \"country\": {\n      \"name\": \"Brazil\",\n      \"native\": \"Brasil\",\n      \"capital\": \"Brasília\",\n      \"emoji\": \"🇧🇷\",\n      \"currency\": \"BRL\",\n      \"languages\": [\n        {\n          \"code\": \"pt\",\n          \"name\": \"Portuguese\"\n        }\n      ]\n    }\n  }\n}\n```\n\nCheck out [the playground](https://countries.trevorblades.com) to explore the schema and test out some queries.\n\n## Filtering\n\nThe `countries`, `continents`, and `languages` top-level `Query` fields accept an optional `filter` argument that causes results to be filtered on one or more subfields. The `continents` and `languages` fields can be filtered by their `code`, while `countries` can be filtered by `code`, `currency`, or `continent`.\n\n\u003e Note: The `continent` filter on the `Query.countries` field must be the continent code, i.e. \"SA\" for South America.\n\nThe filtering logic is powered by [sift](https://github.com/crcn/sift.js) and this API supports the following operators: `eq`, `ne`, `in`, `nin`, and `regex`. To learn more about these operators and how they work, check out [the sift docs](https://github.com/crcn/sift.js#supported-operators).\n\nHere are some examples of filtering that you can copy and paste into [the playground](https://countries.trevorblades.com) to try for yourself:\n\n```graphql\nquery ListCountriesThatUseUSD {\n  countries(filter: { currency: { eq: \"USD\" } }) {\n    code\n    name\n  }\n}\n\nquery ListCountriesInNAFTA {\n  countries(filter: { code: { in: [\"US\", \"CA\", \"MX\"] } }) {\n    code\n    name\n    languages {\n      name\n    }\n  }\n}\n\nquery ListCountriesThatBeginWithTheLetterA {\n  countries(filter: { name: { regex: \"^A\" } }) {\n    code\n    name\n    currency\n  }\n}\n```\n\n## Examples\n\n- [React](./examples/react)\n- [React Native](https://github.com/muhzi4u/country-directory-app)\n- [ReasonML](https://medium.com/@idkjs/reasonml-and-graphql-without-graphql-part-1-192c2e9e349c)\n- [Country quiz app](https://github.com/byrichardpowell/Country-Quiz) (React, TypeScript)\n- [Python](./examples/python)\n- [Seed](https://github.com/seed-rs/seed/tree/master/examples/graphql)\n- [Country Searcher](https://github.com/FranP-code/country-searcher)\n\n## License\n\n[MIT](./LICENSE)\n\n[![Powered by Stellate, the GraphQL API Management platform](https://stellate.co/badge.svg)](https://stellate.co/?ref=powered-by)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrevorblades%2Fcountries","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrevorblades%2Fcountries","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrevorblades%2Fcountries/lists"}