{
"success": true,
"data": {
"geo": {
"continent": "North America",
"continent_code": "NA",
"continent_geo_name_id": 6255149,
"country": "United States",
"country_code": "US",
"country_geo_name_id": 6252001,
"capital": "Washington, D.C.",
"population": 331002651,
"phone": "1",
"is_eu": false,
"neighbours": "CA,MX,PM",
"tld": ".us"
},
"language": {
"name": "English",
"code": "en",
"native": "English"
},
"currency": {
"name": "United States Dollar",
"code": "USD",
"symbol": "$"
},
"flag": {
"emoji": "🇺🇸",
"unicode": "U+1F1FA U+1F1F8",
"png": {
"1000px": "https://greip.io/img/flags/png1000px/us.png",
"250px": "https://greip.io/img/flags/png250px/us.png",
"100px": "https://greip.io/img/flags/png100px/us.png"
},
"svg": "https://greip.io/img/flags/svg/us.svg"
},
"custom_rules_applied": { "total": 0, "rules": [] }
},
"execution_ms": 0
}
{
"success": false,
"code": 101,
"type": "invalid_key",
"description": "The API Key is missing or invalid."
}
Country data
curl --request GET \
--url https://v2.greipapi.com/lookup/countries/{country_code} \
--header 'Authorization: Bearer <token>'import requests
url = "https://v2.greipapi.com/lookup/countries/{country_code}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://v2.greipapi.com/lookup/countries/{country_code}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://v2.greipapi.com/lookup/countries/{country_code}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://v2.greipapi.com/lookup/countries/{country_code}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://v2.greipapi.com/lookup/countries/{country_code}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://v2.greipapi.com/lookup/countries/{country_code}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body
{
"success": true,
"data": {
"geo": {
"continent": "North America",
"continent_code": "NA",
"continent_geo_name_id": 6255149,
"country": "United States",
"country_code": "US",
"country_geo_name_id": 6252001,
"capital": "Washington, D.C.",
"population": 331002651,
"phone": "1",
"is_eu": false,
"neighbours": "CA,MX,PM",
"tld": ".us"
},
"language": {
"name": "English",
"code": "en",
"native": "English"
},
"currency": {
"name": "United States Dollar",
"code": "USD",
"symbol": "$"
},
"flag": {
"emoji": "🇺🇸",
"unicode": "U+1F1FA U+1F1F8",
"png": {
"1000px": "https://greip.io/img/flags/png1000px/us.png",
"250px": "https://greip.io/img/flags/png250px/us.png",
"100px": "https://greip.io/img/flags/png100px/us.png"
},
"svg": "https://greip.io/img/flags/svg/us.svg"
},
"custom_rules_applied": { "total": 0, "rules": [] }
},
"execution_ms": 0
}
{
"success": false,
"code": 101,
"type": "invalid_key",
"description": "The API Key is missing or invalid."
}
Data Lookup
Country Data
This method allows you to retrieve detailed information about a country by providing its country code in the request.
The API returns valuable data, such as the country’s name, capital, population, region, and other relevant attributes, enabling you to enrich your applications with geographic context and enhance user experiences.
{
"success": true,
"data": {
"geo": {
"continent": "North America",
"continent_code": "NA",
"continent_geo_name_id": 6255149,
"country": "United States",
"country_code": "US",
"country_geo_name_id": 6252001,
"capital": "Washington, D.C.",
"population": 331002651,
"phone": "1",
"is_eu": false,
"neighbours": "CA,MX,PM",
"tld": ".us"
},
"language": {
"name": "English",
"code": "en",
"native": "English"
},
"currency": {
"name": "United States Dollar",
"code": "USD",
"symbol": "$"
},
"flag": {
"emoji": "🇺🇸",
"unicode": "U+1F1FA U+1F1F8",
"png": {
"1000px": "https://greip.io/img/flags/png1000px/us.png",
"250px": "https://greip.io/img/flags/png250px/us.png",
"100px": "https://greip.io/img/flags/png100px/us.png"
},
"svg": "https://greip.io/img/flags/svg/us.svg"
},
"custom_rules_applied": { "total": 0, "rules": [] }
},
"execution_ms": 0
}
{
"success": false,
"code": 101,
"type": "invalid_key",
"description": "The API Key is missing or invalid."
}
GET
/
lookup
/
countries
/
{country_code}
Country data
curl --request GET \
--url https://v2.greipapi.com/lookup/countries/{country_code} \
--header 'Authorization: Bearer <token>'import requests
url = "https://v2.greipapi.com/lookup/countries/{country_code}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://v2.greipapi.com/lookup/countries/{country_code}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://v2.greipapi.com/lookup/countries/{country_code}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://v2.greipapi.com/lookup/countries/{country_code}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://v2.greipapi.com/lookup/countries/{country_code}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://v2.greipapi.com/lookup/countries/{country_code}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body
{
"success": true,
"data": {
"geo": {
"continent": "North America",
"continent_code": "NA",
"continent_geo_name_id": 6255149,
"country": "United States",
"country_code": "US",
"country_geo_name_id": 6252001,
"capital": "Washington, D.C.",
"population": 331002651,
"phone": "1",
"is_eu": false,
"neighbours": "CA,MX,PM",
"tld": ".us"
},
"language": {
"name": "English",
"code": "en",
"native": "English"
},
"currency": {
"name": "United States Dollar",
"code": "USD",
"symbol": "$"
},
"flag": {
"emoji": "🇺🇸",
"unicode": "U+1F1FA U+1F1F8",
"png": {
"1000px": "https://greip.io/img/flags/png1000px/us.png",
"250px": "https://greip.io/img/flags/png250px/us.png",
"100px": "https://greip.io/img/flags/png100px/us.png"
},
"svg": "https://greip.io/img/flags/svg/us.svg"
},
"custom_rules_applied": { "total": 0, "rules": [] }
},
"execution_ms": 0
}
{
"success": false,
"code": 101,
"type": "invalid_key",
"description": "The API Key is missing or invalid."
}
Authentication
Include your API key in theAuthorization header:
Authorization: Bearer <api_key>
Path parameters
string
required
The
ISO 3166-1 alpha-2 format of the country code. Learn moreSample value: GBQuery parameters
string
The params command is used to determine the data you need in the response.Expected values:
language, flag, currency, and/or timezone.Sample value: language,currency,timezonestring
default:"JSON"
The format command is used to get a response in a specific format.Expected values:
JSON, XML, CSV, or NewlineFor more information please refer to Response format.string
default:"live"
The mode command is used in the development stage to simulate the integration process before releasing it to the production environment.Expected values:
live, or test.For more information please refer to Development environment.string
Optional label for your own analytics or support correlation (for example a product or channel name).
string
The user_id command can be used to identify requests sent by specific users to monitor in the Events page.Expected values: email address, phone number, user id, name, etc.For more information please refer to User identifier.
Response properties
boolean
required
true when the request succeeded; false on error.object
required
Hide properties
Hide properties
object
required
Core country attributes (always present when the country code is valid).
Hide properties
Hide properties
string
Localized continent name.
string
Continent code.
integer
GeoName ID of the continent.
string
Localized country name.
string
required
ISO 3166-1 alpha-2 country code from the path.
integer
GeoName ID of the country.
string
Capital city.
integer
Population.
string
International dialing code.
boolean
Whether the country is in the EU.
string
Comma-separated neighbour country codes.
string
Country top-level domain (for example
.us).object
integer
required
Time taken to process the request (milliseconds).
Was this page helpful?