Slide 14
Slide 14 text
Netatmo API
require 'net/https'
require 'json'
require 'uri'
token_uri = URI('https://api.netatmo.com/oauth2/token')
res = Net::HTTP.post_form(
token_uri,
grant_type: 'password',
client_id: 'xxx',
client_secret: 'xxx',
username: 'xxx',
password: 'xxx',
scope: 'read_station'
)
access_token = JSON.parse(res.body)['access_token']
api_uri = URI.parse('https://api.netatmo.com/api/getstationsdata')
http = Net::HTTP.new(api_uri.host, api_uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(api_uri.path)
req.set_form_data(access_token: access_token)
res = http.request(req)
data = JSON.parse(res.body)
puts JSON.pretty_generate(data)
https://dev.netatmo.com/en-US/resources/technical/samplessdks/tutorials