Code Monkey home page Code Monkey logo

martinsonuoha / countriesnowapi Goto Github PK

View Code? Open in Web Editor NEW
179.0 9.0 55.0 4.05 MB

CountriesNow is an Open source API for retrieving geo-information for countries, including their states, cities, population, etc. 🌎

Home Page: http://countriesnow.space

License: MIT License

JavaScript 99.98% CSS 0.01% Handlebars 0.01% Makefile 0.01% Procfile 0.01%
population cities countries countries-data population-countries cities-data population-cities geojson open-source country-codes

countriesnowapi's Introduction

CountriesNow

A curation of Countries data including (dial codes, states, cities, currencies, capitals etc) served over a REST API so you don't have to have them locally in your applications. This means lighter application sizes as you wouldn't have to install another package to use geo data. Please note that this doesn't guarantee complete or correct data, feel free to raise issues where necessary.

CleanShot 2022-03-17 at 9 19 17@2x

USAGE

The API does not require any form of Authentication or token.

const BASE_URL = 'https://countriesnow.space/api/v0.1/countries'

let getCountries = async () => {
  const response = await fetch(`${BASE_URL}`).then(response => response.json())
  const { data } = response

  data.forEach((country) => {
    console.log(country) // {"country": "Afghanistan", "cities": [ "Herat", "Kabul", "Kandahar", "Molah", ...]}
  })
}

The API does not require any form of Authentication or token.


Local Setup

git clone https://github.com/YourName/countriesNowAPI.git

Change directory

cd countriesNowAPI

Install packages

npm i

Start Project

npm start

Run test

npm run integration:test

Contribution

Please read the contribution guide here

Feel free to support and keep the API running

Buy Me A Coffee

✨ All thanks to this gist, datahub, and this repository for the data curated.

countriesnowapi's People

Contributors

anuragphadnis avatar deepsource-autofix[bot] avatar dependabot[bot] avatar dr5hn avatar fermellone avatar fladioarmandika avatar huzefa1122 avatar iambenkay avatar jbmoutout avatar johnexzy avatar martinsonuoha avatar mr-emeka avatar peter81git avatar ramazansancar avatar rsh1337 avatar ryzbaka avatar shaedrich avatar sileski avatar timaagaard avatar ucejtech avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

countriesnowapi's Issues

Re-write in Typescript

  • The idea is to help improve DX (developer experience) when contributing to the project

GraphQL support for queries (Improvement)

Since there are many fields for a country it will be great if GraphQL support is added. So users can request the fields they want instead of receiving unwanted fields.
Documentation will be simplified because users can tell what they want. No need of having multiple endpoints for different queries.

Missing Cities in France

Hello,
So, I'm french, and I'm using your API for a school projects, and I wanted to test my work with the cities near me, and I've found multiple cities missing, in France. I don't got the list of all of them, but I know a few of them, like "Méziré", "Morvillars", "Montbéliard".
Is there any way to update the cities in France pls ?
Thanks for your incredible work :)

Unable to get cities by state when the state name contain the word state

When trying to get cities by state, if the state name contains the word state the request fail with error state not found

Example 1:

https://countriesnow.space/api/v0.1/countries/state/cities
payload

{
    "country": "Micronesia",
    "state": "Pohnpei State"
}

Example 1:

https://countriesnow.space/api/v0.1/countries/state/cities
payload

{
    "country": "Micronesia",
    "state": "Pohnpei State"
}

response:

{
    "error": true,
    "msg": "state not found"
}




Example 2:

https://countriesnow.space/api/v0.1/countries/state/cities

payload

{
    "country": "South Africa",
    "state": "free state"
}

Response:

{
    "error": true,
    "msg": "state not found"
}

Boliva is missing

Hi,
I am from India, I am using your API on my college website, one issue I am getting is, that Bolivia is missing in your API. Could you please add Boliva there as soon as possible?

This is the list of states

[
  { "label": "Beni", "value": "Beni" },
  { "label": "Chuquisaca", "value": "Chuquisaca" },
  { "label": "Cochabamba", "value": "Cochabamba" },
  { "label": "La Paz", "value": "La Paz" },
  { "label": "Oruro", "value": "Oruro" },
  { "label": "Pando", "value": "Pando" },
  { "label": "Potosí", "value": "Potosí" },
  { "label": "Santa Cruz", "value": "Santa Cruz" },
  { "label": "Tarija", "value": "Tarija" }
]

