{ "info": { "author": "Ryan McGreal", "author_email": "ryan@quandyfactory.com", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python" ], "description": "Summary\n=======\n\nDownload your Social Bicycles (SoBi) route data and save it locally in various formats.\n\nDetails\n=======\n\nThe `sobidata` module allows you to download your [Social Bicycles](https://app.socialbicycles.com) (SoBi) route data via the applications web API and save it locally in a variety of file formats.\n\nThe module uses the `requests` library to download collections of routes from the SoBi HTTP REST API using HTTP Basic Authentication, as outlined in the [SoBi API documentation](https://app.socialbicycles.com/developer/).\n\nThe route data is paginated, and the method that downloads the data calls itself recursively, incrementing the page with each request until there is no more data.\n\nFor each route, the module makes a follow-up request to the API to look up the bike name, origin hub address and destination hub address. However, it also stores the results of those requests locally so that a subsequent search for the same bike name or hub address retrieves the result from the local cache rather than making a duplicate API request.\n\nAs a result, the data includes three datasets: a list of routes, a list of hubs and a list of bikes. The module also makes a list of totals, calculating the total distance in miles, total distance in km, total duration in seconds, total duration in minutes, total duration in hours, total number of distinct bikes, and total number of distinct hubs.\n\nOnce the data is downloaded, you can save it locally in a variety of formats: JSON, XML, Excel 2007 or CSV format. Note that the JSON, XML and Excel 2007 formats save all four datasets, but the CSV format only saves the routes dataset.\n\nInstallation\n============\n\nThe sobidata module is [published on the Python Package Index](https://pypi.python.org/pypi/sobidata), so you can install it using `pip` or `easy_install`.\n\n pip install sobidata\n \nOr:\n\n easy_install sobidata\n\nAlternately, you can download the tarballed installer - `sobidata-[VERSION].tar.gz` - for this package from the [dist](https://github.com/quandyfactory/sobidata/tree/master/dist) directory on github and uncompress it. Then, from a terminal or command window, navigate into the unzipped folder and type the command:\n\n python setup.py install\n \nThat should be all you need to do.\n\nDependencies\n------------\n\nThis package has a few dependencies: `dicttoxml`, `openpyxl` and `requests`. If you use pip, the installer will pull in any dependencies you don't already have installed. If you use easy_install or direct download, you will need to ensure that you have the dependencies installed already.\n\nBasic Usage\n===========\n\nFrom a Python terminal or script, import the `sobidata` module and create an instance of the Sobi() class.\n\n >>> import sobidata\n >>> sobi = sobidata.Sobi()\n\nAssign your SoBi username (your email address) and password, as they are used for authentication.\n\n >>> sobi.username = 'my@email.address'\n >>> sobi.password = 'SecretPassword123'\n\nIf you try to get any data from the API without setting a username and password, the module will raise a `ValueError`.\n\nDownload Routes Data\n--------------------\n\nCall the `get_data()` method to download and process the data.\n\n >>> sobi.get_data()\n\nIt will take a few moments to download all the data. \n\nSpecify a destination path to save the data.\n\n >>> sobi.path = '/path/to/sobi/download/files'\n\nSave Your Data\n--------------\n\nExport and save the data locally.\n\n >>> sobi.save_data()\n\nIf you call `save_data()` without any parameters, it saves the data in JSON format under the filename:\n\n`/path/to/sobi/download/files/sobidata_export.json` \n\nYou can also save in several other formats by specifying the format as an optional argument:\n\n >>> sobi.save_data('xml') # XML format via dicttoxml module\n >>> sobi.save_data('xlsx') # Excel 2007 format via openpyxl module\n >>> sobi.save_data('csv') # CSV format - only saves routes\n\nPolite Mode\n-----------\n\nUnder normal functioning, this module makes a series of HTTP requests to the SoBi API with no delay. However, you can enable polite mode by setting `polite` to `True`:\n\n >>> sobi.polie = True\n\nWhen you enable polite mode, the module introduces a 0-3 second delay (chosen randomly) between each HTTP request. That way, the load on the SoBi API endpoint is reduced.\n\nAdvanced Usage\n==============\n\nAccess Local Data\n-----------------\n\nThe local data is stored in a dictionary. If you want to view/manipulate the data further, you can access the dictionary here:\n\n >>> data = sobi.data\n >>> data.keys()\n ['bikes', 'hubs', 'routes', 'totals']\n\nThe `data['bikes']` item is a list of dictionaries with the following keys: `bike_id`, `bike_name`.\n\nThe `data['hubs']` item is a list of dictionaries with the following keys: `hub_id', `hub_address`.\n\nThe `data['routes']` item is a list of dictionaries with the following keys: `bike_id`, `bike_name`, `distance_km`, `distance_miles`, `duration`, `duration_hh_mm_ss`, `finish_time`, `first_location_address`, `from_hub_address`, `from_hub_id`, `route_id`, `start_time`, `to_hub_address`, `to_hub_id`.\n\nThe `data['totals']` is a dictionary with the following keys: `distinct_bikes`, `distinct_hubs`, `total_distance_km`, `total_distance_miles`, `total_duration_hours`, `total_duration_minutes`, `total_duration_seconds`.\n\nImport Data\n-----------\n\nIf you have previously saved the data in JSON format, you can import it:\n\n >>> sobi.import_data()\n\nCurrently, you can only import data in JSON format.\n\nMake Requests\n-------------\n\nYou can use `sobidata` to make specific requests against the SoBi API for resource details via the `make_request()` method. The method uses the `requests.get()` method and returns a response object from `requests`.\n\nCurrently, the following resources are supported:\n\n* routes - the details for a route\n* hubs - the details for a hub\n* bikes - the details for a bike\n* friends - list of friends (no way to access individuals by id)\n* me - returns your own user details\n\nContinuing with our example code, here is how to get the details for the bike with id 917:\n\n >>> response = sobi.make_request('bikes', 917):\n >>> response.status_code\n 200\n >>> obj = response.json()\n >>> obj.keys()\n [u'distance', u'current_position', u'name', u'network_id', u'hub_id', u'id', u'state', u'inside_area', u'address', u'repair_state']\n >>> obj['id']\n 917\n >>> obj['state']\n u'available'\n\nAnd here is how to get the details for the hub with id 552:\n\n >>> response = sobi.make_request('hubs', 552)\n >>> response.status_code\n 200\n >>> obj = response.json()\n >>> obj.keys()\n [u'has_kiosk', u'area_id', u'polygon', u'name', u'distance', u'network_id', u'free_racks', u'inside', u'racks_amount', u'current_bikes', u'available_bikes', u'address', u'middle_point', u'id', u'description']\n obj['id']\n 552\n >>> obj['address']\n u'The Chedoke Rail Trail, Hamilton'\n >>> obj['current_bikes']\n\n(Note: this functionality does not currently extend to retrieving all the routes, hubs or bikes from the API, but we plan to introduce this in a future revision.)\n\nAuthor\n======\n\n* Author: Ryan McGreal\n* Email: [ryan@quandyfactory.com](mailto:ryan@quandyfactory.com)\n* Repository: [http://github.com/quandyfactory/sobidata](http://github.com/quandyfactory/sobidata)\n\nVersion\n=======\n\n* Version: 0.5\n* Release Date: 2015-05-08\n\nRevision History\n================\n\nVersion 0.5\n-----------\n\n* Release Date: 2015-05-08\n* Notes:\n * Added `avg_distance_per_route_km` and `avg_distance_per_route_miles` to totals\n * Automatically regenerate `auth` for each request\n * `make_request()` checks response status_code and raise exception if not 200\n\nVersion 0.4.5\n-------------\n\n* Release Date: 2015-05-08\n* Notes:\n * Updated README to clarify note on installation and dependencies\n\nVersion 0.4.4\n-------------\n\n* Release Date: 2015-05-08\n* Notes:\n * Updated setup.py so it pulls long_description from README\n\nVersion 0.4.3\n-------------\n\n* Release Date: 2015-05-08\n* Notes:\n * Updated setup.py so it creates a README copy of README.md for pypi\n\nVersion 0.4.2\n-------------\n\n* Release Date: 2015-05-08\n* Notes:\n * Updated MANIFEST to ensure README.md is included in package\n\nVersion 0.4.1\n-------------\n\n* Release Date: 2015-05-08\n* Notes:\n * Updated README to edit formatting, add copyright and licence\n\nVersion 0.4\n-----------\n\n* Release Date: 2015-05-08\n* Notes:\n * Added ability to make specific API requests\n * Added total number of routes to totals dictionary\n * Added 'polite' mode for delayed API calls\n * Added hashbang and docstring\n * Updated README.md\n\nVersion 0.3\n-----------\n\n* Release Date: 2015-05-06\n* Notes:\n * Fixed version in sobidata.py, README.md and setup.py\n\nVersion 0.2\n-----------\n\n* Release Date: 2015-05-06\n* Notes:\n * Dropped and recreated repository\n\nVersion 0.1\n-----------\n\n* Release Date: 2015-05-06\n* Notes:\n * First commit\n * Thanks to [parlarjb](https://gist.github.com/parlarjb) for looking at an [early gist](https://gist.github.com/quandyfactory/08125fe3050a563d55c3) and offering some helpful suggestions to clean up the code\n\nCopyright and Licence\n=====================\n\nCopyright © Ryan McGreal, 2015.\n\nLicenced under the [GNU General Public License, version 2](https://www.gnu.org/licenses/gpl-2.0.html).", "description_content_type": null, "docs_url": null, "download_url": "https://pypi.python.org/packages/source/s/sobidata/sobidata-0.5.tar.gz?raw=true", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/quandyfactory/sobidata", "keywords": null, "license": "LICENCE.txt", "maintainer": null, "maintainer_email": null, "name": "sobidata", "package_url": "https://pypi.org/project/sobidata/", "platform": "Cross-platform", "project_url": "https://pypi.org/project/sobidata/", "project_urls": { "Download": "https://pypi.python.org/packages/source/s/sobidata/sobidata-0.5.tar.gz?raw=true", "Homepage": "https://github.com/quandyfactory/sobidata" }, "release_url": "https://pypi.org/project/sobidata/0.5/", "requires_dist": null, "requires_python": null, "summary": "Downloads your Social Bicycles route data.", "version": "0.5" }, "last_serial": 1539464, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "c60765c56ef0d39d551d7ffc21e541a3", "sha256": "fbf830cc42ddcdc60d7578130eb2dc47acc1dcd6fbc3a89e99c0d13cf2355506" }, "downloads": -1, "filename": "sobidata-0.1.tar.gz", "has_sig": false, "md5_digest": "c60765c56ef0d39d551d7ffc21e541a3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5197, "upload_time": "2015-05-06T20:31:57", "url": "https://files.pythonhosted.org/packages/61/a5/7ed187ae11fb79aa0e4bb636c332d91582e2469c6928ed112b0548d4ca6a/sobidata-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "fc488b464d7047b23ea7eaec85a2f2cb", "sha256": "cdd18b1a0745eb8e7131a9b0ae59422f184a958c78b0063a7bf3eaffcfb825a3" }, "downloads": -1, "filename": "sobidata-0.2.tar.gz", "has_sig": false, "md5_digest": "fc488b464d7047b23ea7eaec85a2f2cb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5147, "upload_time": "2015-05-06T20:40:39", "url": "https://files.pythonhosted.org/packages/f9/42/a103e07b4f46623ca955a8713b5b04958c164c6815d54c05fd5227f8aefe/sobidata-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "601fb7454ebb337320e4058a4defdb59", "sha256": "54201f7ffc4c9a4a8bac4783fd63373a3fbfbd595a4ea47e8c2e213f06bbda4e" }, "downloads": -1, "filename": "sobidata-0.3.tar.gz", "has_sig": false, "md5_digest": "601fb7454ebb337320e4058a4defdb59", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5195, "upload_time": "2015-05-06T20:47:29", "url": "https://files.pythonhosted.org/packages/51/1a/6f2da4b3997230a13349c2a2e9dd982e3dc131195d75109b9aa6484b8c03/sobidata-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "cde904a4a77d0f670e7c015e960aae04", "sha256": "22974077ce9fed435099022e5f2039ad82b0d6daddc96df8f25e6dff3701f5d9" }, "downloads": -1, "filename": "sobidata-0.4.tar.gz", "has_sig": false, "md5_digest": "cde904a4a77d0f670e7c015e960aae04", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6443, "upload_time": "2015-05-08T15:07:22", "url": "https://files.pythonhosted.org/packages/1e/8d/a6e58b99013e44ba0df9e8827fdc2459ad2c44af7d7527549a871763132a/sobidata-0.4.tar.gz" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "b50ecc125da7a4ff3f5ba18e4400303d", "sha256": "1e0d04fa15ad224cd5330ab29e8de7a620d2fa8434a5ed529090850d8fed7fed" }, "downloads": -1, "filename": "sobidata-0.4.1.tar.gz", "has_sig": false, "md5_digest": "b50ecc125da7a4ff3f5ba18e4400303d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6583, "upload_time": "2015-05-08T18:43:47", "url": "https://files.pythonhosted.org/packages/e6/14/859d83c9762d49aea57c43348d001f5647102aeec358148b69e7f78e576b/sobidata-0.4.1.tar.gz" } ], "0.4.2": [ { "comment_text": "", "digests": { "md5": "e2d59f1ad0985c80e6916c420053b609", "sha256": "9bbb049528d2502bf14fa8cd81b3d9946e175425ef4babbed7be2fc8582039ac" }, "downloads": -1, "filename": "sobidata-0.4.2.tar.gz", "has_sig": false, "md5_digest": "e2d59f1ad0985c80e6916c420053b609", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6618, "upload_time": "2015-05-08T19:23:16", "url": "https://files.pythonhosted.org/packages/b9/91/ea51f9c386e5b59a32827662b11c7ef2ae63a66bfe84db9d3d288b28e019/sobidata-0.4.2.tar.gz" } ], "0.4.3": [ { "comment_text": "", "digests": { "md5": "60a25f63728dd427ca2e85110c14a8b5", "sha256": "14ad7d1c9e2c18f2a277d8c484e0adfacd543adf6dde77eba08534e016cc7772" }, "downloads": -1, "filename": "sobidata-0.4.3.tar.gz", "has_sig": false, "md5_digest": "60a25f63728dd427ca2e85110c14a8b5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7357, "upload_time": "2015-05-08T19:32:38", "url": "https://files.pythonhosted.org/packages/1f/80/3a3c473329abda8769d7a6e4be29d8d574f6285ca801c9c5e2a2da918f35/sobidata-0.4.3.tar.gz" } ], "0.4.4": [ { "comment_text": "", "digests": { "md5": "98dc86661e93ff736be67c94bfb15feb", "sha256": "40e05bbe1f442974402041c4e21eb77083e1009c402bbfa1ec42a013c083870e" }, "downloads": -1, "filename": "sobidata-0.4.4.tar.gz", "has_sig": false, "md5_digest": "98dc86661e93ff736be67c94bfb15feb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7406, "upload_time": "2015-05-08T19:35:53", "url": "https://files.pythonhosted.org/packages/7d/1c/d539278ac809824e979ffca13c34a5dbb78079f635af467e0e8ed10b8c13/sobidata-0.4.4.tar.gz" } ], "0.4.5": [ { "comment_text": "", "digests": { "md5": "1d6b97ae7ec9df6641857b2ba31c4691", "sha256": "8ad84aa48025e9f878ccfca902ce5287cee88c2d4cc351046a28e461344d2ed0" }, "downloads": -1, "filename": "sobidata-0.4.5.tar.gz", "has_sig": false, "md5_digest": "1d6b97ae7ec9df6641857b2ba31c4691", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7560, "upload_time": "2015-05-08T19:45:55", "url": "https://files.pythonhosted.org/packages/23/43/530fa48a3e21c8801b1f142fe306dc758a351d110e704cd63b69abe25a92/sobidata-0.4.5.tar.gz" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "3eeb2d77d7ed904ea4e5156620066ba4", "sha256": "e4f39a7e2131e593f89e4c885921eeaf3ef53e8d0f25a9fa1876ebcf3c23aa4e" }, "downloads": -1, "filename": "sobidata-0.5.tar.gz", "has_sig": false, "md5_digest": "3eeb2d77d7ed904ea4e5156620066ba4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7719, "upload_time": "2015-05-08T20:20:51", "url": "https://files.pythonhosted.org/packages/2c/6e/469b0866ec17298bd930e2752c1d60134e8cd0522c5c090fa8b1b4d3e196/sobidata-0.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3eeb2d77d7ed904ea4e5156620066ba4", "sha256": "e4f39a7e2131e593f89e4c885921eeaf3ef53e8d0f25a9fa1876ebcf3c23aa4e" }, "downloads": -1, "filename": "sobidata-0.5.tar.gz", "has_sig": false, "md5_digest": "3eeb2d77d7ed904ea4e5156620066ba4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7719, "upload_time": "2015-05-08T20:20:51", "url": "https://files.pythonhosted.org/packages/2c/6e/469b0866ec17298bd930e2752c1d60134e8cd0522c5c090fa8b1b4d3e196/sobidata-0.5.tar.gz" } ] }