Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Get Bikeshare Station Metadata

Brown University
Updated: 24 apr 2026

Imports

The required Python libraries are imported below

Source
import pandas as pd
import requests

About

This notebook retrieves metadata about all bikeshare stations within a single network from public API endpoints. The base URL of the API of the single bikeshare network was obtained from the previous notebook

User Inputs

base_url = "https://toronto.publicbikesystem.net/customer/gbfs/v3.0"

The following derived variables are created to define the two station API endpoints from the above

url_info = f"{base_url}/station_information"
url_status = f"{base_url}/station_status"

Extract

First we retrieve the station information from the station_information/ endpoint

r_info = requests.get(url_info).json()
df_info = pd.DataFrame.from_records(r_info["data"]["stations"]).convert_dtypes(
    dtype_backend="pyarrow"
)
df_info
Loading...

Next, we’ll get the station status from the station_status/ endpoint

r = requests.get(url_status).json()
df_status = pd.DataFrame.from_records(r["data"]["stations"]).convert_dtypes(
    dtype_backend="pyarrow"
)
df_status
Loading...

Transform

Next, we’ll merge these two outputs using the station_id column

df = df_info.merge(df_status, on="station_id", how="left")
df
Loading...