Overview

Graph Countries API provides rich country data including currencies, languages, flags, bordering countries, and regional groupings via GraphQL. It is completely free with no authentication required, making it ideal for learning or building geography-based features. Send a GraphQL query to retrieve exactly the fields you need.

Beginner Tip

This API uses GraphQL instead of REST, so you send a POST request with a JSON body containing your query. Use the GraphQL playground at the GitHub project to explore available fields before writing code.

Available Data

The kind of data this API exposes, based on its documentation. We could not call the endpoint to confirm the exact field names.

translated text
source language
target language
confidence score
country name and code
population

Example Response

Illustrative shape only — we were not able to call this endpoint (it requires credentials or exposes no public sample URL), so the fields below show the kind of data this API returns rather than a recorded response.

JSON Response · Illustrative
{
  "name": "Japan",
  "capital": "Tokyo",
  "population": 125800000,
  "region": "Asia",
  "languages": [
    "Japanese"
  ],
  "flag": "https://flagcdn.com/jp.svg",
  "currencies": [
    {
      "code": "JPY",
      "name": "Japanese yen"
    }
  ]
}

Field Reference

data Top-level GraphQL response containing your requested data.
data.country.name The full English name of the country.
data.country.capital The capital city of the country.
data.country.currency Currency code used in the country, e.g. USD, EUR.
data.country.languages List of language objects with name and native name fields.
data.country.emoji Flag emoji representing the country.

Implementation Example

Calls a real endpoint of this API. Replace any placeholder credentials with your own key.

Request
const url = "https://countries.trevorblades.com/graphql";
const response = await fetch(url);
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data);

What Can You Build?

Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.

Common Errors & Troubleshooting

Generated guidance based on this API's documentation, not observed by us. Treat it as a starting point and check against the provider's own error reference.

400 Bad Request Malformed GraphQL query syntax or missing required fields.
Validate your query in the GraphQL playground. Ensure you use double quotes inside the query and escape them correctly in shell.
null field value Requested a field that is not available for a particular country.
Check the schema in the playground to see which fields are available. Handle null values gracefully in your code.
Network Error / CORS Browser-side requests may be blocked depending on the endpoint used.
Use server-side requests or look for an alternative REST mirror of this dataset if CORS is an issue.

Metadata Score Breakdown

Estimated from metadata — endpoint not independently tested

This score is estimated from observable metadata — HTTPS support, authentication model, declared CORS, and documentation reachability — because the API requires authentication or exposes no publicly testable endpoint. The five-signal breakdown is only shown for live-tested APIs.

Metadata estimate · endpoint not independently tested

Technical Specifications

Auth No Auth
HTTPS REQUIRED
CORS UNKNOWN
Category Geocoding
Difficulty Beginner
Listing details not endpoint-verified

Related Tags

Similar APIs

View All →