Best easy to use python weather api?

I am creating a project in witch i use a pi 0 W to power a unicorn hat to shine different colours depending on the outside temperature.

For this all i need is a simple python api that can access uk (more precisely cornish) temperature and a basic weather data (for feature expansions) , it also needs to be easy to use with good documentation.

Any suggestions.

Thanks for any help.

You could do a lot worse than to use the Dark sky API at https://darksky.net/dev/. You get 1000 calls to the API per day for free - more than enough for most uses. Beyond that it is still cost effective. Check the FAQs.
I use it for a couple of monitoring systems and it works very well.

and there is a Python wrapper for DarkSky at https://github.com/ZeevG/python-forecast.io

1 Like

How do I install the python wrapper?

usually, assuming you have the git-core package installed (if not, use “sudo apt-get install git-core” to get it) you’d do something like.

git clone https://github.com/ZeevG/python-forecast.io
cd python-forecast.io
sudo python setup.py install

to set up the library, and then to use it, import the library in your python script

import python-forecast.io

Once you’ve done that, you can edit example.py with your own data (including the API key you need to get from the service)to get the data you want. In my case, the top of the file looks like this

import datetime
import forecastio

def main():
    """
    Run load_forecast() with the given lat, lng, and time arguments.
    """

    api_key = "redacted"

    lat = 53.38
    lng = -1.22
    time = datetime.datetime(2017, 4, 13, 6, 0, 0)

    ...more....

and the output looks like this on the console

===========Currently Data=========
<ForecastioDataPoint instance: Mostly Cloudy at 2017-04-13 05:00:00>
===========Hourly Data=========
Hourly Summary: Mostly cloudy starting overnight.
<ForecastioDataPoint instance: Partly Cloudy at 2017-04-12 23:00:00>
<ForecastioDataPoint instance: Clear at 2017-04-13 00:00:00>
<ForecastioDataPoint instance: Partly Cloudy at 2017-04-13 01:00:00>
<ForecastioDataPoint instance: Partly Cloudy at 2017-04-13 02:00:00>
<ForecastioDataPoint instance: Partly Cloudy at 2017-04-13 03:00:00>
<ForecastioDataPoint instance: Mostly Cloudy at 2017-04-13 04:00:00>
<ForecastioDataPoint instance: Mostly Cloudy at 2017-04-13 05:00:00>
<ForecastioDataPoint instance: Mostly Cloudy at 2017-04-13 06:00:00>
<ForecastioDataPoint instance: Mostly Cloudy at 2017-04-13 07:00:00>
<ForecastioDataPoint instance: Mostly Cloudy at 2017-04-13 08:00:00>
<ForecastioDataPoint instance: Mostly Cloudy at 2017-04-13 09:00:00>
<ForecastioDataPoint instance: Mostly Cloudy at 2017-04-13 10:00:00>
<ForecastioDataPoint instance: Mostly Cloudy at 2017-04-13 11:00:00>
<ForecastioDataPoint instance: Mostly Cloudy at 2017-04-13 12:00:00>
<ForecastioDataPoint instance: Mostly Cloudy at 2017-04-13 13:00:00>
<ForecastioDataPoint instance: Overcast at 2017-04-13 14:00:00>
<ForecastioDataPoint instance: Overcast at 2017-04-13 15:00:00>
<ForecastioDataPoint instance: Mostly Cloudy at 2017-04-13 16:00:00>
<ForecastioDataPoint instance: Mostly Cloudy at 2017-04-13 17:00:00>
<ForecastioDataPoint instance: Mostly Cloudy at 2017-04-13 18:00:00>
<ForecastioDataPoint instance: Mostly Cloudy at 2017-04-13 19:00:00>
<ForecastioDataPoint instance: Mostly Cloudy at 2017-04-13 20:00:00>
<ForecastioDataPoint instance: Partly Cloudy at 2017-04-13 21:00:00>
<ForecastioDataPoint instance: Partly Cloudy at 2017-04-13 22:00:00>
===========Daily Data=========
Daily Summary: None
<ForecastioDataPoint instance: Mostly cloudy throughout the day. at 2017-04-12 23:00:00>

Even easier … from the readme

Installation

You should use pip to install python-forecastio.

To install pip install python-forecastio
To remove pip uninstall python-forecastio
Simple!

I’ve tried that but it gives me an error

Can you copy/paste what you tried and the responses?

this happens (sorry bout the reflections )

you need to run the command with elevated privileges:

sudo pip install python-forecastio