and this is the list of cities

[
  { "label": "Achacachi", "value": "Achacachi", "state": "La Paz" },
  { "label": "Aiquile", "value": "Aiquile", "state": "Cochabamba" },
  { "label": "Ascensión de Guarayos", "value": "Ascensión de Guarayos", "state": "Santa Cruz" },
  { "label": "Bermejo", "value": "Bermejo", "state": "Tarija" },
  { "label": "Camargo", "value": "Camargo", "state": "Chuquisaca" },
  { "label": "Camiri", "value": "Camiri", "state": "Santa Cruz" },
  { "label": "Cobija", "value": "Cobija", "state": "Pando" },
  { "label": "Cochabamba", "value": "Cochabamba", "state": "Cochabamba" },
  { "label": "Colcapirhua", "value": "Colcapirhua", "state": "Cochabamba" },
  { "label": "Cotoca", "value": "Cotoca", "state": "Santa Cruz" },
  { "label": "El Alto", "value": "El Alto", "state": "La Paz" },
  { "label": "Entre Ríos", "value": "Entre Ríos", "state": "Cochabamba" },
  { "label": "Guayaramerín", "value": "Guayaramerín", "state": "Beni" },
  { "label": "Huanuni", "value": "Huanuni", "state": "Oruro" },
  { "label": "La Guardia", "value": "La Guardia", "state": "Santa Cruz" },
  { "label": "La Paz", "value": "La Paz", "state": "La Paz" },
  { "label": "Llallagua", "value": "Llallagua", "state": "Potosí" },
  { "label": "Montero", "value": "Montero", "state": "Santa Cruz" },
  { "label": "Oruro", "value": "Oruro", "state": "Oruro" },
  { "label": "Patacamaya", "value": "Patacamaya", "state": "La Paz" },
  { "label": "Potosí", "value": "Potosí", "state": "Potosí" },
  { "label": "Puerto Quijarro", "value": "Puerto Quijarro", "state": "Santa Cruz" },
  { "label": "Quillacollo", "value": "Quillacollo", "state": "Cochabamba" },
  { "label": "Riberalta", "value": "Riberalta", "state": "Beni" },
  { "label": "Sacaba", "value": "Sacaba", "state": "Cochabamba" },
  { "label": "San Borja", "value": "San Borja", "state": "Beni" },
  { "label": "San Ignacio de Velasco", "value": "San Ignacio de Velasco", "state": "Santa Cruz" },
  { "label": "San José de Chiquitos", "value": "San José de Chiquitos", "state": "Santa Cruz" },
  { "label": "San Julián", "value": "San Julián", "state": "Santa Cruz" },
  { "label": "San Lorenzo", "value": "San Lorenzo", "state": "Tarija" },
  { "label": "San Matías", "value": "San Matías", "state": "Santa Cruz" },
  { "label": "Santa Ana de Yacuma", "value": "Santa Ana de Yacuma", "state": "Beni" },
  { "label": "Santa Cruz de la Sierra", "value": "Santa Cruz de la Sierra", "state": "Santa Cruz" },
  { "label": "Sucre", "value": "Sucre", "state": "Chuquisaca" },
  { "label": "Tarija", "value": "Tarija", "state": "Tarija" },
  { "label": "Trinidad", "value": "Trinidad", "state": "Beni" },
  { "label": "Tupiza", "value": "Tupiza", "state": "Potosí" },
  { "label": "Uyuni", "value": "Uyuni", "state": "Potosí" },
  { "label": "Villamontes", "value": "Villamontes", "state": "Tarija" },
  { "label": "Villazón", "value": "Villazón", "state": "Potosí" },
  { "label": "Warnes", "value": "Warnes", "state": "Santa Cruz" },
  { "label": "Yacuiba", "value": "Yacuiba", "state": "Tarija" }
]

Thanks for providing this helpful resource.

Deprecate POST requests and route them to GET requests

None of the POST requests change anything so they should semantically be GET requests.

Redirecting these POST requests to parameterized GET requests will allow caching of these routes in the future while maintaining compatibility for anything built using the POST requests.

