@@ -7,73 +7,57 @@ simple script which prints out data in just 6 lines of Python.
77API Key
88-------
99
10- To access DataPoint you need to
11- ` register < http://www.metoffice.gov.uk/datapoint/API >`__ with the Met
12- Office and get yourself an API key. The process is simple and just
13- ensures that you don’t abuse the service .
10+ To access DataPoint you need to ` register < https://datahub.metoffice.gov.uk/ >`__
11+ with the Met Office and get yourself an API key. The process is simple and just
12+ ensures that you don’t abuse the service. You will need access to the
13+ Site-Specific forecast API .
1414
15- Connecting to DataPoint
15+ Connecting to DataHub
1616-----------------------
1717
18- Now that we have an API key we can import the module:
18+ Now that you have an API key you can import the module:
1919
2020::
2121
2222 import datapoint
2323
24- And create a connection to DataPoint :
24+ And create a connection to DataHub :
2525
2626::
2727
28- conn = datapoint.connection (api_key="aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
28+ manager = datapoint.Manager (api_key="aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
2929
30- This creates a :ref: `manager ` object which manages our connection and interacts
31- with DataPoint for us, we’ll discuss Manager Objects in depth later but for now
32- you just need to know that it looks after your API key and has a load of methods
33- to return data from DataPoint.
30+ This creates a `manager ` object which manages the connection and interacts
31+ with DataHub.
3432
35- Getting data from DataPoint
33+ Getting data from DataHub
3634---------------------------
3735
38- So now that we have our Manager Object with a connection to DataPoint we can
39- request some data. Our goal is to request some forecast data but first we need
40- to know the site ID for the location we want data for. Luckily the Manager
41- Object has a method to return a :ref: `site ` object, which contains the ID among
42- other things, from a specified latitude and longitude.
43-
44- We can simply request a Site Object like so:
45-
46- ::
47-
48- site = conn.get_nearest_forecast_site(51.500728, -0.124626)
49-
50- For now we’re just going to use this object to get us our forecast but
51- you’ll find more information about what the Site Object contains later.
52-
53- Let’s call another of the Manager Object’s methods to give us a
54- :ref: `forecast ` object for our site:
36+ So now that you have a Manager object with a connection to DataHub you can
37+ request some data. To do this, use the `manager ` object:
5538
5639::
5740
58- forecast = conn.get_forecast_for_site(site.location_id, "3hourly ")
41+ forecast = manager.get_forecast(51, 0, "hourly ")
5942
60- We’ve given this method two parameters, the site ID for the forecast we want and
61- also a forecast type of “3hourly”. We’ll discuss the forecast types later on.
43+ This takes three parameters: the latitude and longitude of the location you want
44+ a forecast for and also a forecast type of “hourly”. We’ll discuss the forecast
45+ types later on.
6246
6347This Forecast Object which has been returned to us contains lots of information
6448which we will cover in a later section, right now we’re just going to get the
65- :ref: ` timestep ` object which represents right this minute :
49+ data for the current time :
6650
6751::
6852
69- current_timestep = forecast.now()
53+ current_weather = forecast.now()
7054
71- This Timestep Object contains many different details about the weather
72- but for now we’ll just print out the weather text .
55+ This is a dict which contains many different details about the weather
56+ but for now we’ll just print out one field .
7357
7458::
7559
76- print current_timestep.weather.text
60+ print(current_weather["feelsLikeTemperature"])
7761
7862And there you have it. If you followed all the steps you should have
7963printed out the current weather for your chosen location.
0 commit comments