The Learn Geo API is free to use for anyone. It allows users to get details about the countries of the world by region, country, population, or even at random.
To retrieve the information about the countries make a get request to the url:
https://learn-geo-api.onrender.com/
a request to the home endpoint will return all countries of the world as an array of objects with the properties name, capital, longitude, latitude, population, code (ISO code), and continent.
To retrieve by region use the following endpoints.
Region | endpoint |
---|---|
North America | /na |
South America | /sa |
Europe | /eu |
Asia | /as |
Africa | /af |
Oceania | /oc |
To retrieve an individual country by name specify the endpoint /name/country where country is the country you need the information from. An example of a retrieving Austria would be /countries/Austria. The name of the country is not case sensitive.
To retrieve by capital specify the endpoint /capital/capital name where capital name is the capital of the country you need the information from. An example of retrieving Paris would be /capital/Paris. The name of the capital is not case sensitive.
To retrieve by population you can specify the endpoint /population/comparison/amount. comparison can be either greater or lesser. Amount is the population threshold for retrieving all countries with a population greater or lesser than that amount. To retrieve all the countries with less than 1 million population you would specify the endpoint, /population/less/1000000.
To retrieve countries at random use the endpoint /random/amount, where amount is the amount of random countries you want to receive. To receive 5 random countries you would specify the endpoint, /random/5.