Python API Client


to use the python api client you can install it from git


git clone git@github.com:availabs/dama-api-client-py.git
cd dama-api-client-py
python3 transcom.py


This will load the python client API and save a sample transcom query into a csv.


Transcom Example


#!/usr/bin/env python3
"""
Example usage of the Datamanager API Client
"""

import json
from datamanager_api_client import (
fetch_data_from_api,
parse_api_response_to_csv,
save_csv_to_file,
fetch_and_convert_to_csv
)

def main():
"""
Example usage of the API client functions.
"""

# Example parameters matching your provided example
view_id = 1947

filters = {
"groupBy": [],
"orderBy": {"cost": "desc nulls last"},
"filter": {
"month_year": ["06-2025"],
"region_name": ["Region 1 - Capital District"]
},
"exclude": {},
"normalFilter": [],
"meta": {}
}

columns = [
"event_id",
"reporting_organization",
"event_class",
"start_date_time",
"close_date",
"facility",
"event_duration",
"event_type",
"lanes_total_count",
"lanes_affected_count",
"lanes_detail",
"lanes_status",
"description",
"direction",
"event_location_latitude",
"event_location_longitude",
"recoverytime",
"f_system",
"vehicle_delay",
"cost"
]



try:
print("\n" + "="*50)
print("Fetch and convert in one step...")
csv_direct = fetch_and_convert_to_csv(view_id, filters, columns, 0, 100, "transcom_data_direct.csv")
print("Direct CSV conversion completed!")

except Exception as e:
print(f"Failed to fetch or convert data: {e}")

if __name__ == "__main__":
main()