metro-route-sdk 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- metro_route_sdk-0.1.0/PKG-INFO +74 -0
- metro_route_sdk-0.1.0/README.md +60 -0
- metro_route_sdk-0.1.0/metro_route/__init__.py +4 -0
- metro_route_sdk-0.1.0/metro_route/async_client.py +60 -0
- metro_route_sdk-0.1.0/metro_route/client.py +60 -0
- metro_route_sdk-0.1.0/metro_route_sdk.egg-info/PKG-INFO +74 -0
- metro_route_sdk-0.1.0/metro_route_sdk.egg-info/SOURCES.txt +10 -0
- metro_route_sdk-0.1.0/metro_route_sdk.egg-info/dependency_links.txt +1 -0
- metro_route_sdk-0.1.0/metro_route_sdk.egg-info/requires.txt +1 -0
- metro_route_sdk-0.1.0/metro_route_sdk.egg-info/top_level.txt +1 -0
- metro_route_sdk-0.1.0/pyproject.toml +25 -0
- metro_route_sdk-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: metro-route-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK for the Metro Route Premium API.
|
|
5
|
+
Author-email: Siddharth <app.details@zohomail.in>
|
|
6
|
+
Project-URL: Homepage, https://github.com/sidd-harth830/Delhi-Metro-API
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/sidd-harth830/Delhi-Metro-API/issues
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
Requires-Dist: httpx>=0.24.0
|
|
14
|
+
|
|
15
|
+
# Metro Route SDK (Python)
|
|
16
|
+
|
|
17
|
+
The official Python client library for the Delhi & Noida Metro Premium API.
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install metro-route-sdk
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
This SDK provides both synchronous and asynchronous clients.
|
|
28
|
+
|
|
29
|
+
### Synchronous Client
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
from metro_route import MetroRouteClient
|
|
33
|
+
|
|
34
|
+
# Initialize the client
|
|
35
|
+
client = MetroRouteClient()
|
|
36
|
+
|
|
37
|
+
# Get all operating lines
|
|
38
|
+
lines = client.get_lines()
|
|
39
|
+
print(lines)
|
|
40
|
+
|
|
41
|
+
# Plan a Noida Metro journey
|
|
42
|
+
journey = client.plan_nmrc_journey(from_station_id="1", to_station_id="16")
|
|
43
|
+
print(journey)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Asynchronous Client
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
import asyncio
|
|
50
|
+
from metro_route import AsyncMetroRouteClient
|
|
51
|
+
|
|
52
|
+
async def main():
|
|
53
|
+
# Use async context manager for proper connection pooling
|
|
54
|
+
async with AsyncMetroRouteClient() as client:
|
|
55
|
+
# Get Noida Metro stations
|
|
56
|
+
stations = await client.get_nmrc_stations()
|
|
57
|
+
print(stations)
|
|
58
|
+
|
|
59
|
+
# Plan a DMRC journey
|
|
60
|
+
journey = await client.plan_journey(from_station="RG", to_station="DW21")
|
|
61
|
+
print(journey)
|
|
62
|
+
|
|
63
|
+
asyncio.run(main())
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Available Methods
|
|
67
|
+
- `get_lines()`
|
|
68
|
+
- `get_stations_by_line(line_code: str)`
|
|
69
|
+
- `search_stations(name: str)`
|
|
70
|
+
- `get_station_details(station_code: str)`
|
|
71
|
+
- `plan_journey(from_station: str, to_station: str)`
|
|
72
|
+
- `get_notifications()`
|
|
73
|
+
- `get_nmrc_stations()`
|
|
74
|
+
- `plan_nmrc_journey(from_station_id: str, to_station_id: str)`
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Metro Route SDK (Python)
|
|
2
|
+
|
|
3
|
+
The official Python client library for the Delhi & Noida Metro Premium API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install metro-route-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
This SDK provides both synchronous and asynchronous clients.
|
|
14
|
+
|
|
15
|
+
### Synchronous Client
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from metro_route import MetroRouteClient
|
|
19
|
+
|
|
20
|
+
# Initialize the client
|
|
21
|
+
client = MetroRouteClient()
|
|
22
|
+
|
|
23
|
+
# Get all operating lines
|
|
24
|
+
lines = client.get_lines()
|
|
25
|
+
print(lines)
|
|
26
|
+
|
|
27
|
+
# Plan a Noida Metro journey
|
|
28
|
+
journey = client.plan_nmrc_journey(from_station_id="1", to_station_id="16")
|
|
29
|
+
print(journey)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Asynchronous Client
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
import asyncio
|
|
36
|
+
from metro_route import AsyncMetroRouteClient
|
|
37
|
+
|
|
38
|
+
async def main():
|
|
39
|
+
# Use async context manager for proper connection pooling
|
|
40
|
+
async with AsyncMetroRouteClient() as client:
|
|
41
|
+
# Get Noida Metro stations
|
|
42
|
+
stations = await client.get_nmrc_stations()
|
|
43
|
+
print(stations)
|
|
44
|
+
|
|
45
|
+
# Plan a DMRC journey
|
|
46
|
+
journey = await client.plan_journey(from_station="RG", to_station="DW21")
|
|
47
|
+
print(journey)
|
|
48
|
+
|
|
49
|
+
asyncio.run(main())
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Available Methods
|
|
53
|
+
- `get_lines()`
|
|
54
|
+
- `get_stations_by_line(line_code: str)`
|
|
55
|
+
- `search_stations(name: str)`
|
|
56
|
+
- `get_station_details(station_code: str)`
|
|
57
|
+
- `plan_journey(from_station: str, to_station: str)`
|
|
58
|
+
- `get_notifications()`
|
|
59
|
+
- `get_nmrc_stations()`
|
|
60
|
+
- `plan_nmrc_journey(from_station_id: str, to_station_id: str)`
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import httpx
|
|
2
|
+
from typing import Optional, Dict, Any, List
|
|
3
|
+
|
|
4
|
+
class AsyncMetroRouteClient:
|
|
5
|
+
"""Asynchronous Client for the Metro Route Premium API."""
|
|
6
|
+
|
|
7
|
+
def __init__(self, base_url: str = "https://siddharth7307-delhi-metro-api.hf.space/api/v2"):
|
|
8
|
+
self.base_url = base_url.rstrip("/")
|
|
9
|
+
self.client = httpx.AsyncClient(base_url=self.base_url)
|
|
10
|
+
|
|
11
|
+
async def _get(self, endpoint: str, params: Optional[Dict[str, Any]] = None) -> Any:
|
|
12
|
+
response = await self.client.get(endpoint, params=params)
|
|
13
|
+
response.raise_for_status()
|
|
14
|
+
return response.json()
|
|
15
|
+
|
|
16
|
+
# --- DMRC (Delhi Metro) Endpoints ---
|
|
17
|
+
|
|
18
|
+
async def get_lines(self) -> List[Dict[str, Any]]:
|
|
19
|
+
"""Get all Delhi Metro lines."""
|
|
20
|
+
return await self._get("/dmrc/lines")
|
|
21
|
+
|
|
22
|
+
async def get_stations_by_line(self, line_code: str) -> List[Dict[str, Any]]:
|
|
23
|
+
"""Get all stations for a specific Delhi Metro line."""
|
|
24
|
+
return await self._get(f"/dmrc/lines/{line_code}/stations")
|
|
25
|
+
|
|
26
|
+
async def search_stations(self, name: str) -> List[Dict[str, Any]]:
|
|
27
|
+
"""Search for Delhi Metro stations by name."""
|
|
28
|
+
return await self._get("/dmrc/stations/search", params={"name": name})
|
|
29
|
+
|
|
30
|
+
async def get_station_details(self, station_code: str) -> Dict[str, Any]:
|
|
31
|
+
"""Get details for a specific Delhi Metro station."""
|
|
32
|
+
return await self._get(f"/dmrc/stations/{station_code}")
|
|
33
|
+
|
|
34
|
+
async def plan_journey(self, from_station: str, to_station: str) -> Dict[str, Any]:
|
|
35
|
+
"""Plan a journey between two Delhi Metro stations (default route)."""
|
|
36
|
+
return await self._get("/dmrc/journeys/fare-route", params={"from_station_code": from_station, "to_station_code": to_station})
|
|
37
|
+
|
|
38
|
+
async def get_notifications(self) -> List[Dict[str, Any]]:
|
|
39
|
+
"""Fetch latest DMRC notifications."""
|
|
40
|
+
return await self._get("/dmrc/notifications")
|
|
41
|
+
|
|
42
|
+
# --- NMRC (Noida Metro) Endpoints ---
|
|
43
|
+
|
|
44
|
+
async def get_nmrc_stations(self) -> List[Dict[str, Any]]:
|
|
45
|
+
"""Get all Noida Metro (Aqua Line) stations."""
|
|
46
|
+
return await self._get("/nmrc/stations")
|
|
47
|
+
|
|
48
|
+
async def plan_nmrc_journey(self, from_station_id: str, to_station_id: str) -> Dict[str, Any]:
|
|
49
|
+
"""Plan a journey on the Noida Metro Aqua Line."""
|
|
50
|
+
return await self._get("/nmrc/journeys/plan", params={"from": from_station_id, "to": to_station_id})
|
|
51
|
+
|
|
52
|
+
async def close(self):
|
|
53
|
+
"""Close the underlying HTTP client."""
|
|
54
|
+
await self.client.aclose()
|
|
55
|
+
|
|
56
|
+
async def __aenter__(self):
|
|
57
|
+
return self
|
|
58
|
+
|
|
59
|
+
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
|
60
|
+
await self.close()
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import httpx
|
|
2
|
+
from typing import Optional, Dict, Any, List
|
|
3
|
+
|
|
4
|
+
class MetroRouteClient:
|
|
5
|
+
"""Synchronous Client for the Metro Route Premium API."""
|
|
6
|
+
|
|
7
|
+
def __init__(self, base_url: str = "https://siddharth7307-delhi-metro-api.hf.space/api/v2"):
|
|
8
|
+
self.base_url = base_url.rstrip("/")
|
|
9
|
+
self.client = httpx.Client(base_url=self.base_url)
|
|
10
|
+
|
|
11
|
+
def _get(self, endpoint: str, params: Optional[Dict[str, Any]] = None) -> Any:
|
|
12
|
+
response = self.client.get(endpoint, params=params)
|
|
13
|
+
response.raise_for_status()
|
|
14
|
+
return response.json()
|
|
15
|
+
|
|
16
|
+
# --- DMRC (Delhi Metro) Endpoints ---
|
|
17
|
+
|
|
18
|
+
def get_lines(self) -> List[Dict[str, Any]]:
|
|
19
|
+
"""Get all Delhi Metro lines."""
|
|
20
|
+
return self._get("/dmrc/lines")
|
|
21
|
+
|
|
22
|
+
def get_stations_by_line(self, line_code: str) -> List[Dict[str, Any]]:
|
|
23
|
+
"""Get all stations for a specific Delhi Metro line."""
|
|
24
|
+
return self._get(f"/dmrc/lines/{line_code}/stations")
|
|
25
|
+
|
|
26
|
+
def search_stations(self, name: str) -> List[Dict[str, Any]]:
|
|
27
|
+
"""Search for Delhi Metro stations by name."""
|
|
28
|
+
return self._get("/dmrc/stations/search", params={"name": name})
|
|
29
|
+
|
|
30
|
+
def get_station_details(self, station_code: str) -> Dict[str, Any]:
|
|
31
|
+
"""Get details for a specific Delhi Metro station."""
|
|
32
|
+
return self._get(f"/dmrc/stations/{station_code}")
|
|
33
|
+
|
|
34
|
+
def plan_journey(self, from_station: str, to_station: str) -> Dict[str, Any]:
|
|
35
|
+
"""Plan a journey between two Delhi Metro stations (default route)."""
|
|
36
|
+
return self._get("/dmrc/journeys/fare-route", params={"from_station_code": from_station, "to_station_code": to_station})
|
|
37
|
+
|
|
38
|
+
def get_notifications(self) -> List[Dict[str, Any]]:
|
|
39
|
+
"""Fetch latest DMRC notifications."""
|
|
40
|
+
return self._get("/dmrc/notifications")
|
|
41
|
+
|
|
42
|
+
# --- NMRC (Noida Metro) Endpoints ---
|
|
43
|
+
|
|
44
|
+
def get_nmrc_stations(self) -> List[Dict[str, Any]]:
|
|
45
|
+
"""Get all Noida Metro (Aqua Line) stations."""
|
|
46
|
+
return self._get("/nmrc/stations")
|
|
47
|
+
|
|
48
|
+
def plan_nmrc_journey(self, from_station_id: str, to_station_id: str) -> Dict[str, Any]:
|
|
49
|
+
"""Plan a journey on the Noida Metro Aqua Line."""
|
|
50
|
+
return self._get("/nmrc/journeys/plan", params={"from": from_station_id, "to": to_station_id})
|
|
51
|
+
|
|
52
|
+
def close(self):
|
|
53
|
+
"""Close the underlying HTTP client."""
|
|
54
|
+
self.client.close()
|
|
55
|
+
|
|
56
|
+
def __enter__(self):
|
|
57
|
+
return self
|
|
58
|
+
|
|
59
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
60
|
+
self.close()
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: metro-route-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK for the Metro Route Premium API.
|
|
5
|
+
Author-email: Siddharth <app.details@zohomail.in>
|
|
6
|
+
Project-URL: Homepage, https://github.com/sidd-harth830/Delhi-Metro-API
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/sidd-harth830/Delhi-Metro-API/issues
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
Requires-Dist: httpx>=0.24.0
|
|
14
|
+
|
|
15
|
+
# Metro Route SDK (Python)
|
|
16
|
+
|
|
17
|
+
The official Python client library for the Delhi & Noida Metro Premium API.
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install metro-route-sdk
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
This SDK provides both synchronous and asynchronous clients.
|
|
28
|
+
|
|
29
|
+
### Synchronous Client
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
from metro_route import MetroRouteClient
|
|
33
|
+
|
|
34
|
+
# Initialize the client
|
|
35
|
+
client = MetroRouteClient()
|
|
36
|
+
|
|
37
|
+
# Get all operating lines
|
|
38
|
+
lines = client.get_lines()
|
|
39
|
+
print(lines)
|
|
40
|
+
|
|
41
|
+
# Plan a Noida Metro journey
|
|
42
|
+
journey = client.plan_nmrc_journey(from_station_id="1", to_station_id="16")
|
|
43
|
+
print(journey)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Asynchronous Client
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
import asyncio
|
|
50
|
+
from metro_route import AsyncMetroRouteClient
|
|
51
|
+
|
|
52
|
+
async def main():
|
|
53
|
+
# Use async context manager for proper connection pooling
|
|
54
|
+
async with AsyncMetroRouteClient() as client:
|
|
55
|
+
# Get Noida Metro stations
|
|
56
|
+
stations = await client.get_nmrc_stations()
|
|
57
|
+
print(stations)
|
|
58
|
+
|
|
59
|
+
# Plan a DMRC journey
|
|
60
|
+
journey = await client.plan_journey(from_station="RG", to_station="DW21")
|
|
61
|
+
print(journey)
|
|
62
|
+
|
|
63
|
+
asyncio.run(main())
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Available Methods
|
|
67
|
+
- `get_lines()`
|
|
68
|
+
- `get_stations_by_line(line_code: str)`
|
|
69
|
+
- `search_stations(name: str)`
|
|
70
|
+
- `get_station_details(station_code: str)`
|
|
71
|
+
- `plan_journey(from_station: str, to_station: str)`
|
|
72
|
+
- `get_notifications()`
|
|
73
|
+
- `get_nmrc_stations()`
|
|
74
|
+
- `plan_nmrc_journey(from_station_id: str, to_station_id: str)`
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
metro_route/__init__.py
|
|
4
|
+
metro_route/async_client.py
|
|
5
|
+
metro_route/client.py
|
|
6
|
+
metro_route_sdk.egg-info/PKG-INFO
|
|
7
|
+
metro_route_sdk.egg-info/SOURCES.txt
|
|
8
|
+
metro_route_sdk.egg-info/dependency_links.txt
|
|
9
|
+
metro_route_sdk.egg-info/requires.txt
|
|
10
|
+
metro_route_sdk.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
httpx>=0.24.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
metro_route
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "metro-route-sdk"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name="Siddharth", email="app.details@zohomail.in" },
|
|
10
|
+
]
|
|
11
|
+
description = "Official Python SDK for the Metro Route Premium API."
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.8"
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
]
|
|
19
|
+
dependencies = [
|
|
20
|
+
"httpx>=0.24.0",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[project.urls]
|
|
24
|
+
"Homepage" = "https://github.com/sidd-harth830/Delhi-Metro-API"
|
|
25
|
+
"Bug Tracker" = "https://github.com/sidd-harth830/Delhi-Metro-API/issues"
|