mirror of
https://gitlab.com/restcountries/restcountries.git
synced 2026-03-31 15:07:46 +01:00
Updating the public readme
This commit is contained in:
@@ -4,7 +4,7 @@ a subscription base API, this project is still Open Source and Free to use.
|
|||||||
|
|
||||||
## Important Information
|
## Important Information
|
||||||
* The structure of V2 has been reverted to its original form from the [Original Project] to maintain compatibility.
|
* The structure of V2 has been reverted to its original form from the [Original Project] to maintain compatibility.
|
||||||
* Only the latest version will receive updates and improvements.
|
* ***Only the latest version will receive updates and improvements.***
|
||||||
|
|
||||||
# REST Countries
|
# REST Countries
|
||||||
You can access API through https://restcountries.com/v3.1/all
|
You can access API through https://restcountries.com/v3.1/all
|
||||||
|
|||||||
@@ -5,66 +5,51 @@ Get information about countries via a RESTful API
|
|||||||
|
|
||||||
*Current version: 3.1*
|
*Current version: 3.1*
|
||||||
|
|
||||||
Donate!
|
# About this Project
|
||||||
---------------
|
|
||||||
We're getting about 1.6 millions hits each day and that means also bandwidth (25 GB per day!) so
|
|
||||||
costs have obviously increased. **Please**, consider making a [donation] to help me pay the server's
|
|
||||||
bills, you're welcome to [donate] or you can also
|
|
||||||
[buy me a coffee](https://www.buymeacoffee.com/amatos).
|
|
||||||
|
|
||||||
Changelog
|
This project is inspired on restcountries.eu by Fayder Florez. Although the original project has now
|
||||||
-----
|
moved to
|
||||||
- 19/10
|
a subscription base API, this project is still Open Source and Free to use.
|
||||||
- Added capital information (lat and long)
|
|
||||||
- Added postal code (format and regex)
|
|
||||||
|
|
||||||
* Previously
|
## Important Information
|
||||||
- Added population
|
|
||||||
- Added named object for `flags`
|
|
||||||
|
|
||||||
New in Version 3
|
* The structure of V2 has been reverted to its original form from the [Original Project] to maintain
|
||||||
-----------------
|
compatibility.
|
||||||
|
* ***Only the latest version will receive updates and improvements.***
|
||||||
|
|
||||||
Version 3 and 3.1 uses [this] project to get the country's structure and adds a couple of new features:
|
# REST Countries
|
||||||
|
|
||||||
- Search by translations
|
You can access API through https://restcountries.com/v3.1/all but in order to get a faster response,
|
||||||
- Search by language's name (not just language code)
|
you should filter the results by the fields you need.
|
||||||
- Search by currency's name (not just currency code)
|
Like
|
||||||
- Turning back from V2 to V3: continent to region and region to subregion
|
|
||||||
- Population
|
|
||||||
- Fifa code
|
|
||||||
- Added country's driving side
|
|
||||||
- Added country Distinguishing (oval) sign
|
|
||||||
|
|
||||||
In addition to those features, I added the flags (svg and png) to each country. Only latest version
|
``` html
|
||||||
will get new features (nodes) while *trying* to keep the same structure as previous versions.
|
https://restcountries.com/v3.1/all?fields=name,flags`
|
||||||
|
|
||||||
V3 vs V3.1
|
|
||||||
----------
|
|
||||||
|
|
||||||
V3.1 has a few more fields and also the flag node is different:
|
|
||||||
|
|
||||||
V3:
|
|
||||||
|
|
||||||
```json
|
|
||||||
"flags": [
|
|
||||||
"https://flagcdn.com/per.svg",
|
|
||||||
"https://flagcdn.com/w320/per.png"
|
|
||||||
]
|
|
||||||
```
|
```
|
||||||
V3.1:
|
|
||||||
|
|
||||||
```json
|
# Contributing
|
||||||
"flags": {
|
|
||||||
"svg": "https://flagcdn.com/per.svg",
|
|
||||||
"png": "https://flagcdn.com/w320/per.png"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Users
|
Any help is always welcome! Just edit the relevant file and create a new Merge Request or you can
|
||||||
---------------
|
also
|
||||||
|
donate using [Patreon](https://www.patreon.com/amatos)
|
||||||
|
or [PayPal](https://www.paypal.me/amatosg/15).
|
||||||
|
|
||||||
This project is used by
|
# Donations
|
||||||
|
|
||||||
|
This are getting out of control (in a positive way).
|
||||||
|
I'm getting about 4 million hits **each day** and that means CPU ussage (sometimes at 99%) and also
|
||||||
|
bandwidth consumption (120 GB **per day!**) so costs have obviously increased. **Please**, consider
|
||||||
|
making a donation on [Patreon](https://www.patreon.com/amatos)
|
||||||
|
or [PayPal](https://www.paypal.me/amatosg/15). This will help me pay the server's bills
|
||||||
|
|
||||||
|
# Fields
|
||||||
|
|
||||||
|
You can check the [FIELDS.md](FIELDS.md) file to get a description for each field (thanks to
|
||||||
|
@ePascalC!).
|
||||||
|
|
||||||
|
# API Endpoints
|
||||||
|
|
||||||
|
## Using this Project
|
||||||
|
|
||||||
- [Famosos](https://famosos.com)
|
- [Famosos](https://famosos.com)
|
||||||
- [Cultural Care](https://www.culturalcare.world/)
|
- [Cultural Care](https://www.culturalcare.world/)
|
||||||
@@ -72,52 +57,53 @@ This project is used by
|
|||||||
- [Asendia](https://tracking.asendia.com)
|
- [Asendia](https://tracking.asendia.com)
|
||||||
- [Picker](https://mwb.pickerexpress.com/#/login)
|
- [Picker](https://mwb.pickerexpress.com/#/login)
|
||||||
|
|
||||||
Original RESTCountries project has over 1200 users, including:
|
# Endpoints
|
||||||
|
|
||||||
- [TTÜ]
|
Below are described the REST endpoints available that you can use to search for countries
|
||||||
- [Spotify International Pricing Index]
|
|
||||||
- [Gorillaz]
|
|
||||||
- [Wanderlust]
|
|
||||||
- [Xero]
|
|
||||||
- [FxPro]
|
|
||||||
- [SKROSS]
|
|
||||||
- [onefinestay]
|
|
||||||
- [Much Better Adventures]
|
|
||||||
|
|
||||||
API Endpoints v3
|
## Latest added Enpoint
|
||||||
=======
|
|
||||||
|
|
||||||
This version takes countries from [this] project, but it adds the flags. Although the requests
|
### Independent
|
||||||
have not changed much, the response has as the country structure is different. Please refer to the
|
|
||||||
example response body.
|
Now you can get all independent (or not independent) countries by calling this endpoint:
|
||||||
|
|
||||||
|
``` html
|
||||||
|
https://restcountries.com/v3.1/independent?status=true
|
||||||
|
```
|
||||||
|
|
||||||
|
If you don't specify the status, true will be taken as default. You can mix it with the `fields`
|
||||||
|
filter like this:
|
||||||
|
|
||||||
|
``` html
|
||||||
|
https://restcountries.com/v3.1/independent?status=true&fields=languages,capital
|
||||||
|
```
|
||||||
|
|
||||||
|
## All
|
||||||
|
|
||||||
All
|
|
||||||
---------------
|
|
||||||
``` html
|
``` html
|
||||||
https://restcountries.com/v3.1/all
|
https://restcountries.com/v3.1/all
|
||||||
```
|
```
|
||||||
|
|
||||||
Name
|
## Name
|
||||||
---------------
|
|
||||||
|
|
||||||
Search by country name. It can be the native name or partial name
|
**Search** by country name. If you want to get an exact match, use the next endpoint. It can be the
|
||||||
|
common or official value
|
||||||
|
|
||||||
``` html
|
``` html
|
||||||
https://restcountries.com/v3.1/name/{name}
|
https://restcountries.com/v3.1/name/{name}
|
||||||
```
|
```
|
||||||
|
|
||||||
``` html
|
``` html
|
||||||
https://restcountries.com/v3.1/name/peru
|
https://restcountries.com/v3.1/name/eesti
|
||||||
```
|
```
|
||||||
|
|
||||||
``` html
|
``` html
|
||||||
https://restcountries.com/v3.1/name/united
|
https://restcountries.com/v3.1/name/deutschland
|
||||||
```
|
```
|
||||||
|
|
||||||
Full Name
|
## Full Name
|
||||||
---------------
|
|
||||||
|
|
||||||
Search by country full name
|
Search by country's full name. It can be the common or official value
|
||||||
|
|
||||||
``` html
|
``` html
|
||||||
https://restcountries.com/v3.1/name/{name}?fullText=true
|
https://restcountries.com/v3.1/name/{name}?fullText=true
|
||||||
@@ -127,581 +113,154 @@ https://restcountries.com/v3.1/name/{name}?fullText=true
|
|||||||
https://restcountries.com/v3.1/name/aruba?fullText=true
|
https://restcountries.com/v3.1/name/aruba?fullText=true
|
||||||
```
|
```
|
||||||
|
|
||||||
Code
|
## Code
|
||||||
---------------
|
|
||||||
|
|
||||||
Search by cca2, ccn3, cca3 or cioc country code (yes, any!)
|
Search by cca2, ccn3, cca3 or cioc country code (yes, any!)
|
||||||
|
|
||||||
**UPDATE**: this will now return an array.
|
|
||||||
|
|
||||||
``` html
|
``` html
|
||||||
https://restcountries.com/v3.1/alpha/{code}
|
https://restcountries.com/v3.1/alpha/{code}
|
||||||
```
|
```
|
||||||
|
|
||||||
``` html
|
``` html
|
||||||
https://restcountries.com/v3.1/alpha/pe
|
https://restcountries.com/v3.1/alpha/co
|
||||||
```
|
```
|
||||||
|
|
||||||
``` html
|
``` html
|
||||||
https://restcountries.com/v3.1/alpha/per
|
https://restcountries.com/v3.1/alpha/col
|
||||||
```
|
```
|
||||||
|
|
||||||
List of codes
|
``` html
|
||||||
---------------
|
https://restcountries.com/v3.1/alpha/170
|
||||||
|
```
|
||||||
|
|
||||||
Search by list of cca2, ccn3, cca3 or cioc country codes (yes, any!). The original project used *;* as
|
## List of codes
|
||||||
separator. In out case, the *comma* is used to separate values.
|
|
||||||
|
Search by cca2, ccn3, cca3 or cioc country code (yes, any!)
|
||||||
|
|
||||||
``` html
|
``` html
|
||||||
https://restcountries.com/v3.1/alpha?codes={code},{code},{code}
|
https://restcountries.com/v3.1/alpha?codes={code},{code},{code}
|
||||||
```
|
```
|
||||||
|
|
||||||
``` html
|
``` html
|
||||||
https://restcountries.com/v3.1/alpha?codes=col,pe,at
|
https://restcountries.com/v3.1/alpha?codes=170,no,est,pe
|
||||||
```
|
```
|
||||||
|
|
||||||
Currency
|
## Currency
|
||||||
---------------
|
|
||||||
|
|
||||||
Search by currency name (_new!_) or code
|
Search by currency code or name
|
||||||
|
|
||||||
``` html
|
``` html
|
||||||
https://restcountries.com/v3.1/currency/{currency}
|
https://restcountries.com/v3.1/currency/{currency}
|
||||||
```
|
```
|
||||||
``` html
|
|
||||||
https://restcountries.com/v3.1/currency/pen
|
|
||||||
```
|
|
||||||
``` html
|
|
||||||
https://restcountries.com/v3.1/currency/dollar
|
|
||||||
```
|
|
||||||
|
|
||||||
Language
|
|
||||||
---------------
|
|
||||||
|
|
||||||
Search by language name (_new!_) or iso639_2 code
|
|
||||||
|
|
||||||
``` html
|
``` html
|
||||||
https://restcountries.com/v3.1/lang/{lang}
|
https://restcountries.com/v3.1/currency/cop
|
||||||
```
|
|
||||||
``` html
|
|
||||||
https://restcountries.com/v3.1/lang/spa
|
|
||||||
```
|
|
||||||
``` html
|
|
||||||
https://restcountries.com/v3.1/lang/german
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Translations (*V3 only*)
|
### Demonym
|
||||||
-
|
|
||||||
Now you can search by name in any available translation
|
|
||||||
``` html
|
|
||||||
https://restcountries.com/v3.1/translation/Peruánská
|
|
||||||
```
|
|
||||||
|
|
||||||
Capital city
|
|
||||||
---------------
|
|
||||||
|
|
||||||
Search by capital city.
|
|
||||||
|
|
||||||
``` html
|
|
||||||
https://restcountries.com/v3.1/capital/{capital}
|
|
||||||
```
|
|
||||||
``` html
|
|
||||||
https://restcountries.com/v3.1/capital/lima
|
|
||||||
```
|
|
||||||
|
|
||||||
Region
|
|
||||||
---------------
|
|
||||||
|
|
||||||
Search by Region: Africa, Americas, Asia, Europe, Oceania. The search can be using the full region's name or just part of it
|
|
||||||
|
|
||||||
``` html
|
|
||||||
https://restcountries.com/v3.1/region/{region}
|
|
||||||
```
|
|
||||||
``` html
|
|
||||||
https://restcountries.com/v3.1/region/europe
|
|
||||||
```
|
|
||||||
``` html
|
|
||||||
https://restcountries.com/v3.1/region/ame
|
|
||||||
```
|
|
||||||
|
|
||||||
Subregion
|
|
||||||
---------------
|
|
||||||
|
|
||||||
Search by Subregion: South America, Southern Europe, Central America, Eastern Asia, etc. The search can be using the full subregion's name or just part of it
|
|
||||||
|
|
||||||
``` html
|
|
||||||
https://restcountries.com/v3.1/subregion/{region}
|
|
||||||
```
|
|
||||||
``` html
|
|
||||||
https://restcountries.com/v3.1/subregion/europe
|
|
||||||
```
|
|
||||||
``` html
|
|
||||||
https://restcountries.com/v3.1/subregion/south
|
|
||||||
```
|
|
||||||
|
|
||||||
Demonym
|
|
||||||
-
|
|
||||||
Now you can search by how a citizen is called.
|
Now you can search by how a citizen is called.
|
||||||
|
|
||||||
``` html
|
``` html
|
||||||
https://restcountries.com/v3.1/demonym/{demonym}
|
https://restcountries.com/v3.1/demonym/{demonym}
|
||||||
```
|
```
|
||||||
|
|
||||||
``` html
|
``` html
|
||||||
https://restcountries.com/v3.1/demonym/peruvian
|
https://restcountries.com/v3.1/demonym/peruvian
|
||||||
```
|
```
|
||||||
|
|
||||||
Response Example
|
## Language
|
||||||
-
|
|
||||||
``` html
|
|
||||||
https://restcountries.com/v3.1/name/japan
|
|
||||||
```
|
|
||||||
``` html
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": {
|
|
||||||
"common": "Japan",
|
|
||||||
"official": "Japan",
|
|
||||||
"nativeName": {
|
|
||||||
"jpn": {
|
|
||||||
"official": "日本",
|
|
||||||
"common": "日本"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"tld": [
|
|
||||||
".jp",
|
|
||||||
".みんな"
|
|
||||||
],
|
|
||||||
"cca2": "JP",
|
|
||||||
"ccn3": "392",
|
|
||||||
"cca3": "JPN",
|
|
||||||
"cioc": "JPN",
|
|
||||||
"independent": true,
|
|
||||||
"status": "officially-assigned",
|
|
||||||
"unMember": true,
|
|
||||||
"currencies": {
|
|
||||||
"JPY": {
|
|
||||||
"name": "Japanese yen",
|
|
||||||
"symbol": "¥"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"idd": {
|
|
||||||
"root": "+8",
|
|
||||||
"suffixes": [
|
|
||||||
"1"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"capital": [
|
|
||||||
"Tokyo"
|
|
||||||
],
|
|
||||||
"altSpellings": [
|
|
||||||
"JP",
|
|
||||||
"Nippon",
|
|
||||||
"Nihon"
|
|
||||||
],
|
|
||||||
"region": "Asia",
|
|
||||||
"subregion": "Eastern Asia",
|
|
||||||
"languages": {
|
|
||||||
"jpn": "Japanese"
|
|
||||||
},
|
|
||||||
"translations": {
|
|
||||||
"ces": {
|
|
||||||
"official": "Japonsko",
|
|
||||||
"common": "Japonsko"
|
|
||||||
},
|
|
||||||
"deu": {
|
|
||||||
"official": "Japan",
|
|
||||||
"common": "Japan"
|
|
||||||
},
|
|
||||||
"est": {
|
|
||||||
"official": "Jaapan",
|
|
||||||
"common": "Jaapan"
|
|
||||||
},
|
|
||||||
"fin": {
|
|
||||||
"official": "Japani",
|
|
||||||
"common": "Japani"
|
|
||||||
},
|
|
||||||
"fra": {
|
|
||||||
"official": "Japon",
|
|
||||||
"common": "Japon"
|
|
||||||
},
|
|
||||||
"hrv": {
|
|
||||||
"official": "Japan",
|
|
||||||
"common": "Japan"
|
|
||||||
},
|
|
||||||
"hun": {
|
|
||||||
"official": "Japán",
|
|
||||||
"common": "Japán"
|
|
||||||
},
|
|
||||||
"ita": {
|
|
||||||
"official": "Giappone",
|
|
||||||
"common": "Giappone"
|
|
||||||
},
|
|
||||||
"jpn": {
|
|
||||||
"official": "日本",
|
|
||||||
"common": "日本"
|
|
||||||
},
|
|
||||||
"kor": {
|
|
||||||
"official": "일본국",
|
|
||||||
"common": "일본"
|
|
||||||
},
|
|
||||||
"nld": {
|
|
||||||
"official": "Japan",
|
|
||||||
"common": "Japan"
|
|
||||||
},
|
|
||||||
"per": {
|
|
||||||
"official": "ژاپن",
|
|
||||||
"common": "ژاپن"
|
|
||||||
},
|
|
||||||
"pol": {
|
|
||||||
"official": "Japonia",
|
|
||||||
"common": "Japonia"
|
|
||||||
},
|
|
||||||
"por": {
|
|
||||||
"official": "Japão",
|
|
||||||
"common": "Japão"
|
|
||||||
},
|
|
||||||
"rus": {
|
|
||||||
"official": "Япония",
|
|
||||||
"common": "Япония"
|
|
||||||
},
|
|
||||||
"slk": {
|
|
||||||
"official": "Japonsko",
|
|
||||||
"common": "Japonsko"
|
|
||||||
},
|
|
||||||
"spa": {
|
|
||||||
"official": "Japón",
|
|
||||||
"common": "Japón"
|
|
||||||
},
|
|
||||||
"swe": {
|
|
||||||
"official": "Japan",
|
|
||||||
"common": "Japan"
|
|
||||||
},
|
|
||||||
"urd": {
|
|
||||||
"official": "جاپان",
|
|
||||||
"common": "جاپان"
|
|
||||||
},
|
|
||||||
"zho": {
|
|
||||||
"official": "日本国",
|
|
||||||
"common": "日本"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"latlng": [
|
|
||||||
36.0,
|
|
||||||
138.0
|
|
||||||
],
|
|
||||||
"landlocked": false,
|
|
||||||
"area": 377930.0,
|
|
||||||
"flag": "🇯🇵",
|
|
||||||
"flags": [
|
|
||||||
"svg": "https://restcountries.com/data/jpn.svg",
|
|
||||||
"png": "https://restcountries.com/data/png/jpn.png"
|
|
||||||
],
|
|
||||||
"demonyms": {
|
|
||||||
"eng": {
|
|
||||||
"f": "Japanese",
|
|
||||||
"m": "Japanese"
|
|
||||||
},
|
|
||||||
"fra": {
|
|
||||||
"f": "Japonaise",
|
|
||||||
"m": "Japonais"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
```
|
|
||||||
|
|
||||||
---------------------
|
Search by language code or name
|
||||||
|
|
||||||
API Endpoints v2
|
|
||||||
=======
|
|
||||||
|
|
||||||
Below are described the REST endpoints available that you can use to search for countries
|
|
||||||
|
|
||||||
All
|
|
||||||
---------------
|
|
||||||
|
|
||||||
``` html
|
``` html
|
||||||
https://restcountries.com/v2/all
|
https://restcountries.com/v3.1/lang/{currency}
|
||||||
```
|
|
||||||
|
|
||||||
Name
|
|
||||||
---------------
|
|
||||||
|
|
||||||
Search by country name. It can be the native name or partial name
|
|
||||||
|
|
||||||
``` html
|
|
||||||
https://restcountries.com/v2/name/{name}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
``` html
|
``` html
|
||||||
https://restcountries.com/v2/name/peru
|
https://restcountries.com/v3.1/lang/cop
|
||||||
```
|
```
|
||||||
|
|
||||||
``` html
|
``` html
|
||||||
https://restcountries.com/v2/name/united
|
https://restcountries.com/v3.1/lang/spanish
|
||||||
```
|
```
|
||||||
|
|
||||||
Full Name
|
## Capital city
|
||||||
---------------
|
|
||||||
|
|
||||||
Search by country full name
|
|
||||||
|
|
||||||
``` html
|
|
||||||
https://restcountries.com/v2/name/{name}?fullText=true
|
|
||||||
```
|
|
||||||
|
|
||||||
``` html
|
|
||||||
https://restcountries.com/v2/name/aruba?fullText=true
|
|
||||||
```
|
|
||||||
|
|
||||||
Code
|
|
||||||
---------------
|
|
||||||
|
|
||||||
Search by ISO 3166-1 2-letter or 3-letter country code
|
|
||||||
|
|
||||||
``` html
|
|
||||||
https://restcountries.com/v2/alpha/{code}
|
|
||||||
```
|
|
||||||
|
|
||||||
``` html
|
|
||||||
https://restcountries.com/v2/alpha/pe
|
|
||||||
```
|
|
||||||
|
|
||||||
``` html
|
|
||||||
https://restcountries.com/v2/alpha/per
|
|
||||||
```
|
|
||||||
|
|
||||||
List of codes
|
|
||||||
---------------
|
|
||||||
|
|
||||||
Search by list of ISO 3166-1 2-letter or 3-letter country codes. The original project used *;* as
|
|
||||||
separator. In out case, the *comma* is used to separate values.
|
|
||||||
|
|
||||||
``` html
|
|
||||||
https://restcountries.com/v2/alpha?codes={code},{code},{code}
|
|
||||||
```
|
|
||||||
|
|
||||||
``` html
|
|
||||||
https://restcountries.com/v2/alpha?codes=col,pe,at
|
|
||||||
```
|
|
||||||
|
|
||||||
Currency
|
|
||||||
---------------
|
|
||||||
|
|
||||||
Search by ISO 4217 currency code
|
|
||||||
|
|
||||||
``` html
|
|
||||||
https://restcountries.com/v2/currency/{currency}
|
|
||||||
```
|
|
||||||
``` html
|
|
||||||
https://restcountries.com/v2/currency/pen
|
|
||||||
```
|
|
||||||
|
|
||||||
Language
|
|
||||||
---------------
|
|
||||||
|
|
||||||
Search by ISO 639-1 language code.
|
|
||||||
|
|
||||||
``` javascript
|
|
||||||
https://restcountries.com/v2/lang/{lang}
|
|
||||||
```
|
|
||||||
``` html
|
|
||||||
https://restcountries.com/v2/lang/es
|
|
||||||
```
|
|
||||||
|
|
||||||
Capital city
|
|
||||||
---------------
|
|
||||||
|
|
||||||
Search by capital city
|
Search by capital city
|
||||||
|
|
||||||
``` html
|
``` html
|
||||||
https://restcountries.com/v2/capital/{capital}
|
https://restcountries.com/v3.1/capital/{capital}
|
||||||
```
|
```
|
||||||
|
|
||||||
``` html
|
``` html
|
||||||
https://restcountries.com/v2/capital/lima
|
https://restcountries.com/v3.1/capital/tallinn
|
||||||
```
|
```
|
||||||
|
|
||||||
Calling code
|
## Calling code
|
||||||
---------------
|
|
||||||
|
|
||||||
Search by calling code
|
In version 3, calling codes are in the _idd_ object. There is no implementation
|
||||||
|
to search by calling codes in V3.
|
||||||
|
|
||||||
|
## Region
|
||||||
|
|
||||||
|
Search by region (replace X with the version you want to use)
|
||||||
|
|
||||||
``` javascript
|
|
||||||
https://restcountries.com/v2/callingcode/{callingcode}
|
|
||||||
```
|
|
||||||
``` html
|
``` html
|
||||||
https://restcountries.com/v2/callingcode/51
|
https://restcountries.com/v3.1/region/{region}
|
||||||
```
|
```
|
||||||
|
|
||||||
Continent
|
|
||||||
---------------
|
|
||||||
|
|
||||||
Search by continent (region): Africa, Americas, Asia, Europe, Oceania
|
|
||||||
|
|
||||||
``` javascript
|
|
||||||
https://restcountries.com/v2/region/{region}
|
|
||||||
```
|
|
||||||
``` html
|
``` html
|
||||||
https://restcountries.com/v3.1/region/europe
|
https://restcountries.com/v3.1/region/europe
|
||||||
```
|
```
|
||||||
|
|
||||||
Regional Bloc
|
## Subregions
|
||||||
---------------
|
|
||||||
|
|
||||||
Search by regional bloc:
|
You can search by subregions (replace X with the version you want to use)
|
||||||
|
|
||||||
- EU (European Union)
|
|
||||||
- EFTA (European Free Trade Association)
|
|
||||||
- CARICOM (Caribbean Community)
|
|
||||||
- PA (Pacific Alliance)
|
|
||||||
- AU (African Union)
|
|
||||||
- USAN (Union of South American Nations)
|
|
||||||
- EEU (Eurasian Economic Union)
|
|
||||||
- AL (Arab League)
|
|
||||||
- ASEAN (Association of Southeast Asian Nations)
|
|
||||||
- CAIS (Central American Integration System)
|
|
||||||
- CEFTA (Central European Free Trade Agreement)
|
|
||||||
- NAFTA (North American Free Trade Agreement)
|
|
||||||
- SAARC (South Asian Association for Regional Cooperation)
|
|
||||||
|
|
||||||
``` html
|
``` html
|
||||||
https://restcountries.com/v2/regionalbloc/{regionalbloc}
|
https://restcountries.com/v3.1/subregion/{subregion}
|
||||||
```
|
```
|
||||||
``` html
|
|
||||||
https://restcountries.com/v2/regionalbloc/eu
|
|
||||||
```
|
|
||||||
|
|
||||||
Response Example
|
|
||||||
---------------
|
|
||||||
|
|
||||||
``` html
|
``` html
|
||||||
https://restcountries.com/v2/alpha/col
|
https://restcountries.com/v3.1/subregion/Northern Europe
|
||||||
```
|
```
|
||||||
|
|
||||||
``` json
|
## Translation
|
||||||
{
|
|
||||||
"name": "Colombia",
|
You can search by any translation name
|
||||||
"topLevelDomain": [
|
|
||||||
".co"
|
``` html
|
||||||
],
|
https://restcountries.com/v3.1/translation/{translation}
|
||||||
"alpha2Code": "CO",
|
|
||||||
"alpha3Code": "COL",
|
|
||||||
"callingCodes": [
|
|
||||||
"57"
|
|
||||||
],
|
|
||||||
"capital": "Bogotá",
|
|
||||||
"altSpellings": [
|
|
||||||
"CO",
|
|
||||||
"Republic of Colombia",
|
|
||||||
"República de Colombia"
|
|
||||||
],
|
|
||||||
"region": "South America",
|
|
||||||
"continent": "Americas",
|
|
||||||
"population": 48759958,
|
|
||||||
"latlng": [
|
|
||||||
4.0,
|
|
||||||
-72.0
|
|
||||||
],
|
|
||||||
"demonym": "Colombian",
|
|
||||||
"area": 1141748.0,
|
|
||||||
"gini": 55.9,
|
|
||||||
"timezones": [
|
|
||||||
"UTC-05:00"
|
|
||||||
],
|
|
||||||
"borders": [
|
|
||||||
"BRA",
|
|
||||||
"ECU",
|
|
||||||
"PAN",
|
|
||||||
"PER",
|
|
||||||
"VEN"
|
|
||||||
],
|
|
||||||
"nativeName": "Colombia",
|
|
||||||
"numericCode": "170",
|
|
||||||
"currencies": [
|
|
||||||
{
|
|
||||||
"code": "COP",
|
|
||||||
"name": "Colombian peso",
|
|
||||||
"symbol": "$"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"languages": [
|
|
||||||
{
|
|
||||||
"iso639_1": "es",
|
|
||||||
"iso639_2": "spa",
|
|
||||||
"name": "Spanish",
|
|
||||||
"nativeName": "Español"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"translations": {
|
|
||||||
"br": "Colômbia",
|
|
||||||
"pt": "Colômbia",
|
|
||||||
"nl": "Colombia",
|
|
||||||
"hr": "Kolumbija",
|
|
||||||
"fa": "کلمبیا",
|
|
||||||
"de": "Kolumbien",
|
|
||||||
"es": "Colombia",
|
|
||||||
"fr": "Colombie",
|
|
||||||
"ja": "コロンビア",
|
|
||||||
"it": "Colombia",
|
|
||||||
"hu": "Kolumbia"
|
|
||||||
},
|
|
||||||
"flags": [
|
|
||||||
"https://restcountries.com/data/col.svg",
|
|
||||||
"https://restcountries.com/data/png/col.png"
|
|
||||||
],
|
|
||||||
"regionalBlocs": [
|
|
||||||
{
|
|
||||||
"acronym": "PA",
|
|
||||||
"name": "Pacific Alliance",
|
|
||||||
"otherNames": [
|
|
||||||
"Alianza del Pacífico"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"acronym": "USAN",
|
|
||||||
"name": "Union of South American Nations",
|
|
||||||
"otherAcronyms": [
|
|
||||||
"UNASUR",
|
|
||||||
"UNASUL",
|
|
||||||
"UZAN"
|
|
||||||
],
|
|
||||||
"otherNames": [
|
|
||||||
"Unión de Naciones Suramericanas",
|
|
||||||
"União de Nações Sul-Americanas",
|
|
||||||
"Unie van Zuid-Amerikaanse Naties",
|
|
||||||
"South American Union"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"cioc": "COL",
|
|
||||||
"independent": true
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Filter Response
|
``` html
|
||||||
=======
|
https://restcountries.com/v3.1/translation/germany
|
||||||
|
```
|
||||||
|
|
||||||
|
``` html
|
||||||
|
https://restcountries.com/v3.1/translation/alemania
|
||||||
|
```
|
||||||
|
|
||||||
|
``` html
|
||||||
|
https://restcountries.com/v3.1/translation/Saksamaa
|
||||||
|
```
|
||||||
|
|
||||||
|
## Filter Response
|
||||||
|
|
||||||
You can filter the output of your request to include only the specified fields.
|
You can filter the output of your request to include only the specified fields.
|
||||||
|
|
||||||
``` javascript
|
|
||||||
https://restcountries.com/v2/{service}?fields={field},{field},{field}
|
|
||||||
```
|
|
||||||
``` html
|
``` html
|
||||||
https://restcountries.com/v2/all?fields=name,capital,currencies
|
https://restcountries.com/v3.1/{service}?fields={field},{field},{field}
|
||||||
```
|
```
|
||||||
|
|
||||||
Sources
|
``` html
|
||||||
=======
|
https://restcountries.com/v3.1/all?fields=name,capital,currencies
|
||||||
* [@mledoze]
|
```
|
||||||
* [List of countries]
|
|
||||||
* [Languages]
|
|
||||||
* [Currencies]
|
|
||||||
* [Area]
|
|
||||||
|
|
||||||
Similar projects
|
## Similar projects
|
||||||
=======
|
|
||||||
* [Original Project]
|
* [REST Countries] (original project)
|
||||||
* [Countries of the world]
|
* [Countries of the world]
|
||||||
* [REST Countries Node.js]
|
* [REST Countries Node.js]
|
||||||
* [REST Countries Ruby]
|
* [REST Countries Ruby]
|
||||||
@@ -709,38 +268,22 @@ Similar projects
|
|||||||
* [REST Countries Python]
|
* [REST Countries Python]
|
||||||
* [world-currencies]
|
* [world-currencies]
|
||||||
|
|
||||||
License
|
|
||||||
=======
|
|
||||||
[Mozilla Public License] MPL 2.0
|
|
||||||
|
|
||||||
[$5]:https://www.paypal.com/paypalme/amatosg/5
|
|
||||||
[$10]:https://www.paypal.com/paypalme/amatosg/10
|
|
||||||
[$15]:https://www.paypal.com/paypalme/amatosg/15
|
|
||||||
[more]:https://www.paypal.com/paypalme/amatosg/
|
|
||||||
[Original Project]: https://github.com/apilayer/restcountries/
|
|
||||||
[@mledoze]: https://github.com/mledoze/countries
|
|
||||||
[List of countries]: https://en.wikipedia.org/wiki/ISO_3166-1#Current_codes
|
|
||||||
[Languages]: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
|
|
||||||
[Currencies]: https://en.wikipedia.org/wiki/List_of_circulating_currencies
|
|
||||||
[Area]: https://en.wikipedia.org/wiki/List_of_countries_and_dependencies_by_area
|
|
||||||
[Population]: https://en.wikipedia.org/wiki/List_of_countries_by_population
|
|
||||||
[Gini coefficient]: http://en.wikipedia.org/wiki/List_of_countries_by_income_equality
|
|
||||||
[Mozilla Public License]: https://www.mozilla.org/en-US/MPL/2.0/
|
|
||||||
[world-currencies]: https://github.com/wiredmax/world-currencies
|
[world-currencies]: https://github.com/wiredmax/world-currencies
|
||||||
|
|
||||||
[REST Countries Node.js]: https://github.com/aredo/restcountries
|
[REST Countries Node.js]: https://github.com/aredo/restcountries
|
||||||
|
|
||||||
[REST Countries Ruby]: https://github.com/davidesantangelo/restcountry
|
[REST Countries Ruby]: https://github.com/davidesantangelo/restcountry
|
||||||
|
|
||||||
[REST Countries Go]: https://github.com/alediaferia/gocountries
|
[REST Countries Go]: https://github.com/alediaferia/gocountries
|
||||||
|
|
||||||
[REST Countries Python]: https://github.com/SteinRobert/python-restcountries
|
[REST Countries Python]: https://github.com/SteinRobert/python-restcountries
|
||||||
|
|
||||||
[Countries of the world]: http://countries.petethompson.net
|
[Countries of the world]: http://countries.petethompson.net
|
||||||
[TTÜ]: https://www.ttu.ee/studying/tut_admission/programmes-in-tut/ask-us/
|
|
||||||
[Spotify International Pricing Index]: http://mts.io/2014/05/07/spotify-pricing-index/
|
[REST Countries]: https://github.com/apilayer/restcountries
|
||||||
[Gorillaz]: http://www.gorillaz.com/
|
|
||||||
[Wanderlust]: https://wanderlust.com/
|
[Original Project]: https://github.com/apilayer/restcountries/
|
||||||
[Xero]: https://www.xero.com/
|
|
||||||
[FxPro]: http://www.fxpro.com/
|
|
||||||
[onefinestay]: https://www.onefinestay.com/
|
|
||||||
[Much Better Adventures]: https://www.muchbetteradventures.com
|
|
||||||
[SKROSS]: http://www.skross.com/en
|
|
||||||
[this]: https://github.com/mledoze/countries
|
|
||||||
[donation]: https://www.paypal.me/amatosg/15
|
[donation]: https://www.paypal.me/amatosg/15
|
||||||
[donate]: https://www.paypal.me/amatosg/15
|
|
||||||
|
[donate]: https://www.paypal.me/amatosg/15
|
||||||
|
|||||||
@@ -1,24 +1,39 @@
|
|||||||
package dev.amatos.restcountries;
|
package dev.amatos.restcountries;
|
||||||
|
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import dev.amatos.restcountries.domain.v3.v31.Country;
|
||||||
import dev.amatos.restcountries.service.v3.v31.CountryServiceV31;
|
import dev.amatos.restcountries.service.v3.v31.CountryServiceV31;
|
||||||
|
import io.micronaut.http.client.RxHttpClient;
|
||||||
|
import io.micronaut.http.client.annotation.Client;
|
||||||
import io.micronaut.test.annotation.MicronautTest;
|
import io.micronaut.test.annotation.MicronautTest;
|
||||||
|
import java.security.spec.ECField;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import javax.inject.Inject;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
@MicronautTest
|
@MicronautTest
|
||||||
class RestCountriesV31Test {
|
class RestCountriesV31Test {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Client("/")
|
||||||
|
RxHttpClient rxHttpClient;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getAll() {
|
void getAll() {
|
||||||
var countries = CountryServiceV31.getInstance().getAll();
|
var countries = CountryServiceV31.getInstance().getAll();
|
||||||
Assertions.assertFalse(countries.isEmpty());
|
assertFalse(countries.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getByAlpha() {
|
void getByAlpha() {
|
||||||
var countries = CountryServiceV31.getInstance().getByAlpha("CO");
|
var countries = CountryServiceV31.getInstance().getByAlpha("CO");
|
||||||
Assertions.assertFalse(countries.isEmpty());
|
assertFalse(countries.isEmpty());
|
||||||
Assertions.assertEquals("Colombia",
|
Assertions.assertEquals("Colombia",
|
||||||
countries.stream().findFirst().map(country -> country.getName().getCommon()).orElseThrow());
|
countries.stream().findFirst().map(country -> country.getName().getCommon()).orElseThrow());
|
||||||
}
|
}
|
||||||
@@ -32,7 +47,7 @@ class RestCountriesV31Test {
|
|||||||
@Test
|
@Test
|
||||||
void getCountryByName() {
|
void getCountryByName() {
|
||||||
var countries = CountryServiceV31.getInstance().getByName("Peru", false);
|
var countries = CountryServiceV31.getInstance().getByName("Peru", false);
|
||||||
Assertions.assertFalse(countries.isEmpty());
|
assertFalse(countries.isEmpty());
|
||||||
Assertions.assertEquals("Peru",
|
Assertions.assertEquals("Peru",
|
||||||
countries.stream().findFirst().map(country -> country.getName().getCommon()).orElseThrow());
|
countries.stream().findFirst().map(country -> country.getName().getCommon()).orElseThrow());
|
||||||
}
|
}
|
||||||
@@ -41,21 +56,21 @@ class RestCountriesV31Test {
|
|||||||
void getByCodeList() {
|
void getByCodeList() {
|
||||||
var countries = CountryServiceV31.getInstance().getByCodeList("PE,NL,DE");
|
var countries = CountryServiceV31.getInstance().getByCodeList("PE,NL,DE");
|
||||||
Assertions.assertNotNull(countries);
|
Assertions.assertNotNull(countries);
|
||||||
Assertions.assertFalse(countries.isEmpty());
|
assertFalse(countries.isEmpty());
|
||||||
Assertions.assertEquals(3, countries.size());
|
Assertions.assertEquals(3, countries.size());
|
||||||
var result = countries.stream().allMatch(country ->
|
var result = countries.stream().allMatch(country ->
|
||||||
country.getName().getCommon().contains("Peru") ||
|
country.getName().getCommon().contains("Peru") ||
|
||||||
country.getName().getCommon().contains("Netherlands") ||
|
country.getName().getCommon().contains("Netherlands") ||
|
||||||
country.getName().getCommon().contains("German")
|
country.getName().getCommon().contains("German")
|
||||||
);
|
);
|
||||||
Assertions.assertTrue(result);
|
assertTrue(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getByCurrency() {
|
void getByCurrency() {
|
||||||
var countries = CountryServiceV31.getInstance().getByCurrency("EUR");
|
var countries = CountryServiceV31.getInstance().getByCurrency("EUR");
|
||||||
Assertions.assertNotNull(countries);
|
Assertions.assertNotNull(countries);
|
||||||
Assertions.assertFalse(countries.isEmpty());
|
assertFalse(countries.isEmpty());
|
||||||
countries.forEach(country -> country.getCurrencies()
|
countries.forEach(country -> country.getCurrencies()
|
||||||
.forEach((key, value) -> Assertions.assertEquals("EUR", key)));
|
.forEach((key, value) -> Assertions.assertEquals("EUR", key)));
|
||||||
}
|
}
|
||||||
@@ -65,7 +80,7 @@ class RestCountriesV31Test {
|
|||||||
var countries = CountryServiceV31.getInstance().getByCapital("Helsinki");
|
var countries = CountryServiceV31.getInstance().getByCapital("Helsinki");
|
||||||
var result = countries.stream()
|
var result = countries.stream()
|
||||||
.anyMatch(country -> country.getName().getCommon().equalsIgnoreCase("Finland"));
|
.anyMatch(country -> country.getName().getCommon().equalsIgnoreCase("Finland"));
|
||||||
Assertions.assertTrue(result);
|
assertTrue(result);
|
||||||
Assertions.assertEquals(1, countries.size());
|
Assertions.assertEquals(1, countries.size());
|
||||||
Assertions.assertEquals("Finland",
|
Assertions.assertEquals("Finland",
|
||||||
countries.stream().findFirst().map(country -> country.getName().getCommon()).orElseThrow());
|
countries.stream().findFirst().map(country -> country.getName().getCommon()).orElseThrow());
|
||||||
@@ -74,44 +89,44 @@ class RestCountriesV31Test {
|
|||||||
@Test
|
@Test
|
||||||
void getByRegion() {
|
void getByRegion() {
|
||||||
var countries = CountryServiceV31.getInstance().getByRegion("Asia");
|
var countries = CountryServiceV31.getInstance().getByRegion("Asia");
|
||||||
Assertions.assertFalse(countries.isEmpty());
|
assertFalse(countries.isEmpty());
|
||||||
var result = countries.stream()
|
var result = countries.stream()
|
||||||
.anyMatch(country -> country.getName().getCommon().equalsIgnoreCase("Bangladesh"));
|
.anyMatch(country -> country.getName().getCommon().equalsIgnoreCase("Bangladesh"));
|
||||||
Assertions.assertTrue(result);
|
assertTrue(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getBySubregion() {
|
void getBySubregion() {
|
||||||
var countries = CountryServiceV31.getInstance().getBySubregion("Middle Africa");
|
var countries = CountryServiceV31.getInstance().getBySubregion("Middle Africa");
|
||||||
Assertions.assertFalse(countries.isEmpty());
|
assertFalse(countries.isEmpty());
|
||||||
var result = countries.stream()
|
var result = countries.stream()
|
||||||
.anyMatch(country -> country.getName().getCommon().equalsIgnoreCase("Gabon"));
|
.anyMatch(country -> country.getName().getCommon().equalsIgnoreCase("Gabon"));
|
||||||
Assertions.assertTrue(result);
|
assertTrue(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getByLanguage() {
|
void getByLanguage() {
|
||||||
var countries = CountryServiceV31.getInstance().getByLanguage("german");
|
var countries = CountryServiceV31.getInstance().getByLanguage("german");
|
||||||
Assertions.assertFalse(countries.isEmpty());
|
assertFalse(countries.isEmpty());
|
||||||
var result = countries.stream()
|
var result = countries.stream()
|
||||||
.anyMatch(country -> country.getName().getCommon().equalsIgnoreCase("Liechtenstein"));
|
.anyMatch(country -> country.getName().getCommon().equalsIgnoreCase("Liechtenstein"));
|
||||||
Assertions.assertTrue(result);
|
assertTrue(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getByDemonym() {
|
void getByDemonym() {
|
||||||
var countries = CountryServiceV31.getInstance().getByDemonym("chilean");
|
var countries = CountryServiceV31.getInstance().getByDemonym("chilean");
|
||||||
Assertions.assertFalse(countries.isEmpty());
|
assertFalse(countries.isEmpty());
|
||||||
var result = false;
|
var result = false;
|
||||||
result = countries.stream()
|
result = countries.stream()
|
||||||
.anyMatch(country -> country.getName().getCommon().equalsIgnoreCase("Chile"));
|
.anyMatch(country -> country.getName().getCommon().equalsIgnoreCase("Chile"));
|
||||||
Assertions.assertTrue(result);
|
assertTrue(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getByTranslation() {
|
void getByTranslation() {
|
||||||
var countries = CountryServiceV31.getInstance().getByTranslation("Běloruská");
|
var countries = CountryServiceV31.getInstance().getByTranslation("Běloruská");
|
||||||
Assertions.assertFalse(countries.isEmpty());
|
assertFalse(countries.isEmpty());
|
||||||
Assertions.assertEquals(1, countries.size());
|
Assertions.assertEquals(1, countries.size());
|
||||||
Assertions.assertEquals("Belarus", countries.stream().findFirst().get().getName().getCommon());
|
Assertions.assertEquals("Belarus", countries.stream().findFirst().get().getName().getCommon());
|
||||||
}
|
}
|
||||||
@@ -128,7 +143,7 @@ class RestCountriesV31Test {
|
|||||||
Exception ex) {
|
Exception ex) {
|
||||||
Assertions.fail();
|
Assertions.fail();
|
||||||
}
|
}
|
||||||
Assertions.assertTrue(result);
|
assertTrue(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -143,6 +158,6 @@ class RestCountriesV31Test {
|
|||||||
Exception ex) {
|
Exception ex) {
|
||||||
Assertions.fail();
|
Assertions.fail();
|
||||||
}
|
}
|
||||||
Assertions.assertTrue(result);
|
assertTrue(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user