Skip to main content

Metwit weather API client library

Project description

Metwit API for Python

A Python client for [Metwit weather API](

It's as simple as this:

from metwit import Metwit

weather =,

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'

What if I want to authenticate my app?

from metwit import Metwit

CLIENT_ID = '111111'
CLIENT_SECRET = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

metwit = Metwit(client_id=CLIENT_ID, client_secret=CLIENT_SECRET)
metwit.token_client_credentials(), location_lng=9.18)

Fine. This will allow me to use credits from my plan and make more API calls.

Posting data

Metwit API plans come with a number of `weather` calls you can make daily. You can overcome the limit by posting data. Every time you post meaningful data to Metwit, your limits will extend.

How? Post a `Metag`:

metag = {
'geo': {
'lat': 45.45,
'lng': 9.18,
'weather': {
'status': 'rainy',

`geo` is the only mandatory field. As an overview, a `Metag` object may contain weather status, measured data (temperature, pressure, humidity, etc) and sensory info (I feel hot/warm/etc). Detailed reference is available on the [Metwit API documentation page for metags](


All you need is the `Metwit` class.

### class **`metwit.Metwit`**`([client_id], [client_secret], [access_token], [refresh_token])`

*`client_id`* and *`client_secret`* come from the [Developer Dashboard]( You only need those if you registered an application. You shouldn't include a client secret if you are going to distribute the code of your application (as opposed to application code hosted on a server, or running on your machine, for example).

If you stored an *`access_token`* (and *`refresh_token`*) elsewhere you can pass them to the constructor, otherwise you can make unauthenticated calls, or obtain a token with `get_token()` or one of the shortcut methods.

#### `Metwit.metags`
#### ``
#### `Metwit.users`
These are the API resources. You can `.get()` and `.post()` these, or get
individual items with the subscript operator (e.g. `Metwit.metag['123456'].get()`).

#### `Metwit.get_token(grant_type, **kwargs)`
Calls the token endpoint to obtain an access token. The `Metwit` object stores the access token for you, so API calls after this will be authenticated.

#### `Metwit.dialog(redirect_uri, [scope], [state], [implicit])`
Returns the URL for the OAuth 2.0 authorization dialog. If you want to act in behalf of the users, you should redirect their browser to this URL.

#### `Metwit.token_auth_code(code, redirect_uri)`
This is a shortcut to `get_token()`. Use it when your users go through the
authorization dialog and you get the authorization code back.

#### `Metwit.token_client_credentials()`
This is a shortcut to `get_token()`. Use it when you just want to query the
weather and don't need to act in behalf of a user.

#### `Metwit.token_password(username, password, [scope])`
This is a shortcut to `get_token()`. Use it when you have the username and
the password of a Metwit user.

#### `Metwit.resource(uri)`
Use this when you have the URI of a resource and need to access it. E.g.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for metwit-weather, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size metwit-weather-0.1.0.tar.gz (3.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page