{ "info": { "author": "Stefan Kuethe", "author_email": "crazycapivara@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Topic :: Utilities" ], "description": "openweathermapy\n===============\n\nPython package wrapping *OpenWeatherMap.org\u2019s* API 2.5.\n\nAs *OpenWeatherMap* returns data mostly in the form of nested\ndictionaries, *openweathermapy* gives a simple API to access items in a\ncomfortable way:\n\n.. code:: python\n\n # classic access\n item = data[\"main\"][\"temp\"]\n\n # openweathermapy access\n item = data(\"main.temp\")\n\n # access multiple items at once\n >>> items = data(\"main.temp\", \"wind.speed\")\n\nStatus\n======\n\nDevelopment - Alpha\n\nVersion\n=======\n\n0.6.6\n\nInstallation\n============\n\n.. code:: bash\n\n # via pip\n ~$ pip install openweathermapy\n\n # or download package and run ...\n ~$ python setup.py install\n\nDocumentation\n=============\n\nBesides the examples in this file, please use Python\u2019s builtin help\nfunctionality. Further documentation based on the docstrings is planned.\n\nUsage\n=====\n\n.. code:: python\n\n >>> import openweathermapy.core as owm\n\nAll parameters defined in *OpenWeatherMap\u2019s* API documentation can be\npassed to the functions in *openweathermapy* as keyword arguments\n``**params``. The query string always depends on the request (API call),\nbut unsupported parameters will (normally) not raise an error. Most\ncommon ones to be used are ``units``, ``lang`` and (if needed)\n``APPID``. So, it may be a good idea to pass them in the form of a\nsettings dictionary:\n\n.. code:: python\n\n >>> settings = {\"units\": \"metric\", \"lang\": \"DE\"}\n >>> data = owm.get_current(\"Kassel,DE\", **settings)\n\n # settings containing APIKEY\n >>> settings = {\"APPID\": 1111111111, \"units\": \"metric\"}\n\n**Data objects and views**\n\nThe main data object is ``openweathermapy.utils.NestedDict``, which\nextends Python\u2019s builtin ``dict`` by methods giving a more flexible\naccess to the items as shown above. If a list of weather data (objects)\nis returned ``openweathermapy.utils.NestedDictList`` or\n``openweathermapy.core.DataBlock`` is used. The latter one just adds an\nattribute ``meta`` to the ``NestedDictList`` containing the meta data of\nthe responses.\n\nA **view** is just a list of keys to extract data from the responses.\nSo, you can define views like *summary*, *minimal* etc. depending on\nyour needs. This keeps everything as flexible as possible:\n\n.. code:: python\n\n >>> views = {\n ... \"summary\": [\"main.temp\", \"main.pressure\", \"main.humidity\"]\n ... }\n\n >>> data = owm.get_current(\"London,UK\", units=\"metric\")\n >>> data(*views[\"summary\"])\n (18.56, 1011, 63)\n\n # return complete keys\n >>> data.get_dict(views[\"summary\"])\n {'main.temp': 18.56, 'main.humidity': 63, 'main.pressure': 1011}\n\n # return only last key\n >>> data.get_dict(views[\"summary\"], split_keys=True)\n {'pressure': 1011, 'temp': 18.56, 'humidity': 63} \n\nYou can also load views from files in *json* format for example by using\n``openweathermapy.utils.load_config``.\n\n**Current weather data**\n\n**City** can be given as *name*, *id*, or *geographic coordinates*. If\nyou want to stay as close as possible to the original API, you can also\nskip the first argument and use the parameters ``q``, ``id``, ``lat``\nand ``lon`` or ``zip`` instead. For details see *OpenWeatherMap\u2019s* API\ndocumentation.\n\n.. code:: python\n\n # get data by city name and country code\n >>> data = owm.get_current(\"Kassel,DE\")\n \n # get data by city id and set language to german (DE)\n >>> data = owm.get_current(2892518, lang=\"DE\")\n \n # get data by latitude and longitude and return temperatures in Celcius\n >>> location = (51.32, 9.5)\n >>> data = owm.get_current(location, units=\"metric\")\n \n # optional: skip city argument and get data by zip code\n >>> data = owm.get_current(zip=\"34128,DE\") \n\n # access single item\n >>> data(\"main.temp\")\n 11.06\n\n # access multiple items at once\n >>> keys = [\"main.temp\", \"main.humidity\", \"wind.speed\"]\n >>> data.get_many(keys)\n (11.06, 58, 6.2)\n\n # alternative access\n >>> data(*keys)\n (11.06, 58, 6.2)\n\n # get data for 'Malaga,ES', 'Kassel,DE', 'New York,US'\n >>> city_ids = (2892518, 2514256, 5128581)\n >>> data = owm.get_current_for_group(city_ids, units=\"metric\", lang=\"DE\")\n >>> data_malaga = data[0]\n\n # find city by name and return data for match(es)\n >>> data = owm.find_city(\"Malaga\")\n\n # get data for 5 cities around geographic coordinates\n >>> location = (51.32, 9.5)\n >>> data = owm.find_cities_by_geo_coord(location, 5)\n\n # get data from station\n >>> data = owm.get_current_from_station(4926)\n\n # get stations by geographic coordinates\n >>> location = (51.32, 9.5)\n >>> data = owm.find_stations_by_geo_coord(location)\n\n**Forecast data**\n\n**City** can be given in the same way as shown in the examples above.\n\n.. code:: python\n\n # get 3h forecast data\n >>> data = owm.get_forecast_hourly(\"Kassel,DE\", lang=\"DE\")\n\n # get daily forecast data for 7 days\n >>> data = owm.get_forecast_daily(\"Kassel,DE\", 7, units=\"metric\")\n\n # show meta data\n >>> data.meta\n {u'city': {u'country': u'DE', u'population': 0, u'id': 2892518,\n u'coord': {u'lat': 51.316669, u'lon': 9.5}, u'name': u'Kassel'},\n u'message': 0.0185, u'cod': u'200', u'cnt': 7}\n\n # get coordinates and id\n >>> data.meta(*[\"city.coord\", \"city.id\"])\n ({u'lat': 51.316669, u'lon': 9.5}, 2892518)\n\n # select columns\n >>> selection = data.select([\"dt\", \"temp.min\", \"temp.max\"])\n >>> for line in selection:\n ... line \n ...\n (1437044400, 16.63, 24.99)\n (1437130800, 18.21, 30.17)\n (1437217200, 14.96, 26.35)\n (1437303600, 15.82, 23.49)\n (1437390000, 15.52, 23.95)\n (1437476400, 18.77, 29.11)\n (1437562800, 14.67, 27.11)\n\n # convert column \"dt\" to datetime string\n >>> from datetime import datetime as dt\n >>> conv = {\"dt\": lambda ts: str(dt.utcfromtimestamp(ts))}\n\n >>> selection = data.select([\"dt\", \"temp.min\", \"temp.max\"], converters=conv)\n >>> for line in selection:\n ... line \n ...\n ('2015-07-16 11:00:00', 16.63, 24.99)\n ('2015-07-17 11:00:00', 18.21, 30.17)\n ('2015-07-18 11:00:00', 14.96, 26.35)\n ('2015-07-19 11:00:00', 15.82, 23.49)\n ('2015-07-20 11:00:00', 15.52, 23.95)\n ('2015-07-21 11:00:00', 18.77, 29.11)\n ('2015-07-22 11:00:00', 14.67, 27.11)\n\n**Historical data**\n\nFor a complete list of parameters as ``start``, ``end`` etc., which can\nbe passed, please refer to *OpenWeatherMap\u2019s* API documention.\n\n.. code:: python\n\n # get historical data for city\n >>> data = owm.get_history(\"Kassel,DE\")\n\n # get historical data from station\n >>> data = owm.get_history_from_station(4926)\n\n**Customization**\n\nYou can customize or extend the lib to your needs by using the wrapper\nfunction ``wrap_get`` or the decorator class ``GetDecorator``. Both are\nmore or less the same. As first argument the *appendix* to the *base\nurl* needs to be given. Optionally a *dictionary with parameters* and a\n*data converter* can be passed.\n\n.. code:: python\n\n # show base url\n >>> owm.BASE_URL\n 'http://api.openweathermap.org/data/2.5/'\n\n # base url for fetching current weather data\n >>> appendix = \"weather\"\n >>> owm.BASE_URL+appendix\n 'http://api.openweathermap.org/data/2.5/weather'\n\n # create a function to get current weather data and return temperatures in Celsius (units=\"metric\") \n >>> f = wrap_get(\"weather\", dict(units=\"metric\"))\n >>> data = f(\"London,UK\")\n >>> data_de = f(zip=\"34128,DE\", lang=\"DE\")\n\n", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/crazycapivara/openweathermapy/archive/master.zip", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/crazycapivara/openweathermapy", "keywords": "openweathermap,weather data,forecast data,free weather,open weather,API 2.5", "license": "GPLv3", "maintainer": null, "maintainer_email": null, "name": "openweathermapy", "package_url": "https://pypi.org/project/openweathermapy/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/openweathermapy/", "project_urls": { "Download": "https://github.com/crazycapivara/openweathermapy/archive/master.zip", "Homepage": "https://github.com/crazycapivara/openweathermapy" }, "release_url": "https://pypi.org/project/openweathermapy/0.6.6/", "requires_dist": null, "requires_python": null, "summary": "Python package wrapping OpenWeatherMap.org's API 2.5", "version": "0.6.6" }, "last_serial": 1639497, "releases": { "0.6.5": [ { "comment_text": "", "digests": { "md5": "cab923857c7e5709baabd59615259461", "sha256": "ee727b7cd8cdcf63c3c5a283dfc7fcd35a6a2e50fdec8dcafee13a0c40c8d493" }, "downloads": -1, "filename": "openweathermapy-0.6.5.tar.gz", "has_sig": false, "md5_digest": "cab923857c7e5709baabd59615259461", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7278, "upload_time": "2015-07-17T21:06:32", "url": "https://files.pythonhosted.org/packages/6b/c4/b20619cdaca72bd6480f2daa6c93510ee1566be0c134f4d2c51bb3658b5c/openweathermapy-0.6.5.tar.gz" } ], "0.6.6": [ { "comment_text": "", "digests": { "md5": "65ca2db7957f1addfd485ea40a8c92e3", "sha256": "c9b7b49e33e99b56c7c517cf846519f1c815c4c321b241c9d8ef7b3212f2059c" }, "downloads": -1, "filename": "openweathermapy-0.6.6.tar.gz", "has_sig": false, "md5_digest": "65ca2db7957f1addfd485ea40a8c92e3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7238, "upload_time": "2015-07-18T20:22:22", "url": "https://files.pythonhosted.org/packages/41/ea/eda328e60ffc8ee201c6743ecb463ef122f10f9d13ec9fcaa0028736ce4e/openweathermapy-0.6.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "65ca2db7957f1addfd485ea40a8c92e3", "sha256": "c9b7b49e33e99b56c7c517cf846519f1c815c4c321b241c9d8ef7b3212f2059c" }, "downloads": -1, "filename": "openweathermapy-0.6.6.tar.gz", "has_sig": false, "md5_digest": "65ca2db7957f1addfd485ea40a8c92e3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7238, "upload_time": "2015-07-18T20:22:22", "url": "https://files.pythonhosted.org/packages/41/ea/eda328e60ffc8ee201c6743ecb463ef122f10f9d13ec9fcaa0028736ce4e/openweathermapy-0.6.6.tar.gz" } ] }