A weather API to monitor precipitations at a given location

image


Here we are!

We’ve just deployed a kickass new weather API to receive precipitation alerts nearby a given location.

To put it shortly, every time it’ll start raining at a location of your choice, you’ll be able to receive a callback to your servers. Yes, you got that right: push weather notifications.

Some awesome implementation ideas:

  • Would you like to receive a phone call or an SMS whenever it starts raining at home, or snowing at your favorite ski resort? Try Metwit weather API + Twilio API.

     

  • Would you like to play a beautiful “rainy” Stereomood playlist to simulate the weather at your girlfriend’s secluded amazonian village? Try Metwit weather API + Stereomood API.

     

  • Would you like to post a job on TaskRabbit when it starts snowing, to find someone willing to shovel your frontyard? Try Metwit weather API + TaskRabbit API.

     

If you wish to know more give a good look at our weather api monitor documentation and most of all, if you still wish to ask us something, tweet or email us!

We’re hungry for feedback as this is the first version of this new API.

So… Let’s go!

A weather API for your Internet Of Things next innovative sensing device

image


Finally!

Now you can post real time weather data without having to authenticate a Metwit user. No more OAuth dialog!

All you’ll need is to get an access_token as an application, no longer an access_token as a Metwit user, and to post with using that token.

With our Python Weather SDK, you can send an anonymous MeTag like this:

metwit = Metwit(client_id=CLIENT_ID, client_secret=CLIENT_SECRET)
metwit.token_client_credentials()
metag = metwit.metags.post(
   dict(weather=dict(status="clear"),
        geo=dict(lat=45.45, lng=9.18),
        )
)

Easy, isn’t it?

Of course, there’s an API to receive all of the MeTags submitted by your applications:

GET /v2/metags/?client_id=[client_id]

Now, lacking the authorization through Metwit’s dialogs, you will of course be unable to profile your users and to add the social layer Metwit offers to your applications. MeTags will not be associated to people, but to a single author: your app.

For a sports app, for example, were interaction among users is fundamental, I would recommend using the dialogs, so you can offer a profile to each user and create a community made up of real people.

In other kinds of automated applications: internet of things devices or sensing device apps, such as an Internet connected weather station with Raspberry PI, like this, or a pressure data app, like pressureNET, I would recommend using the Anonymous MeTag POST without involving the single user.

Let us know your thoughts and ideas!

Weather Ruby gem for Metwit weather API

Hello fellow rubyists, nice to meet you!
Did you hear that explosion from the caves in Yahoo Land?

Yes, it was their rusty, unusable, shitty API that finally exploded.

Fear no more my miners friends, today is finally available a weather ruby gem for the Metwit REST Weather API.

Install the gem with:

gem install metwit

Then register your application to our weather API in order to obtain a client_id and a client_secret.

Require it in your code and setup it like that:

Metwit.client_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Metwit.client_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Metwit.get_access_token

Then to get weather and forecast it’s a single method.

Metwit::Weather.in_location(latitude, longitude)

YES, you hear me: no fucking lookup of the location in a database, no XML, no shenanigans! Just plain JSON translated in sweeeeeeet ruby objects.

C’mon grab your pickaxe and start mining using our beautiful APIs.

Enjoy the weather

Metwit Weather API, an alternative to Yahoo! Weather API

image

Two days ago, Yahoo! dismissed its geocoding API from use. The API which, given a lat, lng coordinates group, gave a WOEID back is no longer available:

http://where.yahooapis.com/geocode?q=43.771033,11.248001&gflags=R

See for yourselves: the url above now displays a 404 message. 

As a consequence, it is no longer possible to easily, quickly, and freely use the Yahoo! weather APIs that relied on a WOEID as a parameter, through a call like this:

http://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where woeid=’WOEID’ and u=’c’&format=json

The updated and supported method to receive the WOEID is to use the paid for Yahoo! BOSS Search API, after filling a form complete with your credit card number. Here’s a discussion about this topic. ;)

Yahoo! is dead, long live Metwit!

So, you used to rely on Yahoo! weather APIs and are now feeling stranded? Don’t panic! There are some alternatives, one of which has been developed by yours truly. If you’re looking for an alternative REST with JSON response for weather data, both real time and forecast, you should try Metwit’s weather APIs.

They are dead easy to use and, and for test phase, you can use it without authentication:

https://api.metwit.com/v2/weather/?location_lat=45.45&location_lng=9.18

A call like this one above will give you back real time weather and forecasts.

The unique characteristic of our APIs is that they’re built around a crowdsourcing approach, and you can both send and receive data to and from your client (write us to learn more or visit our Developers page).

Within a week, we intend to release a free plan (‘till June) with 5000 calls/day, and we’re also considering and selecting 5 applications to which to offer custom free plans for one year.

