Countries Now API
countriesnow.space · Data
Country data with cities — list all countries, get cities for a country, state data, country flags, population, and ISO codes. Free, no API key.
Authentication
No authentication requiredFree to use with no key needed.
Sample Requests
GET
Get countries
Get all countries with their cities.
https://countriesnow.space/api/v0.1/countries
Hover any highlighted part to learn what it does
curl -X GET "https://countriesnow.space/api/v0.1/countries"
import requests
response = requests.get(
"https://countriesnow.space/api/v0.1/countries",
)
print(response.json())const url = 'https://countriesnow.space/api/v0.1/countries'; const response = await fetch(url); const data = await response.json(); console.log(data);
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
targetURL := "https://countriesnow.space/api/v0.1/countries"
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://countriesnow.space/api/v0.1/countries")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://countriesnow.space/api/v0.1/countries";
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));
POST
Get cities for country
Get all cities in the United States.
https://countriesnow.space/api/v0.1/countries/cities
Hover any highlighted part to learn what it does
Headers — extra info sent with the request
| Content-Type | application/json |
Request Body — data you're sending
{
"country": "United States"
}
curl -X POST "https://countriesnow.space/api/v0.1/countries/cities" \
-H "Content-Type: application/json" \
-H "Content-Type: application/json" \
-d '{"country":"United States"}'import requests
headers = {
"Content-Type": "application/json"
}
data = {
"country": "United States"
}
response = requests.post(
"https://countriesnow.space/api/v0.1/countries/cities",
headers=headers,
json=data,
)
print(response.json())const url = 'https://countriesnow.space/api/v0.1/countries/cities';
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
"country": "United States"
}),
});
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"bytes"
"encoding/json"
)
func main() {
targetURL := "https://countriesnow.space/api/v0.1/countries/cities"
jsonData, _ := json.Marshal({"country":"United States"})
req, _ := http.NewRequest("POST", targetURL, bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://countriesnow.space/api/v0.1/countries/cities")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Post.new(uri)
req["Content-Type"] = "application/json"
req["Content-Type"] = "application/json"
req.body = "{\"country\":\"United States\"}"
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://countriesnow.space/api/v0.1/countries/cities";
$opts = ["http" => [
"method" => "POST",
"header" => implode("\r\n", [
"Content-Type: application/json",
"Content-Type: application/json"
]),
"content" => json_encode({"country":"United States"}),
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Postman Setup Guide
- No API key needed
- All countries: GET https://countriesnow.space/api/v0.1/countries/iso
- Cities for country: POST /countries/cities with {"country":"Canada"}
- Country flag: POST /countries/flag/images with {"country":"Germany"}
- States: POST /countries/states with {"country":"Australia"}