Skip to main content

RITIS INRIX API

PyPI PyPI - Python Version GitHub License

GitHub issues Unit Tests

A Python package for automated retrieval of traffic data from RITIS and INRIX APIs for INRIX XD Segments.

Installation

pip install ritis-inrix-api

Core Functionality

This package provides tools to:

  • Download Historical Data: Retrieve historical XD segment data from the RITIS API for specific date ranges or on a daily schedule.
  • Fetch Real-Time Data: Get current traffic speeds from the INRIX API.
  • Scrape Segment Geometries: Identify and retrieve XD segment geometries based on a list of latitude/longitude coordinates.

Examples

Here are some examples of how to use the package.

RITIS API: Download Historical Data

You can download data for a specific date range or set up a recurring daily download.

Download data for a single period

import os
from ritis_inrix_api import RITIS_Downloader

segments = [1236893704, 1236860943]

updater = RITIS_Downloader(
    api_key=os.environ.get('RITIS_API_KEY'),
    segments=segments, # can be list of IDs or path to a .txt file
    columns=['speed', 'travel_time_seconds'], # Specify desired columns
    start_time='06:00:00', #default is '00:00:00
    end_time='06:15:00', #default is '23:59:00'
    bin_size=5, #Enter 1, 5, 10, 15(default), or 60
    units='seconds', #'seconds' or 'minutes'
    #download_path='Data', #where to save data

) 

# Returns a pandas DataFrame (unless download_path is specified)
df = updater.single_download('2025-09-01', '2025-09-02', 'test')
Sample Output
xd_id measurement_tstamp speed travel_time_seconds
0 1236860943 2025-09-01 06:00:00 25 11.95
1 1236860943 2025-09-01 06:05:00 25 11.95
2 1236860943 2025-09-01 06:10:00 25 11.95

Set up automated daily downloads

This will download data from the last run date through yesterday one day at a time and save it as Parquet files at the specified download path. This option is intended to run daily via a scheduler like cron or Windows Task Scheduler.

import os
from ritis_inrix_api import RITIS_Downloader

updater = RITIS_Downloader(
    api_key=os.environ.get('RITIS_API_KEY'),
    download_path='Data', # Data will be saved in this directory
    segments='sample_XD_segments.txt', # Path to a file with segment IDs
    last_run_path='last_run.txt' # Path for text file containing last run datetime
) 

updater.daily_download()

INRIX API: Fetch Real-Time Speeds

import os
from ritis_inrix_api import INRIX_Downloader

inrix_downloader = INRIX_Downloader(
    app_id=os.environ.get('INRIX_APP_ID'),
    hash_token=os.environ.get('INRIX_HASH_TOKEN'),
    segments_path='sample_XD_segments.txt'
)

# Returns a pandas DataFrame
speed_data = inrix_downloader.get_speed_data()
Sample Output
code type speed average
0 1236893704 XDS 53 52
1 1236860943 XDS 21 19

Geometry Scraper: Find Segments and Geometries

This tool finds XD segment geometries within a specified radius of given latitude/longitude points.

The Geometry Scraper requires a valid browser cookie from a logged-in RITIS session to authenticate its requests. Open network tab in dev tools look for a request that has a cookie, copy and paste the cookie when prompted in the console.

Example Usage

from ritis_inrix_api import GeometryScraper

# A list of (latitude, longitude) tuples
locations = [
    (42.34072155027376, -122.89930147132378),
    (44.3029045246138, -120.842181329508),
    # ... more locations
]

# The scraper will prompt you to paste the cookie into the console
scraper = GeometryScraper()
geometry_data = scraper.process_locations(locations, buffer_size=50) # buffer size in yards

# Save the new segment IDs to a file
segments = list(geometry_data['segID'])
with open('Map_Data/XD_Segments.txt', 'w') as f:
    f.write(','.join(map(str, segments)))
Sample Output

The script will print progress messages as it runs:

Processing 1002 locations in batches of 500
Processing batch 1
Processing batch 2
Processing batch 3
Combining all batches into a single DataFrame
There were 5008 segments found for the provided signals.

The final geometry_data DataFrame will look like this:

zip country segID bearing county ... coordinates
0 97051 USA 1237027426 E COLUMBIA ... [[-122.8316, 45.84865], [-122.83134, 45.84852], ...]
1 97756 USA 1237004066 S DESCHUTES ... [[-121.19391, 44.24292], [-121.1941, 44.2427], ...]
2 97527 USA 125164532 E JOSEPHINE ... [[-123.32078, 42.42779], [-123.32054, 42.42772], ...]

Metadata

Release files for ritis-inrix-api 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ritis-inrix-api 1.0.0
File Size Uploaded Provenance
ritis_inrix_api-1.0.0.tar.gz 16.9 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ritis-inrix-api 1.0.0
File Interpreter ABI Platform
ritis_inrix_api-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 32.6 kB

Release files / ritis_inrix_api-1.0.0.tar.gz

Download URL ritis_inrix_api-1.0.0.tar.gz
Size 16.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b6a5617b48af1f035763d422300a34caf8bcdcfaa272c6239013a02bb625fd1b
BLAKE2b-256 checksum
How to use checksums
d225b5d9401d7d3d3ab95fb040c61a1fa2ab4621abb05cf867ff42d6d2158eb2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 10, 2025.

Transparency log

Release files / ritis_inrix_api-1.0.0-py3-none-any.whl

Download URL ritis_inrix_api-1.0.0-py3-none-any.whl
Size 15.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c3880123d16aca2f454f7c9c98b19b02884562e09cb8840bc90ec1cb4f7e441b
BLAKE2b-256 checksum
How to use checksums
2aae346a5997e6a78fb44252a4ec65e1a7c97f1cf303a0ea907fb3318f7ceb0e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 10, 2025.

Transparency log

Security for ritis-inrix-api 1.0.0

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ritis_inrix_api-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 10, 2025.

Transparency log

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.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page