3

I'm wondering if I can call in one request using openweathermap api to get data about (today & all weekdays) at once! I tried this >>

http://api.openweathermap.org/data/2.5/weather?q=london&units=metric&APPID=value

and it gives data for only today

then I tried forecast

http://api.openweathermap.org/data/2.5/forecast/?q=london%2&cnt=7&units=metric&APPID=value

and also this gives me data about some weekdays.

is there any way to get all (today & weekdays ) in one request ?

josliber
  • 43,891
  • 12
  • 98
  • 133
Dev HH
  • 91
  • 1
  • 2
  • 7

2 Answers2

3

The api docs at http://openweathermap.org show that there's a "forecast16" api, documented at http://openweathermap.org/forecast16.

The docs say that you can call

api.openweathermap.org/data/2.5/forecast/daily?q={city name},{country code}&cnt={cnt}

and that {cnt} is number of day's worth of data that you are requesting (from 1 to 16)

So, in your case,

http://api.openweathermap.org/data/2.5/forecast/daily?q=london&units=metric&APPID=value&cnt=7

should give you 7 day's data.

GreyBeardedGeek
  • 29,460
  • 2
  • 47
  • 67
  • thanks @GreyBeardedGeek for your help but the response json days list doesn't contain date attribute ... so how can i distinguish them !! and how to know today weather !! – Dev HH Jul 25 '16 at 04:35
  • Each day's forecast contains a "dt" entry, which is a numeric long that is a Unix-style timestamp. In the case of the example in the documentation, this value is 1406080800, which translates to Wed, 23 Jul 2014 02:00:00 GMT For info on how to do the conversion, see http://stackoverflow.com/questions/3371326/java-date-from-unix-timestamp – GreyBeardedGeek Jul 25 '16 at 13:34
0

16 day forecasts is available at any location or city. Forecasts include daily weather and available in JSON or XML format. It is only available for all paid accounts.

https://openweathermap.org/forecast16

Arto
  • 71
  • 3
  • 1
    7-day forecast (https://openweathermap.org/api/one-call-api) under 1000 calls is available in free plan(https://openweathermap.org/price), and it looks like OP didn't ask for 16 days, especially that they have `&cnt=7` in their example. Also, the question was asked 3 years ago, and one call api was added only recently, but still, 7-day forecast is still available for free even though limited by count. – Pavlus Jun 22 '20 at 15:14