pybikes


Namepybikes JSON
Version 1.0.5 PyPI version JSON
download
home_pageNone
SummaryA python library for scraping bike sharing data
upload_time2025-07-08 17:37:01
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords transport open data bike share bike sharing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            pybikes [![Build Status](https://github.com/eskerda/pybikes/actions/workflows/test.yml/badge.svg)](https://github.com/eskerda/pybikes/actions/workflows/test.yml)
[![Chat on Matrix](https://matrix.to/img/matrix-badge.svg)](https://matrix.to/#/#citybikes:matrix.org)
=======
![pybikes](http://citybik.es/files/pybikes.png)

pybikes provides a set of tools to scrape bike sharing data from different
websites and APIs, thus providing a coherent and generalized set of classes
and methods to access this sort of information.

The library is distributed and intended mainly for statistics and data
sharing projects. More importantly, it powers the [CityBikes][1] project, and
is composed of a set of classes and a pack of data files that provide instances
for all different systems.

Installation
------------

Install from PyPI:

```bash
pip install pybikes
```

Install directly from GitHub:
```bash
pip install git+https://github.com/eskerda/pybikes.git
```

Or after downloading/cloning the source:
```bash
pip install .
```

Usage
-----
```python
>>> import pybikes

# Capital BikeShare instantiation data is in bixi.json file
>>> capital_bikeshare = pybikes.get('capital-bikeshare')

# The instance contains all possible metadata regarding this system
>>> print(capital_bikeshare.meta)
{
    'name': 'Capital BikeShare',
    'city': 'Washington, DC - Arlington, VA',
    'longitude': -77.0363658,
    'system': 'Bixi',
    'company': ['PBSC'],
    'country': 'USA',
    'latitude': 38.8951118
}
# The update method retrieves the list of stations
>>> print(len(capital_bikeshare.stations))
0
>>> capital_bikeshare.update()
>>> print(len(capital_bikeshare.stations))
191
>>> print(capital_bikeshare.stations[0])
--- 31000 - 20th & Bell St ---
bikes: 7
free: 4
latlng: 38.8561,-77.0512
extra: {
    'installed': True,
    'uid': 1,
    'locked': False,
    'removalDate': '',
    'installDate': '1316059200000',
    'terminalName': '31000',
    'temporary': False,
    'name': '20th & Bell St',
    'latestUpdateTime': '1353454305589'
}
```

Some systems might require an API key to work (for instance, Cyclocity). In
these cases, the instance factory can take an extra API key parameter.

```python
>>> key = "This is not an API key"
>>> dublinbikes = pybikes.get('dublinbikes', key)
```

Note that pybikes works as an instance factory and, choicely, instances can be
generated by passing the right arguments to the desired class

```python
>>> from pybikes.cyclocity import BixiSystem
>>> capital_bikeshare = BixiSystem(
        tag = 'foo_tag',
        root_url = 'http://capitalbikeshare.com/data/stations/',
        meta = {'foo':'bar'}
    )
```

The way information is retrieved can be tweaked using the PyBikesScraper class
included on the utils module thus allowing session reusing and niceties such as
using a proxy. This class uses [Requests][2] module internally.

```python
>>> scraper = pybikes.utils.PyBikesScraper()
>>> scraper.enableProxy()
>>> scraper.setProxies({
        "http" : "127.0.0.1:8118",
        "https": "127.0.0.1:8118"
    })
>>> scraper.setUserAgent("Walrus™ v3.0")
>>> scraper.headers['Foo'] = 'bar'
>>> capital_bikeshare.update(scraper)
```

[1]: http://www.citybik.es              "CityBikes"
[2]: http://docs.python-requests.org    "Requests"

Tests
-----
Tests are separated between unit tests and integration tests with the different
sources supported.

To run unit tests simply

```bash
make test
```

To run integration tests

```bash
make test-update
```

Note that some systems require authorization keys, tests expect these to be
set as environment variables like:

```bash
PYBIKES_CYCLOCITY='some-api-key'
PYBIKES_DEUTSCHEBAHN_CLIENT_ID='some-client-id'
PYBIKES_DEUTSCHEBAHN_CLIENT_SECRET='some-client-secret'

# or if using an .env file
# source .env

make test-update
```

This project uses pytest for tests. Test a particular network by passing a
filter expresson

```bash
pytest -k bicing
pytest -k gbfs
```

To speed up tests execution, install [pytest-xdist][3] to specify the number of
CPUs to use

```bash
pytest -k gbfs -n auto
```

To use Makefile steps and pass along pytest arguments, append to the `T_FLAGS`
variable

```bash
make test-update T_FLAGS+='-n 10 -k gbfs'
```

Integration tests can generate a json report file with all extracted data stored
as geojson. Using this json report file, further useful reports can be generated
like a summary of the overall health of the library or a map visualization of
all the information.

For more information on reports see [utils/README.md][4]

[3]: https://pypi.org/project/pytest-xdist/
[4]: utils/README.md

Development
-----------
We welcome contributions from the community! The best place to get started is
by diving into the codebase or checking the issues list.

Join our developer community on Matrix: [#citybikes:matrix.org](https://matrix.to/#/#citybikes:matrix.org)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pybikes",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "transport, open data, bike share, bike sharing",
    "author": null,
    "author_email": "Lluis Esquerda <eskerda@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/f8/a6/4e54180a02c2d908b56af5bb6a802473587ba3e792ab60187bc9c83e329a/pybikes-1.0.5.tar.gz",
    "platform": null,
    "description": "pybikes [![Build Status](https://github.com/eskerda/pybikes/actions/workflows/test.yml/badge.svg)](https://github.com/eskerda/pybikes/actions/workflows/test.yml)\n[![Chat on Matrix](https://matrix.to/img/matrix-badge.svg)](https://matrix.to/#/#citybikes:matrix.org)\n=======\n![pybikes](http://citybik.es/files/pybikes.png)\n\npybikes provides a set of tools to scrape bike sharing data from different\nwebsites and APIs, thus providing a coherent and generalized set of classes\nand methods to access this sort of information.\n\nThe library is distributed and intended mainly for statistics and data\nsharing projects. More importantly, it powers the [CityBikes][1] project, and\nis composed of a set of classes and a pack of data files that provide instances\nfor all different systems.\n\nInstallation\n------------\n\nInstall from PyPI:\n\n```bash\npip install pybikes\n```\n\nInstall directly from GitHub:\n```bash\npip install git+https://github.com/eskerda/pybikes.git\n```\n\nOr after downloading/cloning the source:\n```bash\npip install .\n```\n\nUsage\n-----\n```python\n>>> import pybikes\n\n# Capital BikeShare instantiation data is in bixi.json file\n>>> capital_bikeshare = pybikes.get('capital-bikeshare')\n\n# The instance contains all possible metadata regarding this system\n>>> print(capital_bikeshare.meta)\n{\n    'name': 'Capital BikeShare',\n    'city': 'Washington, DC - Arlington, VA',\n    'longitude': -77.0363658,\n    'system': 'Bixi',\n    'company': ['PBSC'],\n    'country': 'USA',\n    'latitude': 38.8951118\n}\n# The update method retrieves the list of stations\n>>> print(len(capital_bikeshare.stations))\n0\n>>> capital_bikeshare.update()\n>>> print(len(capital_bikeshare.stations))\n191\n>>> print(capital_bikeshare.stations[0])\n--- 31000 - 20th & Bell St ---\nbikes: 7\nfree: 4\nlatlng: 38.8561,-77.0512\nextra: {\n    'installed': True,\n    'uid': 1,\n    'locked': False,\n    'removalDate': '',\n    'installDate': '1316059200000',\n    'terminalName': '31000',\n    'temporary': False,\n    'name': '20th & Bell St',\n    'latestUpdateTime': '1353454305589'\n}\n```\n\nSome systems might require an API key to work (for instance, Cyclocity). In\nthese cases, the instance factory can take an extra API key parameter.\n\n```python\n>>> key = \"This is not an API key\"\n>>> dublinbikes = pybikes.get('dublinbikes', key)\n```\n\nNote that pybikes works as an instance factory and, choicely, instances can be\ngenerated by passing the right arguments to the desired class\n\n```python\n>>> from pybikes.cyclocity import BixiSystem\n>>> capital_bikeshare = BixiSystem(\n        tag = 'foo_tag',\n        root_url = 'http://capitalbikeshare.com/data/stations/',\n        meta = {'foo':'bar'}\n    )\n```\n\nThe way information is retrieved can be tweaked using the PyBikesScraper class\nincluded on the utils module thus allowing session reusing and niceties such as\nusing a proxy. This class uses [Requests][2] module internally.\n\n```python\n>>> scraper = pybikes.utils.PyBikesScraper()\n>>> scraper.enableProxy()\n>>> scraper.setProxies({\n        \"http\" : \"127.0.0.1:8118\",\n        \"https\": \"127.0.0.1:8118\"\n    })\n>>> scraper.setUserAgent(\"Walrus\u2122 v3.0\")\n>>> scraper.headers['Foo'] = 'bar'\n>>> capital_bikeshare.update(scraper)\n```\n\n[1]: http://www.citybik.es              \"CityBikes\"\n[2]: http://docs.python-requests.org    \"Requests\"\n\nTests\n-----\nTests are separated between unit tests and integration tests with the different\nsources supported.\n\nTo run unit tests simply\n\n```bash\nmake test\n```\n\nTo run integration tests\n\n```bash\nmake test-update\n```\n\nNote that some systems require authorization keys, tests expect these to be\nset as environment variables like:\n\n```bash\nPYBIKES_CYCLOCITY='some-api-key'\nPYBIKES_DEUTSCHEBAHN_CLIENT_ID='some-client-id'\nPYBIKES_DEUTSCHEBAHN_CLIENT_SECRET='some-client-secret'\n\n# or if using an .env file\n# source .env\n\nmake test-update\n```\n\nThis project uses pytest for tests. Test a particular network by passing a\nfilter expresson\n\n```bash\npytest -k bicing\npytest -k gbfs\n```\n\nTo speed up tests execution, install [pytest-xdist][3] to specify the number of\nCPUs to use\n\n```bash\npytest -k gbfs -n auto\n```\n\nTo use Makefile steps and pass along pytest arguments, append to the `T_FLAGS`\nvariable\n\n```bash\nmake test-update T_FLAGS+='-n 10 -k gbfs'\n```\n\nIntegration tests can generate a json report file with all extracted data stored\nas geojson. Using this json report file, further useful reports can be generated\nlike a summary of the overall health of the library or a map visualization of\nall the information.\n\nFor more information on reports see [utils/README.md][4]\n\n[3]: https://pypi.org/project/pytest-xdist/\n[4]: utils/README.md\n\nDevelopment\n-----------\nWe welcome contributions from the community! The best place to get started is\nby diving into the codebase or checking the issues list.\n\nJoin our developer community on Matrix: [#citybikes:matrix.org](https://matrix.to/#/#citybikes:matrix.org)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A python library for scraping bike sharing data",
    "version": "1.0.5",
    "project_urls": {
        "Documentation": "https://docs.citybik.es",
        "Homepage": "https://www.citybik.es",
        "Source": "https://github.com/eskerda/pybikes",
        "Tracker": "https://github.com/eskerda/pybikes/issues"
    },
    "split_keywords": [
        "transport",
        " open data",
        " bike share",
        " bike sharing"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "80a66aa33997a1021a7289dbd9cb5a8ac7c5d32c17e81b26bdd8d365251a3fa1",
                "md5": "64f20b491dc2d03ad932db19199445db",
                "sha256": "5828c677c7e6774008e90a4a9deaff66667b2c1758bcf6411bb83e51a7d38fda"
            },
            "downloads": -1,
            "filename": "pybikes-1.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "64f20b491dc2d03ad932db19199445db",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 498037,
            "upload_time": "2025-07-08T17:37:00",
            "upload_time_iso_8601": "2025-07-08T17:37:00.294743Z",
            "url": "https://files.pythonhosted.org/packages/80/a6/6aa33997a1021a7289dbd9cb5a8ac7c5d32c17e81b26bdd8d365251a3fa1/pybikes-1.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f8a64e54180a02c2d908b56af5bb6a802473587ba3e792ab60187bc9c83e329a",
                "md5": "311cebb419718b4ba48711624fcd01e1",
                "sha256": "b7422e8debb1d4b1de7825bf9751fe2be4575957e36d9ac4b2e57c4018aa3b7f"
            },
            "downloads": -1,
            "filename": "pybikes-1.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "311cebb419718b4ba48711624fcd01e1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 472625,
            "upload_time": "2025-07-08T17:37:01",
            "upload_time_iso_8601": "2025-07-08T17:37:01.967222Z",
            "url": "https://files.pythonhosted.org/packages/f8/a6/4e54180a02c2d908b56af5bb6a802473587ba3e792ab60187bc9c83e329a/pybikes-1.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-08 17:37:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "eskerda",
    "github_project": "pybikes",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "pybikes"
}
        
Elapsed time: 0.83165s