I can't retrieve the fields according to their type (see my example below). I always get the following message: "KeyError: 'ozone"

I have never encountered this problem with other APIs of this type. It is a real pity that your documentation is not more provided as examples.

Could you tell me what's wrong or give me an example?

import requests

def get_data():

app_id = 'MYAPI'
city_name = 'Raleigh'
country_code = 'NC'
api_call = 'http://api.weatherbit.io/v2.0/forecast/hourly?city=' + city_name + ',' + country_code + '&key=' + app_id + '&lang=en&hours=48'

r = requests.get(api_call)

data = r.json()




Category: API


John says:
June, Saturday, 2019 at 5:38PM

Hello Jean Jacque,

The API returns a JSON object, with an array (data:) of forecast elements. The correct way to access the first forecast hour's ozone field would be:


  • John at Weatherbit

Leave A Reply

What is eight minus 2?