Skip to main content

This is a python wrapper for the ecobici api

Project description

Ecobici python wrapper

Build Status PyPI version GitHub

Ecobici logo

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ecobici-0.0.3.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ecobici-0.0.3-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file ecobici-0.0.3.tar.gz.

File metadata

  • Download URL: ecobici-0.0.3.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for ecobici-0.0.3.tar.gz
Algorithm Hash digest
SHA256 ad9642e6ab1e436558fbd661da237c0f6549568e1d3519d2cacf3096757b1db4
MD5 46a089e1b34cc29130a77c2501de2f2a
BLAKE2b-256 226c1a0743eb3e4d3603d565d41b9711c46aeb47ffa25574ddafab73d76b0818

See more details on using hashes here.

File details

Details for the file ecobici-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: ecobici-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for ecobici-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5ef86a9b96a782990f67b655bfba4e25c609b80c808808ea5ab81cc7a4e421dc
MD5 dff601a183232c4fe433d59013f1478c
BLAKE2b-256 596732467c0b6ee67fb0dc1c95643e31cbfc751c482cf76abd3129f15ce23418

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page