Ecobici python wrapper
Installation
pip install ecobici
Usage
# Import module
from ecobici import Ecobici
# Initialize client
client = Ecobici(your_client_id, your_client_secret)
# Get dictionary containing stations
stations = client.get_stations()
# Get dictionary containing the status of stations
stations_status = client.get_stations_status()
# (Optional) Force refresh token
client.refresh_token()
Examples
Get the name of the first station
from ecobici import Ecobici
client = Ecobici(your_client_id, your_client_secret)
list_of_stations = client.get_stations()["stations"]
print("The name of the first station is ", list_of_stations[0]["name"])
Check the Data structure section for more information
Get the status of the third station
from ecobici import Ecobici
client = Ecobici(your_client_id, your_client_secret)
list_of_stations = client.get_stations_status()["stationsStatus"]
print("The status of the third station is ", list_of_stations[3]["status"])
Check the Data structure section for more information
Data structure
Stations structure
This module translate the json objects to python objects and returns it to the user, it doesn't unwraps it because I didn't want to modify the data.
The econduce's API returns data in the following json format,
that's why you have to manually unwrap it with client.get_stations_status()["stations"]:
{
"stations": [
{
"id": 448,
"name": "448 DR. ANDRADE - ARCOS DE BELÉN",
"address": "DR. ANDRADE ARCOS DE BELÉN",
"addressNumber": "S/N",
"zipCode": null,
"districtCode": null,
"districtName": null,
"altitude": null,
"nearbyStations": [
448
],
"location": {
"lat": 19.426611,
"lon": -99.14447
},
"stationType": "BIKE,TPV"
},
]
}
Structure and types
| Key | Type |
|---|---|
| id | int |
| name | str |
| address | str |
| addressNumber | str |
| zipCode | str |
| districtCode | str |
| districtName | str |
| nearbyStations | list with id (int) |
| location | list |
| stationType | str |
Location list:
| Key | Type |
|---|---|
| lat | float |
| lon | float |
Latitud and logitud are coordinates based on the World Geodetic System (WGS84).
Status structure
This module translate the json objects to python objects and returns it to the user, it doesn't unwraps it because I didn't want to modify the data.
The econduce's API returns data in the following json format,
that's why you have to manually unwrap it with client.get_stations_status()["stationsStatus"]:
{
"stationsStatus": [
{
"id": 1,
"status": "OPN",
"availability": {
"bikes": 4,
"slots": 23
}
},
]
}
Structure and types
| Key | Type |
|---|---|
| id | int |
| status | str (OPN means open, CLS means closed) |
| availability | list |
Availability list:
| Key | Type |
|---|---|
| bikes | int |
| slots | int |
Test
python3 -m pytest ecobici/test.py
Notes
- There's no need to refresh the token when it expires. The client does it automatically.
- Ecobici's API can return null values. It's up to you to verify that the value you want to access if defined.
- You can find more information about the API structure here: Spanish documentation.
Metadata
Release files for ecobici 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ecobici-0.0.3.tar.gz | 4.1 kB | Without provenance | Details for ecobici-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ecobici-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for ecobici-0.0.3-py3-none-any.whl |
Total release size: 8.3 kB
Release files / ecobici-0.0.3.tar.gz
| Download URL | ecobici-0.0.3.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ad9642e6ab1e436558fbd661da237c0f6549568e1d3519d2cacf3096757b1db4
|
|
BLAKE2b-256 checksum How to use checksums |
226c1a0743eb3e4d3603d565d41b9711c46aeb47ffa25574ddafab73d76b0818
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.5
|
Release files / ecobici-0.0.3-py3-none-any.whl
| Download URL | ecobici-0.0.3-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5ef86a9b96a782990f67b655bfba4e25c609b80c808808ea5ab81cc7a4e421dc
|
|
BLAKE2b-256 checksum How to use checksums |
596732467c0b6ee67fb0dc1c95643e31cbfc751c482cf76abd3129f15ce23418
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.5
|
Security for ecobici 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.