final String FORECAST_BASE_URL =
"http://api.openweathermap.org/data/2.5/forecast/daily?";
final String QUERY_PARAM = "q";
Hello. I'm making a weather forecast app. But when I use "http://openweathermap.org"'s API, I stock in trouble how can I get the city code or ID "q"? I try to find the city ID but I can't.
Example code Call by city ID:
api.openweathermap.org/data/2.5/forecast/daily?id=524901
and I heard that "q" is used to "id" also. I mean
api.openweathermap.org/data/2.5/forecast/daily?q=524901
is also possible. i want to do like this.
So, How to find city id? Anybody knows?
Before contacting SiriusXM, the Weather ID and Radio ID of the weather antenna will need to be determined. These numbers can be found on the bottom of the antenna.
Once you sign up using your email, the API key (APPID) will be sent to you in a confirmation email. Your API keys can always be found on your account page, where you can also generate additional API keys if needed.
Open the Weather app, then tap the Add icon (at the top of the screen). Enter a location in the Search city box, then tap the city you want to add. Tap Current location (at the top of the screen) to update your current location.
There is a similar question that was asked in the OpenWeatherMap support center. Here is the link OpenWeatherMap
Also, here is a link to the list of cities and their respective ID's (just CTRL + F to find the city you want): List of Cities & IDs
A full list of CityID's can be downloaded from: http://bulk.openweathermap.org/sample/city.list.json.gz
You can manually search that file (after unzipping it) for your city name or search from the shell like:
grep -i "london" city.list.json
Regarding the "q" vs. "id" query tags: you can search by city (and country) using the "q" tag like this:
http://api.openweathermap.org/data/2.5/forecast/daily?q=London,GB
(note that the country code isn't necessarily required)
and that works as long as there is no question about which city. If there's multiple cities of the same name in a country, though, you can use the CityID to specify a certain one after you've found the correct identifier in the list linked above like this:
http://api.openweathermap.org/data/2.5/forecast/daily?id=2643743
which also returns London's weather, but ensures you don't accidentally get the weather for London, Kentucky, USA or London, Ohio, USA if you've chosen not to use the country code in the "q" tag.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With