If you have a nice app, with a cool concept and neat design, contact me right away at duccio@metwit.com, indicating:

  • App name and description

  • URL (if it is already available in stores or online as a webapp)

  • Estimated calls/day need

And I will evaluate your requests ASAP. :)

Hack the weather with us!

Python weather by Metwit

Hooray, the first Metwit Python SDK is here!

Now you can play around with our amazing weather API. :)

This first version contains the basic functionalities of our API:

– Receiving forecasts for a given location

– Receiving real-time weather for a given location

– Posting real-time weather data from a location

In order to receive real-time weather data and forecasts, all it takes is a couple line of code:

from metwit import Metwit
weather = Metwit.weather.get(location_lat=45.45, location_lng=9.18)

Good! Hope it’s not raining.

# weather[0] is the real-time weather in a location
if weather[0]['weather']['status'] == 'rainy': 
    print 'Better take my umbrella with me' 

The other elements of the weather array will contain weather forecasts.

In order to post real-time data, on the other hand, it is necessary to be authenticated.

How can I authenticate my app?

You need to create an application first!

You can start here: http://metwit.com/developers/quickstart/

Then, one you’ve obtained a CLIENT_ID and CLIENT_SECRET, you can:

from metwit import Metwit
CLIENT_ID = '111111'
CLIENT_SECRET = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' 
metwit = Metwit(client_id=CLIENT_ID, client_secret=CLIENT_SECRET) metwit.token_client_credentials() metwit.weather.get(location_lat=45.45, location_lng=9.18)

Alright! This will allow you to consume your credit and obtain more bonus API calls. :)

Now, on to posting real-time weather data:

Metwit API plans come with a number of daily weather calls you can make.

In detail:

Authenticated requests:
200 requests per app, 200 per IP once that first threshold is passed

Non-authenticated requests:
200 per IP.

It will be possible for you to overcome this limit by posting data.

Every time you post meaningful data to Metwit, those limits will become broader and broader.

How? Post a Metag:

metag = { 
'geo': { 'lat': 45.45, 'lng': 9.18
}, 'weather': {
'status': 'rainy'
} }
metwit.metags.post(metag)

For more details and the full documentation, see this link:

Metwit Python SDK Documentation

Check it out and let us know what you think of this first version!

Getting an access token to use Metwit Weather API

Judging from the first feedback we’ve received, there appears to be some uncertainty on how to get a valid access token to start testing our weather API.

This tutorial intends to explain step by step the easiest authentication procedure (‘client credentials’), so you can quickly and easily start using our weather resource.

Here’s the steps for this process:

  1. Register with Metwit
  2. Create an application
  3. Copy client_id and client_secret
  4. Get an access_token
  5. Call /weather/ resources

STEP 1

Navigate here and complete the registration procedure:

image

STEP 2

Once you’re done registering, you need to create an application:

image

STEP 3

Now you need to fetch the newly generated client_id and client_secret:

image

STEP 4

Now that you have a client_id and a client_secret, you can get an access token with a POST request using cURL:

image

For your convenience, here’s the request we’ve used in the screenshot above:

curl --user client_id:client_secret -F "grant_type=client_credentials" https://api.metwit.com/token/

STEP 5

Once the request successfully resulted in you getting your access_token, you can call the weather resource:

image

Again, here’s the request we’ve used:

curl -H "Authorization: Bearer $ACCESS_TOKEN" "https://api.metwit.com/v2/weather/?location_lat=45.45&location_lng=9.18"

And that’s it!

As you can see in our screenshot, the answer to the call is correct, as described in the documentation.

If you have further doubts, tweet us @metwitdev or write us info@metwit.com .

Simple weather widget in PHP with Metwit Weather API

Here we are!

Today I’ll explain you how to create a simple weather widget in PHP to show real time weather in a given location, using Metwit’s Weather API and with the help of Mashape, which will provide us an SDK ready to use with Metwit APIs.

Quick and simple steps:

  1. Get an account on Mashape
  2. Get public and private keys from Mashape
  3. Download the sample widget pack
  4. Edit the index.php file with the Mashape credentials previously obtained, and a desired location
  5. Upload to your servers and include the script wherever you want

STEP 1

Register to Mashape here.

STEP 2

Once you complete your registration with Mashape, you will need to get Mashape’s public and private keys, which you will use in your PHP script.

STEP 3

Download here.

STEP 4

Open the widget.php file and edit line 12 by adding in the public and private keys you have previously obtained:

image

Now scroll down to line 17: here you can edit in the coordinates of the location you want to display in your widget (first latitude, then longitude):

image

STEP 5

I used the index.php file to style and edit the widget as I pleased. You can, of course, create your own container div to better manage the widget.php file, to show the information you want, as you want.

Here’s my sample widget:

image

And that’s it!

Have fun and keep hacking the weather with our weather API!

P.s you can of course fork the repo on GitHub.

Here we go…

…with our brand new techy blog.
Stay tuned!