Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Jamie Baker
Jamie Baker
5,703 Points

Do you always need to declare an API key?

Hi, just mimicking the weather data app but trying to create it using a different API called OpenWeatherMap. I am actually getting data back in my console similar to the data Pasan got back. I called:

private let APIKey = "79d5ab442367e9bec588b0cb0796605b"

viewDidLoad() { super.viewDidLoad()

let baseURL = NSURL(string: "http://api.openweathermap.org/data/2.5/forecast/city?id=") let forecastURL = NSURL(string: "524901", relativeToURL: baseURL)


However, I get data back irrespective of declaring the API key that was given to me upon signing up at OpenWeatherMap.com. Just wondering why this is, and whether therefore the API key is always necessary? Thanks a lot.