I want to get historical weather data (Winter 2014) of temperature, humidity, air-pressure, wind_speed, wind direction, rain in specific latitude/longitude.

Is there any API that I can use to get these informations.


For international and historical data, and for a modest number of requests per day, I personally recommend the Wunderground API. Once you register, you can get 500 free requests per day.

The URL for historical data will look like this:


I've posted a sample code (python 2.7) that you can use (and improve!) - LINK. I would run this code every day, just changing the year (currently it's set for 2013). The output of the code is a CSV file, but you can store the JSON and/or parse as needed.

  • Is there any way to specify lat/long to get that data ? Dec 31 '14 at 14:45
  • 1
    This endpoint gives you the closest city to a latitude/longitude - wunderground.com/weather/api/d/docs?d=data/geolookup
    – philshem
    Jan 1 '15 at 18:11
  • Anyone know how to use the API to get the weather at a specific historical time?
    – Guillochon
    Jan 2 '17 at 1:31
  • 1
    Wunderground API is now only available if you register a weather station to your account on the site apparently. That's the message I have when going into the API Key section in my profile: "No API key. You must own a Personal Weather Station in order to generate an API key."
    – Link14
    Jul 1 '20 at 1:56

I have written some sample code for directly building a CSV starting with a given date and ending with a given date: https://github.com/joshmalina/pollution/blob/master/notebooks/Build_historical_weather_data.ipynb

The city is currently set to Beijing, but you can change that easily. The data will also be cleaned of null values.


For Canada, you can download historical data by city in bulk csv or xml files from Environment & Climate Change Canada.

The example provided here uses wget to download all available hourly data for Yellowknife A, from 1998 to 2008, in .csv format

for year in `seq 1998 2008`;
    do for month in `seq 1 12`;
    do wget --content-disposition "http://climate.weather.gc.ca/climate_data/bulk_data_e.html?format=csv&stationID=1706&Year=${year}&Month=${month}&Day=14&timeframe=1&submit= Download+Data" ;

• year = change values in command line (seq 1998 2008)
• month = change values in command line (seq 1 12)
• format= [csv|xml]: the format output
• timeframe = 1: for hourly data
• timeframe = 2: for daily data
• timeframe = 3 for monthly data
• Day: the value of the "day" variable is not used and can be an arbitrary value
• For another station, change the value of the variable stationID
• For the data in XML format, change the value of the variable format to xml in the URL.

You can grab a list of stations from this csv or search for a station

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.