example-data.com
Menu
Browse docs and collections

Overview

countries / #2

Canada

CA

Capital: Ottawa · Region: Americas

Component variants

Request

curl example

curl -sS \
  "https://example-data.com/api/v1/countries/2" \
  -H "Accept: application/json"

JavaScript example

const res = await fetch(
  "https://example-data.com/api/v1/countries/2"
);
const country = await res.json();

TypeScript example

// Download once: mkdir -p types && curl -o types/countries.d.ts https://example-data.com/types/countries.d.ts
import type { Country } from "./types/countries";

const res = await fetch(
  "https://example-data.com/api/v1/countries/2"
);
const country = (await res.json()) as Country;

Python example

import requests

res = requests.get(
    "https://example-data.com/api/v1/countries/2"
)
countrie = res.json()

Response

{
  "id": 2,
  "name": "Canada",
  "alpha2": "CA",
  "alpha3": "CAN",
  "numericCode": "124",
  "capital": "Ottawa",
  "region": "Americas",
  "subregion": "Northern America",
  "currencyCode": "CAD",
  "callingCode": "+1",
  "flagEmoji": "🇨🇦"
}