Missing city in Ohio

Hi, I would like to ask if we can add North Jackson in cities under Ohio? thanks!

query cities of a specific state using iso of country

currently the query for cities requires country and state payload. We need to have iso2 and state or iso3 and state`. or both.

Current payload:

{
  "country": "Nigeria",
  "state": "Lagos"
}

Required payload:

{
  "iso2": "NG",
  "state" "Lagos"
}

or

{
  "iso3": "NGN",
  "state": "Lagos"
}

Inconsistent "state" suffix in states

When sending a POST request to /state/cities, the payload looks like

{
   "country" : "Nigeria",
   "state" : "Abia State"
}

But not all states have the "state" suffix. In other words, payload such as

{
   "country" : "Nigeria",
   "state" : "Abia"
}

returns 404

Feature request: Country code as param

Currently the country name is required, but preferred country names can be inconsistent (for example, see "Viet Nam" vs "Vietnam"). It would be useful to instead allow one of either country, countryCode (an alias for countryCodeIso2), countryCodeIso2, or countryCodeIso3.

add country code to retrieving country flags

Response should be in this format

{
  "error": false,
  "msg": "flags images retrieved",
  "data": [
    {
      "name": "Afghanistan",
      "code": "AF",
      "flag": "https://upload.wikimedia.org/wikipedia/commons/9/9a/Flag_of_Afghanistan.svg"
    }
    ...]
}

Where is the data being sourced from?

Hello!
First of all, thank you so much for this API! It's very useful 🥇
Second of all, where are you sourcing your city information from? I'm assuming that it's census records, but I'm genuinely curious.

POST methods broken

First let me say thanks for this great API.

I've noticed while playing around with it that all the POST methods seem to be broken i.e.:

❯ curl --location 'https://countriesnow.space/api/v0.1/countries/states' \
--data '{
    "country": "Nigeria"
}'
{"error":true,"msg":"missing param (country or iso2)"}

I've got these requests to work with the query string, IE

❯ curl --location 'https://countriesnow.space/api/v0.1/countries/states/?country="Nigeria"'

So I am guessing something is going wrong with the Middleware redirection in

* Redirect all POST requests by appending "/q" to the end of the route

Is there anyway of investigating this further? I've cloned the repo and the tests pass, which contradicts my lived experience.

Alternatively, is it time to remove all the POST requests (at least in the documentation) for their proper GET versions? I'm happy to take this on

Inconsistent "state" suffix across states in NIGERIA

Although several issues have been fixed around this niche, I think Lagos should have a state suffix like other states in Nigeria to please data consistency.

The entry point to easily solving this should be on the datastore here

Missing Basel-Stadt in Switzerland

Hey there!

First of all, thank you for this awesome pack of locations. Great work! 👏

In our application, we reach to a problem with Basel city, in Switzerland. The file model/countriesAndCities.js has the Basel city, but we do not use this one. We use the model/countriesStateCity.js, which has only Basel-Landschaft Kanton, not the Basel-Stadt Kanton. Basel city (i think, as of my research, I'm not from Switzerland, but we have some users from there) should be inside of Basel-Stadt Kanton. Example:

...
{
    "name": "Basel-Stadt",
    "code": "BS",
    "cities": [
        {
            "name": "Basel",
            "latitude": "...",
            "longitude": "..."
        },
}
...

Refs:
https://en.wikipedia.org/wiki/Basel-Stadt
https://en.wikipedia.org/wiki/Basel-Landschaft

Country: "Anguilla" Not Found

  • querying the /cities endpoint, with { country: "Anguilla" } returns 404
  • Looking through the response from the /cities endpoint, the country "Anguilla" doesn't exist
  • This is basically another missing data issue
  • This can be resolved if we have all the cities under Anguilla
  • Ref: http://www.fallingrain.com/world/AV/

some countries has no cites

Using https://countriesnow.space/api/v0.1/countries/positions
return some countries name in a different way when using this :
https://countriesnow.space/api/v0.1/countries/info?returns=name

Example:
/positions response: syria as "Syrian Arab Republic"
/info?returns=name response: "Syria"

Using "Syrian Arab Republic" as post request to get its cities return nothing, but when using "Syria" it works, the problem I need to use positions to get lat and long also to get a country name to get it cities.

I noticed there are some other countries that have the same issue.

Investigate breaking endpoints & Error handling

Owner @TimAagaard

  1. I just broke your API, sorry. If you run /api/v0.1/countries/population/filter with:
{
    "year": 2020,
    "orderBy": "name"
}

The app hard crashes. I double checked locally and Node crashes. (So if you're around and awake you should restart the app)

  1. If you run the same route with the values in the documentation, it runs fine

  2. If you change the year to 2020 in situation 2, the route runs forever and never returns, which would cause Heroku's router to send back a 503 because your dyno is stuck processing. I don't know if its actually stuck, or taking a really long time but it's been running for over 10 minutes locally without returning - no errors from Node.

This is just one route that I checked because I thought it had the potential to be expensive.

I'm going to test all of these routes tonight and try to break them. Then I'm going to attempt to fix them.

If you don't have any objections we can start off by wrapping all the routes in a try/catch block that just returns an HTTP 500 if the catch block gets triggered. That will prevent hard crashes.

I would also recommend implementing default values for all parameters.

Beyond that, it's going to be profiling the routes for time constraints. Anything over 30s is going to cause a 503 on Heroku.

We could also implement caching to speed up repeated routes if you don't already have that.

Originally posted by @TimAagaard in #90 (comment)

not able to get some countries city

Hi!

Need help to get couple of countries cities. How can type in the get request if the country comes 2 or more seperate words for example:
https://countriesnow.space/api/v0.1/countries/population/cities/filter/q?limit=800000&order=asc&orderBy=name&country=

and the country is United Kingdom as you know I'll get an error code with this request :
https://countriesnow.space/api/v0.1/countries/population/cities/filter/q?limit=800000&order=
asc&orderBy=name&country=united kingdom

I tried many other options like united&kingdom, or united&20kingdom, or united-kingdom, or united_kingdom
could be better with iso3 code.
thanks, Robert

[bug][missing data] The Netherlands result in an internal server error

Hello

I'm facing issues with The Netherlands.

these endpoints return 404 country not found

POST https://countriesnow.space/api/v0.1/countries/cities

{
	"country": "Netherlands"
}

I've tried different variations of the country's name in addition to its informal name holland with different casing.

it's either 404 not found or internal server error.

Some countries inconsistent and missing

Data retrieved from endpoints inconsistent, this can lead to conflicts and inability to retrieve data across endpoints. If a country is retrieved from /countries/positions, that same country should be valid to retrieve data from /countries/cities

For instance in the endpoint
/countries/positions
South Korea is referred to as Korea, Republic of

/countries
South Korea becomes Korea South

Same inconsistency problem with Ivory Coast: in /countries/capital it is Ivory Coast but in /countries/positions it is Cote d'Ivoire.
Both Ivory Coast and Cote d'Ivoire returns country not found when querying /countries/cities

Duplicated cities in Brazil

I've detected some duplicated cities in Brazil:

Right name (to keep) Right ID Wrong name (to remove) Wrong ID
Xique-Xique 15643 Xique Xique 15642
Pindaré-Mirim 13850 Pindaré Mirim 13849
Tomé-Açu 15335 Tomé Açu 15334
Belém do São Francisco 10621 Belém de São Francisco 10618
Governador Dix-Sept Rosado 11981 Governador Dix Sept Rosado 11980
Ceará-Mirim 11227 Ceará Mirim 11226
Não-Me-Toque 13486 Não Me Toque 13485
Ji-Paraná 12630 Ji Paraná 12629
Guajará-Mirim 12020 Guajará Mirim 12019
Lauro Müller 12805 Lauro Muller 12804
Pariquera-Açu 13676 Pariquera Açu 13675
Embu-Guaçu 11692 Embu Guaçu 11690
Brodowski 10805 Brodósqui 10806

Also, "Residencia Moacir PU5BHV" (ID 14202) should be removed, as it isn't a city, it is a sublocality of "Rodeio" (ID 14328) city of "Santa Catarina" (ID 2014) state.

API Down

Not sure if this is the correct place to report this, but the API is currently down.
image

Thanks!

Add endpoint to get a random country on request.

Requirement

  • add a new /random endpoint that returns a random country object on request.
  • It is not yet clear what details of the country would be needed, but the basics for now.
    • name
    • iso2/3
    • dial code

Some cities are duplicated

A small list of some of the cities with duplicate entries.

  • Adamstown: 4,
  • Albany: 15,
  • Alberton: 5,
  • Albion: 12,
  • Alexandra: 2,
  • Alexandria: 16,
  • Alma: 12,
  • Alpine: 8,
  • Altona: 3,
  • Annandale: 4,
  • Ararat: 3,
  • Arcadia: 15,
  • Armadale: 3,
  • Ascot: 2,
  • Ashburton: 2,
  • Ashfield: 3,
  • Ashton: 7,
  • Atherton: 3,
  • Auburn: 17,
  • Augusta: 12,
  • Avalon: 5,

As soon as I have the duplicate free entries I'll do the PR.
Thank you,
peter81git

Cache all GET requests

The back-end data hasn't changed in a long time. There should be a decent performance boost to all routes, but particularly ones that call async data. We could also cache the async data once upon app start.

Missing Basel-Stadt

Hi,

Nice work!!

Last year you fix missing Basel as a city. But Basel-Stadt is also a Kanton. So the list of Kanton (oe states), which there are 26 in Switzerland, only lists 25 of them and miss Basel-Stadt.

"error" field in JSON response

Good day. Nice work you're doing here. I was going through the documentation and I noticed you add the error field to every JSON response. I want to know why exactly. because I assume that errors can be conveyed with appropriate error codes (status codes greater than or equal to 400). I believe that is the semantic use of those status codes. Is there a special reason you set the error field?

Multiple Redirects

Good day,

It would seem that the API for the Posts to get City with Region and Region in country has changed with more redirects than before. This looks to have changed in the past week. I use Bubble.io and the Bubble.io API, which allows for less than 10 redirects but it would seem you have more than 10. Can you confirm if changes were made and if this could be corrected as it was previously?

Curl:
curl --request POST 'https://countriesnow.space/api/v0.1/countries/state/cities'
--header 'Content-Type: application/json'
--data-raw '{
"country": "south africa",
"state": "gauteng"
}'

Error:

**There was an issue setting up your call.

Raw error for the API
Exceeded maxRedirects. Probably stuck in a redirect loop https://countriesnow.space/api/v0.1/countries/state/cities/q/q/q/q/q/q/q/q/q?

**

Thanks
Jan

Incorrect states

Hi,

The following states are in the wrong location.

  • Bonaire
  • Saba
  • Sint Eustatius

They currently fall under The Netherlands (NL), but they're supposed to be under Netherlands Antilles (AN).

Tried pushing and doing a pull request, but I'm receiving some errors.
Needs to be corrected in the following files.

countriesStateCity.js and countriesAndState.js

Svg images returns 404.

  • For the countries and flag images endpoint, some of the images return 404
    • Flag of Honduras
    • Flag of British Indian Ocean Territory
    • Flag of Guadeloupe
    • Flag of Heard Island and McDonald Islands
    • Flag of Honduras
    • Flag of Martinique
    • Flag of New Caledonia
    • Flag of Swaziland

Duplicate City Names

Cheers for a very useful set of API's.

However, There are some cities which are getting duplicated. e.g.

For the below API
https://countriesnow.space/swagger-docs/#/Cities/post_state_cities with the below data
{
"country": "India",
"state": "Telangana"
}

And the result, I see that some cities are getting duplicated e.g.

"Hyderabad",
"Hyderābād",

One more e.g for the same API with the below input data
{
"country": "India",
"state": "Andhra Pradesh"
}

You get the following duplicates in the output.
"Guntur",
"Guntūr",

Inconsistent State suffix: error fetching cities in lagos state

Hi @MartinsOnuoha

I guess i am known for these kinda issues by now😅, saw this one while watching hotjar's recordings,

After reviewing Issue #136 and its fix, we also need to do same with the StateCity by appending "state" to Lagos in model/countriesStateCity.js Line 486046 on the datastore.

More context

api/v0.1/countries/state/cities/q?country=Nigeria&state=kaduna%20state 200 OK
api/v0.1/countries/state/cities/q?country=Nigeria&state=niger%20state 200 OK
api/v0.1/countries/state/cities/q?country=Nigeria&state=lagos%20state 404 Not Found

Duplicate city IDs in countriesStateCity.js

{
              "id": 4822,
              "name": "French Guiana",
              "state_code": "GF",
              "cities": [
                  ....
                  { "id": 90328124, "name": 'Camopi', latitude: '3.1688700', longitude: '-52.3352500' },
                  { "id": 90328124, "name": 'Awala-Yalimapo', latitude: '5.741111', longitude: '-53.9277780' },
              ]
          },

Also City IDs:

  • 77028
  • 77123
  • 72123

Please advice.

同学,您这个项目引入了569个开源组件,存在6个漏洞,辛苦升级一下

检测到 MartinsOnuoha/countriesNowAPI 一共引入了569个开源组件,存在6个漏洞

漏洞标题:handlebars 安全漏洞
缺陷组件:[email protected]
漏洞编号:CVE-2021-23369
漏洞描述:handlebars是一款语义化的Web模板系统。
handlebars 4.7.7版本之前存在安全漏洞,该漏洞源于在选择某些编译选项来编译来自不受信任的源的模板时,handlebars容易受到远程代码执行(Remote Code Execution, RCE)的攻击。
国家漏洞库信息:https://www.cnvd.org.cn/flaw/show/CNVD-2021-29741
影响范围:(∞, 4.7.7)
最小修复版本:4.7.7
缺陷组件引入路径:[email protected]>[email protected]>[email protected]
[email protected]>[email protected]>[email protected]

另外还有6个漏洞,详细报告:https://mofeisec.com/jr?p=i31807

Spain provinces issue

There are three provinces in the States that I'd add as provinces since there is a mix between the Communities (States in our case) and the provinces. In order to minimize the double effort, I'd add the word province at the end to the following places:

  • Gipuzkoa
  • Biscay
  • Araba Álava

Thanks for your great work!

Multilangual names

Thanks for the great work
Can you guide me to create an Arabic version for this?

add endpoint to get cities within a state.

Within the ./model/countriesStateCity.js Files you'll find countries, their respective states, and cities within that state.

The goal is to be able to get all the cities within a state.
For example, given this data:

{
      "id": 1,
      "name": "Afghanistan",
      "iso3": "AFG",
      "iso2": "AF",
      "phone_code": "93",
      "capital": "Kabul",
      "currency": "AFN",
      "states": [
          {
              "id": 3901,
              "name": "Badakhshan",
              "state_code": "BDS",
              "cities": [
                  {
                      "id": 52,
                      "name": "Ashkāsham",
                      "latitude": "36.68333000",
                      "longitude": "71.53333000"
                  },
                  {
                      "id": 68,
                      "name": "Fayzabad",
                      "latitude": "37.11664000",
                      "longitude": "70.58002000"
                  },
                  {
                      "id": 78,
                      "name": "Jurm",
                      "latitude": "36.86477000",
                      "longitude": "70.83421000"
                  },
                  {
                      "id": 84,
                      "name": "Khandūd",
                      "latitude": "36.95127000",
                      "longitude": "72.31800000"
                  },
                  {
                      "id": 115,
                      "name": "Rāghistān",
                      "latitude": "37.66079000",
                      "longitude": "70.67346000"
                  },
                  {
                      "id": 131,
                      "name": "Wākhān",
                      "latitude": "37.05710000",
                      "longitude": "73.34928000"
                  }
              ]
          }

We need to be able to get the cities within "Badakhshan" by sending a POST request to the /state/cities endpoint with this payload:

{
   "state": "Badakhshan"
}

Question

is there a way to get 2 iso country code instead of 3 ?

Issue with Uppercase countries

This is small but I think it would make the experience better. In the docs where we get country position by name, where we send a POST Request to /api/v1.0/countries/positions with the country parameter in the body, I noticed that you capitalized it but in reality it doesn't return any data. I also tried with non-existent country names and it kept returning the same strings. For a moment there I thought the API was broken. So I took a look at https://github.com/MartinsOnuoha/countriesAndCitiesAPI/blob/1742ee9dd6c34bb306aac8a1c9f0304e6d190d60/controllers/countryController.js#L90 and found out that you weren't formatting the input to lowercase just the data from the model. Also I think it should fail when a non-existent country is sent. I could make a PR with the suggested changes if you want.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.