
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
An asynchronous Python client for the CTS (Compagnie des Transports Strasbourgeois) API.
You can install this library from the repository:
pip install git+https://github.com/theggz/cts-api.git
First, you need to get an API token from the CTS API website.
Then, you can initialize the client and make API calls:
import asyncio
from cts_api.client import CtsApi
async def main():
# Initialize the client with your API token
# Make sure to replace "YOUR_API_TOKEN" with your actual token
api = CtsApi(token="YOUR_API_TOKEN", session=None)
# Example: Get all lines
lines_response = await api.lines_discovery()
for line in lines_response.lines_delivery.annotated_line_refs:
print(f"Line {line.line_name} ({line.line_ref})")
# Example: Get stop points near a location
stop_points_response = await api.stoppoints_discovery(
latitude=48.583,
longitude=7.75,
distance=500
)
for stop in stop_points_response.stop_points_delivery.annotated_stop_point_ref:
print(f"Stop: {stop.stop_name}")
# Example: Get next departures for a stop
stop_monitoring_response = await api.stop_monitoring(monitoring_ref="280a")
for visit in stop_monitoring_response.service_delivery.stop_monitoring_delivery[0].monitored_stop_visit:
journey = visit.monitored_vehicle_journey
print(
f"Line {journey.published_line_name} to {journey.destination_name}: "
f"at {journey.monitored_call.expected_departure_time}"
)
if __name__ == "__main__":
asyncio.run(main())
All methods are async
and raise exceptions derived from CtsError
on failure.
CtsApi(token, session=None)
: Constructor. token
is your API key. session
is an optional aiohttp.ClientSession
.
lines_discovery()
: Returns a list of all lines.
stoppoints_discovery(latitude, longitude, distance, stop_code=None, ...)
: Returns a list of stop points. Can search by coordinates and distance, or by stop code.
stop_monitoring(monitoring_ref, ...)
: Provides a stop-centric view of vehicle departures (real-time) at a designated stop. monitoring_ref
is typically a stop code.
general_messages()
: Returns messages about traffic, services, commercial information, etc.
To run the tests, first clone the repository and install the development dependencies:
git clone https://github.com/theggz/cts-api.git
cd cts-api
pip install -e .
pip install pytest pytest-asyncio faker
The unit tests mock the API and can be run without an API token:
pytest
The integration tests run against the live CTS API and require a valid API token.
Set your API token as an environment variable:
export CTS_API_TOKEN="YOUR_API_TOKEN"
Run the tests marked as integration
:
pytest -m integration
FAQs
Asynchronous API client for interaction with the CTS api.
We found that cts-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.