CityofSantaMonica
mds-provider
Python

Python tools for working with MDS Provider data

Last updated Aug 21, 2024
18
Stars
20
Forks
8
Issues
0
Stars/day
Attention Score
20
Language breakdown
No language data available.
Files click to expand
README

mds-provider

Tools for working with [MDS provider][provider] data.

Developed and tested with Python 3.7+.

See mds-provider-services for real-world usage of many of these tools.

Installation

Install with pip:

pip install -e git+https://github.com/CityofSantaMonica/mds-provider@master#egg=mds-provider

Or with python directly:

git clone https://github.com/CityofSantaMonica/mds-provider.git
cd mds-provider
python setup.py install

Getting Started

Read from a Provider API

from datetime import datetime, timedelta

import mds

end = datetime.utcnow() start = end - timedelta(hours=1)

client = mds.Client("provider_name", token="secret-token")

trips = client.gettrips(starttime=start, end_time=end)

Validate against the MDS schema

validator = mds.DataValidator.trips()

for error in validator.validate(trips): print(error)

Load into a Postgres database

db = mds.Database(user="user", password="password", host="host", db="database")

db.load_trips(trips)

Package organization

| module | description | | --------- | ----------- | | mds| Tools for working with Mobility Data Specification provider data | | mds.api | Request data from compatible API endpoints | | mds.db | Work with databases | | mds.encoding | Custom data encoding and decoding. | | mds.fake | Generate fake provider data for testing and development | | mds.files | Work with provider configuration and data payload files | | mds.geometry | Helpers for GeoJSON-based geometry objects | | mds.github | Data and helpers for MDS on GitHub. | | mds.providers | Parse [Provider registry][registry] files | | mds.schemas | Validate data using the [JSON schemas][schemas] | | mds.versions | Work with [MDS versions][versions] |

[provider]: https://github.com/CityOfLosAngeles/mobility-data-specification/tree/master/provider [registry]: https://github.com/CityofLosAngeles/mobility-data-specification/blob/master/providers.csv [schemas]: https://github.com/CityOfLosAngeles/mobility-data-specification/tree/master/generate_schema [versions]: https://github.com/CityofLosAngeles/mobility-data-specification/releases

🔗 More in this category

© 2026 GitRepoTrend · CityofSantaMonica/mds-provider · Updated daily from GitHub