Skip to content

πŸ—Ί A JSON catalogue of countries, cities and everything inbetween, as well as UI to consume the data.

Notifications You must be signed in to change notification settings

schalkventer/territories

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

20 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ—Ί Territories

A JSON catalogue of countries, cities and everything inbetween, as well as UI to consume the data

Example

  • Andorra
    • Andorra la Vella
    • Canillo
    • Encamp
    • ...
  • United Arab Emirates
    • ...
  • Afghanistan
    • ...
  • ...

Data Structure

territories/
β”œβ”€β”€ packages/
|   └── json/
β”‚       β”œβ”€β”€ keys.json
β”‚       β”œβ”€β”€ previews.json
β”‚       β”œβ”€β”€ AD/
β”‚       β”‚   β”œβ”€β”€ keys.json
β”‚       β”‚   └── previews.json
β”‚       β”‚   
β”‚       β”œβ”€β”€ AE/
β”‚       β”‚   β”œβ”€β”€ keys.json
β”‚       β”‚   └── previews.json
β”‚       β”‚   
β”‚       β”œβ”€β”€ AD/
β”‚       β”‚   β”œβ”€β”€ keys.json
β”‚       β”‚   └── previews.json
β”‚       β”‚   ...
β”‚       ...   
...

The root keys.json file in the json folder contains an array of all country ISO 3166-2 codes, if you want to just get a list of all countries.

For example:

[
  "AD",
  "AE",
  "AF",
  // ...
]

However, you probably require a bit more than just the ISO 3166-2 key if you want to surface this information in your user interface. Luckily there is also a previews.json file with a bit more information.

For example:

[
  {
    "key": "AD",
    "icon": "https://cdn.rawgit.com/hjnilsson/country-flags/master/svg/ad.svg",
    "name": "Andorra",
    "link": "https://en.wikipedia.org//wiki/ISO_3166-2:AD"
  },
  {
    "key": "AE",
    "icon": "https://cdn.rawgit.com/hjnilsson/country-flags/master/svg/ae.svg",
    "name": "United Arab Emirates",
    "link": "https://en.wikipedia.org//wiki/ISO_3166-2:AE"
  },
  {
    "key": "AF",
    "icon": "https://cdn.rawgit.com/hjnilsson/country-flags/master/svg/af.svg",
    "name": "Afghanistan",
    "link": "https://en.wikipedia.org//wiki/ISO_3166-2:AF"
  },
  // ...
]

Each of the keys above also has a namesake folder in the root json folder. Each of these have their own keys.json and preview.json files following the same structure. Note that subdivision is the umbrella term used by the ISO 3166-2 for the highest territorial unit under country. This can be states, provinces, districts, prefectures, et al.

For example AD/keys.json:

[
  "AD-07",
  "AE-02",
  "AF-03",
  // ...
]

And also AD/previews.json:

[
  {
    "key": "AD-07",
    "name": "Andorra la Vella",
    "icon": "https:////upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Escut_d%27Andorra_la_Vella.svg/23px-Escut_d%27Andorra_la_Vella.svg.png"
  },
  {
    "key": "AD-02",
    "name": "Canillo",
    "icon": "https:////upload.wikimedia.org/wikipedia/commons/thumb/4/4b/Escut_de_Canillo.svg/23px-Escut_de_Canillo.svg.png"
  },
  {
    "key": "AD-03",
    "name": "Encamp",
    "icon": "https:////upload.wikimedia.org/wikipedia/commons/thumb/e/e9/Escut_d%27Encamp.svg/23px-Escut_d%27Encamp.svg.png"
  },
  // ...
]

Sources

Data is aggregated from several sources, most notably:

About

πŸ—Ί A JSON catalogue of countries, cities and everything inbetween, as well as UI to consume the data.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published