Public and up-to-date API for getting country, state, city - api

I need an API for getting country, state, city.
I need to get by following endpoints
/somepath - for countries
/:countryName - for states
/:stateName - for cities.
If you know any up to date API for this task, please write a comment about it.
Thanks

Related

How to check user is within given Country or not using reverse geocode. "HereMap Reverse Geocode"

I want to get reverse geocode of Here map to fetch user postalCode with specified Country. So, if user is not in that Country, it should give error/warning message.
How about enabling the parameter show->countryInfo on the request so that we receive the country info in the response, and then do your own client-side checking for that country? https://developer.here.com/documentation/geocoding-search-api/api-reference-swagger.html

amadeus api where if the list of all cityCodes

In Amadeus API the is often a reference to "cityCode"
The documentation give this example
https://test.api.amadeus.com/v2/shopping/hotel-offers?cityCode=PAR&adults=1&radius=5&radiusUnit=KM&paymentPolicy=NONE&includeClosed=false&bestRateOnly=true&view=FULL&sort=PRICE
Where is the list of ALL cityCode ???
for this example it seems PAR refers to PARIS
is this https://service.unece.org/trade/locode/fr.htm
is there a cvs format of all city codes ?
Thanks
You can use the Airport & City Search API to find an IATA code based on a city name
Otherwise, this website provides a list of IATA city codes.

Restful context or entity?

What's the best approach to bring information about an object in a Rest API?
All the entire object always:
Request:
GET /user/{idUser}
Response:
{
id,
name,
birthday,
street,
city,
state,
country
}
Part that matters in an object, identified by context:
Request:
GET /user/address/{idUser}
Response:
{
id,
street,
city,
state,
country
}
(2) should be avoided because it leads to a proliferation of endpoints. (1) is acceptable, but may be a performance hit because it pushes more information than is required over the wire. If you test the performance and find it unacceptable, you can provide something like this:
GET /users/bob?fields=id,street,city,state,country
{
id,
street,
city,
state,
country
}

ESPN API - How can I retrieve college basketball conferences using the Teams API?

The support forums on ESPN.com recommend using Stack Overflow with the ESPN tag. That's why I'm here.
I'm trying to obtain a list of all NCAA college basketball teams using ESPN's Teams API. I started with this GET request:
http://api.espn.com/v1/sports/basketball/mens-college-basketball/teams?apikey=MY_API_KEY
That gave me a list of teams, but many of them are missing. For example, there is no Nebraska. So then I thought that maybe I need to get a list of teams by conference. So I read this in the documentation:
GROUPS: Allows for filtering by "group" or division, e.g. AL East, NFC South, etc. For group IDs and their corresponding values, make a request to http://developer.espn.com/v1/{resource}/leagues. Not applicable to golf and tennis.
So then I try to make a request to `http://developer.espn.com/v1/sports/basketball/mens-college-basketball/leagues?apikey=MY_API_KEY' and it says the page does not exist.
Is this a bug or user error?
First, I think you forgot sports in the resource. Try this:
http://api.espn.com/v1/sports/basketball/mens-college-basketball?apikey=MY_API_KEY&leagues
That will return a mapping of integers to conferences it seems according to the documentation.
That fetched me:
{"name" :"Atlantic Coast Conference","abbreviation" :"acc","groupId" :2,"shortName" :"ACC"}
...and much more.
Then once you have that, let's say 2 = ACC. You should be able to do this:
http://api.espn.com/v1/sports/basketball/mens-college-basketball?groups=2&apikey=MY_API_KEY'
to get everything on ACC mens' basketball teams.
Bear in mind the API is in beta though.
I could not figure out how to get a list of conferences, but I found out how to get the missing teams. When I was making the first get request, it was limiting me to 50 results by default:
http://api.espn.com/v1/sports/basketball/mens-college-basketball/teams?apikey=MY_API_KEY
They have a sandbox where you can play with your parameters, and I saw a limit and offset option:
http://developer.espn.com/io-docs
To get more than 50 results, you have to make multiple requests using the limit and offset parameters.
First Call:
http://api.espn.com/v1/sports/basketball/mens-college-basketball/teams/?limit=50&offset=0&_accept=text%2Fxml&apikey=MY_API_KEY
Next Call:
http://api.espn.com/v1/sports/basketball/mens-college-basketball/teams/?limit=50&offset=50&_accept=text%2Fxml&apikey=MY_API_KEY
And so on...

Google map geocoding address parser

I want to parse the addresses from Google geocoding API and store it as:
address
city
state
zipcode
country
Some places has full address from Google map and some just half, how can i know which part of the address is city, state or country? or just zipcode?
It would be helpful if some expert pointed out some help here.
In the response the geocoding API breaks up the address into AdministrativeAreaName (usually State) and SubAdministrativeArea. The SubAdministrativeArea area includes LocalityName (City), PostalCodeNumber (Zip Code) and Thoroughfare (Street Name and Number). For an example see: http://maps.google.com/maps/geo?q=1%20Infinite%20Loop,%20Cupterino,%20Ca. This is a geocode requst for Apple's Headquarters which has an address of 1 Infinite Loop, Cupterino, CA 95014.