{ "info": { "author": "Yoan Tournade", "author_email": "yoan@ytotech.com", "bugtrack_url": null, "classifiers": [], "description": "# SafecastPy\n\nA pure Python wrapper around the Safecast API.\n\n![](/misc/safecast_logo.png?raw=true \"Safecast\")\n\nBy the [YtoTech members](https://www.ytotech.com/). Checkout our related [blog post](https://blog.ytotech.com/2016/03/30/radiation-watch-safecast/).\n\n# Introduction\n\nThis library provides a pure Python interface for the [Safecast API](https://api.safecast.org/).\n\n[Safecast](http://blog.safecast.org/) provides open hardware and platforms to measure and share data about people environments. Currently the Safecast API allows to publish radiation measurement data.\n\nAs they put it:\n> We believe that having more freely available open data is better for everyone.\n\n# Installation\n\nYou can install SafecastPy using:\n\n```\n$ pip install SafecastPy\n```\n\n[![PyPI version](https://badge.fury.io/py/SafecastPy.svg)](https://pypi.python.org/pypi/SafecastPy/)\n\n# Starting out\n\nFirst, you'll want to head over to https://api.safecast.org/en-US/users/sign_up and register a new account!\n\nAfter you register, grab your account `API key` from the profile tab.\n\n![](/misc/yourprofile.png?raw=true \"API key\")\n\nYou can also begin by testing your application on the Safecast API [development instance](http://dev.safecast.org/en-US/users/sign_up).\n\nFirst, you'll want to import SafecastPy:\n\n```python\nimport SafecastPy\n```\n\n## Dynamic Function Arguments\n\nKeyword arguments to functions are mapped to the functions available for each endpoint in the Safecast API docs. Doing this allows us to be incredibly flexible in querying the Safecast API, so changes to the API aren't held up from you using them by this library.\n\n# Basic Usage\n\nAll the method definitions can be found by reading over [SafecastPy/endpoints.py](/SafecastPy/endpoints.py).\n\n## Initialization\n\nCreate a SafecastPy instance with your API key:\n\n```python\nimport SafecastPy\nsafecast = SafecastPy.SafecastPy(\n api_key='YOUR_API_KEY')\n```\n\nBy default it uses the Safecast API production instance. You may want to use the development instance:\n\n```python\nimport SafecastPy\nsafecast = SafecastPy.SafecastPy(\n api_key='YOUR_API_KEY',\n api_url=SafecastPy.DEVELOPMENT_API_URL)\n```\n\n## Getting measurements\n\n```python\n# Get the 25 last added measurements.\nsafecast.get_measurements(order='created_at desc'))\n# Use paging to navigate through the results.\nfor i in range(2, 10):\n safecast.get_measurements(order='created_at desc', page=i))\n# You can also filter by unit.\nsafecast.get_measurements(unit=SafecastPy.UNIT_CPM)))\n# Or date.\nsafecast.get_measurements(since='2015-09-08', until='2016-12-22')\n# And use a combination of all of that.\nsafecast.get_measurements(\n since='2015-09-08', until='2016-12-22',\n unit=SafecastPy.UNIT_USV, order='created_at asc',\n page=20)\n```\n\nGet more information on the available parameters on [the API documentation](https://api.safecast.org/en-US/home).\n\n\n## Add a measurement\n\n```python\nimport datetime, random\nmeasurement = safecast.add_measurement(json={\n 'latitude': 49.418683,\n 'longitude': 2.823469,\n 'value': random.uniform(1, 10),\n 'unit': SafecastPy.UNIT_CPM,\n 'captured_at': datetime.datetime.utcnow().isoformat() + '+00:00',\n 'device_id': 90,\n 'location_name': '1 Rue du Grand Ferr\u00e9, Compi\u00e8gne',\n 'height': 120\n})\nprint('New measurement id: {0}'.format(measurement['id']))\n```\n\n## Retrieve a measurement\n\n```python\nsafecast.get_measurement(id=52858985)\n```\n\n## Upload a bGeigie import\n\n```python\nbgeigie_import = safecast.upload_bgeigie_import(files={\n 'bgeigie_import[source]': open('misc/sample_bgeigie.LOG', 'rb')\n }, data={\n 'bgeigie_import[name]': 'Logging in Compi\u00e8gne',\n 'bgeigie_import[description]': 'Around the Universit\u00e9 de Technologie',\n 'bgeigie_import[credits]': 'by YtoTech team',\n 'bgeigie_import[cities]': 'Compi\u00e8gne',\n 'bgeigie_import[orientation]': 'NWE',\n 'bgeigie_import[height]': '100'\n })\nprint('New import id: {0}'.format(bgeigie_import['id']))\n```\n\n-------------------------\n\nYou enjoy the lib? You may check out [our blog](https://blog.ytotech.com).\n\nYou may also send us love-notes, ask questions or give any comment at [yoan@ytotech.com](mailto:yoan@ytotech.com).\n\nHappy hacking!\n\n### Contribute\n\nFeel free to [open a new ticket](https://github.com/MonsieurV/SafecastPy/issues/new) or submit a PR to improve the lib.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/MonsieurV/SafecastPy", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "SafecastPy", "package_url": "https://pypi.org/project/SafecastPy/", "platform": "any", "project_url": "https://pypi.org/project/SafecastPy/", "project_urls": { "Homepage": "https://github.com/MonsieurV/SafecastPy" }, "release_url": "https://pypi.org/project/SafecastPy/0.1.1/", "requires_dist": [ "requests (>=2.9.1)" ], "requires_python": "", "summary": "A Python wrapper for the Safecast API.", "version": "0.1.1" }, "last_serial": 5135965, "releases": { "0.1": [], "0.1.0": [ { "comment_text": "", "digests": { "md5": "262849529f6e7a860167453d2d73ed3d", "sha256": "462bebc917892091efa5fed30fc52ea3e5ab390654bbc16aa378614ceda0806a" }, "downloads": -1, "filename": "SafecastPy-0.1.0.tar.gz", "has_sig": false, "md5_digest": "262849529f6e7a860167453d2d73ed3d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3267, "upload_time": "2016-03-17T01:15:57", "url": "https://files.pythonhosted.org/packages/60/50/5632f2f2674cc5650054ac63db0ce6fcaf96886f6879bfd09653da0d7170/SafecastPy-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "1430b4f6b3855b5e730d5b914605b7ff", "sha256": "549b417b348d5122558a25672905ca3f8dc60c07f4fe825d820faeff120a4900" }, "downloads": -1, "filename": "SafecastPy-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "1430b4f6b3855b5e730d5b914605b7ff", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7107, "upload_time": "2019-04-12T22:29:51", "url": "https://files.pythonhosted.org/packages/e7/38/fb4ef0ae139570781127c0b342bd521316766f1fe34994a3b2bb0906c6d1/SafecastPy-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "591b136af45c8085b1c7dc987d8cd9c0", "sha256": "e195931860d637eff12b3c6eb7e0917e38da6d6e764e8934375ca71168358fca" }, "downloads": -1, "filename": "SafecastPy-0.1.1.tar.gz", "has_sig": false, "md5_digest": "591b136af45c8085b1c7dc987d8cd9c0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5275, "upload_time": "2019-04-12T22:29:52", "url": "https://files.pythonhosted.org/packages/68/f4/8babc6aebfdba8d787dee9061e58d6fc84b2733f8939b7aab939e75a231f/SafecastPy-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1430b4f6b3855b5e730d5b914605b7ff", "sha256": "549b417b348d5122558a25672905ca3f8dc60c07f4fe825d820faeff120a4900" }, "downloads": -1, "filename": "SafecastPy-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "1430b4f6b3855b5e730d5b914605b7ff", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7107, "upload_time": "2019-04-12T22:29:51", "url": "https://files.pythonhosted.org/packages/e7/38/fb4ef0ae139570781127c0b342bd521316766f1fe34994a3b2bb0906c6d1/SafecastPy-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "591b136af45c8085b1c7dc987d8cd9c0", "sha256": "e195931860d637eff12b3c6eb7e0917e38da6d6e764e8934375ca71168358fca" }, "downloads": -1, "filename": "SafecastPy-0.1.1.tar.gz", "has_sig": false, "md5_digest": "591b136af45c8085b1c7dc987d8cd9c0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5275, "upload_time": "2019-04-12T22:29:52", "url": "https://files.pythonhosted.org/packages/68/f4/8babc6aebfdba8d787dee9061e58d6fc84b2733f8939b7aab939e75a231f/SafecastPy-0.1.1.tar.gz" } ] }