{ "info": { "author": "Metwit", "author_email": "info@metwit.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Topic :: Internet" ], "description": "Metwit API for Python\r\n=====\r\n\r\nA Python client for [Metwit weather API](http://metwit.com/developers/).\r\n\r\nIt's as simple as this:\r\n\r\n from metwit import Metwit\r\n\r\n weather = Metwit.weather.get(location_lat=45.45,\r\n location_lng=9.18)\r\n\r\nGood! Hope it's not raining.\r\n\r\n # weather[0] is the real-time weather in a location\r\n if weather[0]['weather']['status'] == 'rainy':\r\n print 'Better take my umbrella with me'\r\n\r\nWhat if I want to authenticate my app?\r\n\r\n from metwit import Metwit\r\n\r\n CLIENT_ID = '111111'\r\n CLIENT_SECRET = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'\r\n\r\n metwit = Metwit(client_id=CLIENT_ID, client_secret=CLIENT_SECRET)\r\n metwit.token_client_credentials()\r\n\r\n metwit.weather.get(location_lat=45.45, location_lng=9.18)\r\n\r\nFine. This will allow me to use credits from my plan and make more API calls.\r\n\r\nPosting data\r\n-----\r\n\r\nMetwit 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.\r\n\r\nHow? Post a `Metag`:\r\n\r\n metag = {\r\n 'geo': {\r\n 'lat': 45.45,\r\n 'lng': 9.18,\r\n }\r\n 'weather': {\r\n 'status': 'rainy',\r\n },\r\n }\r\n metwit.metags.post(metag)\r\n\r\n`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](http://metwit.com/developers/docs/resources/metags/).\r\n\r\nReference\r\n----\r\n\r\nAll you need is the `Metwit` class.\r\n\r\n### class **`metwit.Metwit`**`([client_id], [client_secret], [access_token], [refresh_token])`\r\n\r\n*`client_id`*\u00a0and *`client_secret`* come from the [Developer Dashboard](https://metwit.com/developers/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).\r\n\r\nIf 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.\r\n\r\n#### `Metwit.metags`\r\n#### `Metwit.weather`\r\n#### `Metwit.users`\r\nThese are the API resources. You can `.get()` and `.post()` these, or get\r\nindividual items with the subscript operator (e.g. `Metwit.metag['123456'].get()`).\r\n\r\n#### `Metwit.get_token(grant_type, **kwargs)`\r\nCalls 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.\r\n\r\n#### `Metwit.dialog(redirect_uri, [scope], [state], [implicit])`\r\nReturns 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.\r\n\r\n#### `Metwit.token_auth_code(code, redirect_uri)`\r\nThis is a shortcut to `get_token()`. Use it when your users go through the\r\nauthorization dialog and you get the authorization code back.\r\n\r\n#### `Metwit.token_client_credentials()`\r\nThis is a shortcut to `get_token()`. Use it when you just want to query the\r\nweather and don't need to act in behalf of a user.\r\n\r\n#### `Metwit.token_password(username, password, [scope])`\r\nThis is a shortcut to `get_token()`. Use it when you have the username and\r\nthe password of a Metwit user.\r\n\r\n#### `Metwit.resource(uri)`\r\nUse this when you have the URI of a resource and need to access it. E.g.\r\n`metwit.resource('/v2/metags/123456/').get()`.", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/metwit/metwit-python", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/metwit/metwit-python", "keywords": "weather rest api metwit", "license": "UNKNOWN", "maintainer": "Davide Rizzo", "maintainer_email": "davide@metwit.com", "name": "metwit-weather", "package_url": "https://pypi.org/project/metwit-weather/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/metwit-weather/", "project_urls": { "Download": "https://github.com/metwit/metwit-python", "Homepage": "http://github.com/metwit/metwit-python" }, "release_url": "https://pypi.org/project/metwit-weather/0.1.0/", "requires_dist": null, "requires_python": null, "summary": "Metwit weather API client library", "version": "0.1.0" }, "last_serial": 794738, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "5a908b0d8d2b2d89aab2af59dd75e060", "sha256": "df1a32eadc64fc8f001cb81befd8f16fccbb4b71383ab3dc2f8bfbfcae4bf23c" }, "downloads": -1, "filename": "metwit-weather-0.1.0.tar.gz", "has_sig": false, "md5_digest": "5a908b0d8d2b2d89aab2af59dd75e060", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2986, "upload_time": "2013-04-04T10:08:35", "url": "https://files.pythonhosted.org/packages/de/89/74b4ccb7fdf97099a2623d8e7c2120a4ad6c107cdaceda1113c85694b2f6/metwit-weather-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5a908b0d8d2b2d89aab2af59dd75e060", "sha256": "df1a32eadc64fc8f001cb81befd8f16fccbb4b71383ab3dc2f8bfbfcae4bf23c" }, "downloads": -1, "filename": "metwit-weather-0.1.0.tar.gz", "has_sig": false, "md5_digest": "5a908b0d8d2b2d89aab2af59dd75e060", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2986, "upload_time": "2013-04-04T10:08:35", "url": "https://files.pythonhosted.org/packages/de/89/74b4ccb7fdf97099a2623d8e7c2120a4ad6c107cdaceda1113c85694b2f6/metwit-weather-0.1.0.tar.gz" } ] }