Skip to main content

AI-ready Python API wrapper for Île de France mobilités open-data API

Project description

pyidfm — Île-de-France Mobilités API

AI-ready Python API wrapper for the Île-de-France Mobilités open-data API. It exposes next-schedule lookups, traffic disruption reports and traffic messages for the Paris / Île-de-France public transport network (Metro, RER, Transilien, Tram, Bus).

The package is designed both as a regular Python library and as a CLI that is easy to drive from an LLM agent.

Part of this codebase (notably the SIRI / Navitia request plumbing in idfm.py and the dataclasses in models.py) is derived from the idfm-api package, with heavy modifications focused on reliability and LLM-friendliness rather than raw feature completeness.

Installation

pip install pyidfm

Or, from a checkout of this repository:

pip install .

API key

Live endpoints (next schedules, traffic reports, messages) require a free API key from the IDFM PRIM platform: https://prim.iledefrance-mobilites.fr/.

Once you have a key, expose it via the IDFM_API_KEY environment variable (every CLI command picks it up automatically) or pass it explicitly with the --apikey option.

export IDFM_API_KEY="your-key-here"

Static datasets

Lines and stops are resolved from local snapshots of the IDFM open-data datasets. They are downloaded on first use, but you can refresh them if required.

pyidfm update-data

CLI usage

The CLI is exposed as pyidfm once installed. Top-level commands:

Command Description
pyidfm update-data Download/refresh the local static datasets.
pyidfm search lines List lines, optionally filtered by transport mode.
pyidfm search stops List stops served by a given line.
pyidfm traffic Next schedules at a stop (live).
pyidfm line-report Traffic disruption reports for a line (live).
pyidfm messages Traffic messages for a line or stop (live).

All commands accept --json to emit machine-readable output, and the top-level --debug flag for verbose logging.

Examples

Find the ID of the RER D:

pyidfm search lines --mode rail

List the stops on a line:

pyidfm search stops C01742

Get the next departures at a stop:

pyidfm traffic --stop-id "STIF:StopArea:SP:43135:"

Get current disruptions on a line:

pyidfm line-report C01742

Python usage

from pyidfm.idfm import IDFMApi
from pyidfm.dataset import Dataset


# Live data (PRIM API key required)
api = IDFMApi(apikey="your-key-here")

stops = api.get_stops("C01742")
for s in stops:
    print(s.name, s.stop_id)

departures = api.get_traffic("STIF:StopArea:SP:43135:")
for d in departures:
    print(d.schedule, d.destination_name, d.direction)

reports = api.get_line_reports("C01742")
for r in reports:
    print(r.name, r.severity, r.effect)

Usage through LLMs

The CLI is the recommended entry point for LLM agents. A typical flow is three calls — search linessearch stopstraffic (or line-report / messages).

Output format guidance:

  • Standard output (default) — formatted table; use this when reporting information to the user.
  • --json — machine-parseable array; use this when extracting a specific value (an ID to pass to the next command, a departure time, a status).

See SKILL.md in this repository for the agent skill packaging used during development.

License

MIT — see LICENCE.

The IDFM open-data datasets bundled at runtime are redistributed under the ODbL; the live PRIM API is covered by the Licence Mobilité.

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

pyidfm-0.1.0.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

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

pyidfm-0.1.0-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file pyidfm-0.1.0.tar.gz.

File metadata

  • Download URL: pyidfm-0.1.0.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyidfm-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c3fc15f468a719f9475a7cc24cb27290c73102a8e22e560d100310707b361a35
MD5 ed62dced54f03ee32f35f5b7956a91f8
BLAKE2b-256 3ded2d44716288d442309d7b6ae0c178cd6627dbbf34b7d0c8bc60bb44e7259b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyidfm-0.1.0.tar.gz:

Publisher: release.yml on RobinDavid/pyidfm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyidfm-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyidfm-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyidfm-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 03641dee84a4d04050e44872e9e73cda7baf3b8a20a1e8d6b5693453d85aaeba
MD5 b5ea39a53d336c76e1cfd23059e76f14
BLAKE2b-256 10130b8dba0afee3d3da58acb2b85f1621f017a9b23aae0f2b197bc13a41898f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyidfm-0.1.0-py3-none-any.whl:

Publisher: release.yml on RobinDavid/pyidfm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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