How to find 7 days weather forecast in openweather API?

I am trying to find 7 days weather forecast using openweather API , but when I am calling the openweather API then the data are not coming for the current location, can anyone guide me to find the correct API to get weather forecast for the current location. API's used so far

1. api.openweathermap.org/data/2.5/forecast?q=&appid= 2. https://api.openweathermap.org/data/2.5/onecall?lat=&lon=&exclude=&appid=
  1. https://openweathermap.org/forecast5
  2. https://openweathermap.org/api/one-call-api

Request: https://api.openweathermap.org/data/2.5/forecast?q=India&appid= Response: (Added only 2 days data out of 40)

< "cod": "200", "message": 0, "cnt": 40, "list": [ < "dt": 1600668000, "main": < "temp": 283.42, "feels_like": 282.81, "temp_min": 283.42, "temp_max": 284.26, "pressure": 1018, "sea_level": 1018, "grnd_level": 862, "humidity": 84, "temp_kf": -0.84 >, "weather": [ < "id": 802, "main": "Clouds", "description": "scattered clouds", "icon": "03d" >], "clouds": < "all": 32 >, "wind": < "speed": 0.1, "deg": 22 >, "visibility": 10000, "pop": 0, "sys": < "pod": "d" >, "dt_txt": "2020-09-21 06:00:00" >, < "dt": 1600722000, "main": < "temp": 283.34, "feels_like": 282.29, "temp_min": 283.34, "temp_max": 283.34, "pressure": 1016, "sea_level": 1016, "grnd_level": 861, "humidity": 86, "temp_kf": 0 >, "weather": [ < "id": 500, "main": "Rain", "description": "light rain", "icon": "10n" >], "clouds": < "all": 66 >, "wind": < "speed": 0.82, "deg": 149 >, "visibility": 823, "pop": 0.35, "rain": < "3h": 0.18 >, "sys": < "pod": "n" >, "dt_txt": "2020-09-21 21:00:00" > ], "city": < "id": 3168508, "name": "Innichen", "coord": < "lat": 46.7406, "lon": 12.2797 >, "country": "IT", "population": 3107, "timezone": 7200, "sunrise": 1600664205, "sunset": 1600708262 > > 
Subhasish Mishra asked Sep 21, 2020 at 12:56 Subhasish Mishra Subhasish Mishra 13 1 1 gold badge 1 1 silver badge 4 4 bronze badges Can you include the request and the response to the API and any errors you're receiving? Commented Sep 21, 2020 at 13:45

Have you retrieved an API key yet? If not, follow the steps to get one here openweathermap.org/appid . If you're just starting out, I would recommend focusing on the one call (openweathermap.org/api/one-call-api) API (since it is free).

Commented Sep 21, 2020 at 14:00

@elderlyman I have collected my API key, but it is not showing the forecast for the current location. Whatever location I am giving the same response comes every time.

Commented Sep 21, 2020 at 14:44 @ZachValenta I have added request and response please check. Commented Sep 21, 2020 at 14:59

Please note that your request contains q=India but your response is coming back with "country": "IT" and "name": "Innichen" . For some reason, if you ask for results for India, the server is giving results for a city called Innichen in Italy. Let's clarify - what city name would you like results for?

Commented Sep 21, 2020 at 15:26

2 Answers 2

You have a lot of issues and it would be helpful if you could narrow them down. But here's my best shot at helping in every way that I can:

For a 7 day forecast, you need to request a 7 day forecast..

In your example for a request 1. api.openweathermap.org/data/2.5/forecast?q=&appid= you also included a link that you used which is for a 5 day request. That's a problem if you want 7 days.

If you want a 5 day forecast, the API you cited in your first example requires a city name and (if you want to include a country) it requires that the country name be in ISO 3166 so India would be "IND" not INDIA.

Whether you want a 5 day or a 7 day, you will need to be more specific than INDIA.

In the case of a 5 day, you will need a city name. For a 5 day forecast for Mumbai, you can use the API you tried in the first example like this:

 "https://api.openweathermap.org/data/2.5/forecast?q=mumbai&appid=" 

In the case of a 7 day, you will need latitude and longitude coordinates.
For a 7 day forecast for Mumbai, you can use the API you tried in your second example like this:

 //includes lat and long for mumbai "https://api.openweathermap.org/data/2.5/onecall?lat=19.0760&lon=72.8777&appid=" 

I hope this answers your question.