Metadata-Version: 2.4
Name: metro-route-sdk
Version: 0.1.1
Summary: Official Python SDK for the Metro Route Premium API.
Author-email: Siddharth <app.details@zohomail.in>
Project-URL: Homepage, https://github.com/sidd-harth830/Delhi-Metro-API
Project-URL: Bug Tracker, https://github.com/sidd-harth830/Delhi-Metro-API/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.24.0

# Metro Route SDK (Python)

[![PyPI version](https://img.shields.io/pypi/v/metro-route-sdk.svg)](https://pypi.org/project/metro-route-sdk/)
[![Python versions](https://img.shields.io/pypi/pyversions/metro-route-sdk.svg)](https://pypi.org/project/metro-route-sdk/)

The official, highly optimized Python client library for the **Metro Route Premium API**. This SDK provides seamless, programmatic access to real-time data, station information, and journey planning for both the **Delhi Metro (DMRC)** and the **Noida Metro (NMRC)**.

## 🚀 Installation

```bash
pip install metro-route-sdk
```

## 💻 Quick Start

This SDK provides both a standard synchronous client (`MetroRouteClient`) and an asynchronous client (`AsyncMetroRouteClient`) for modern, high-performance web frameworks like FastAPI.

### Asynchronous Example (Recommended)
```python
import asyncio
from metro_route import AsyncMetroRouteClient

async def main():
    async with AsyncMetroRouteClient() as client:
        # Get all operating lines in Delhi
        lines = await client.get_lines()
        print(f"Found {len(lines)} metro lines!")

        # Plan a journey on the Noida Metro Aqua Line
        journey = await client.plan_nmrc_journey(from_station_id="1", to_station_id="16")
        print(f"Fare: ₹{journey['fare']}, Stations: {journey['stations_count']}")

asyncio.run(main())
```

### Synchronous Example
```python
from metro_route import MetroRouteClient

client = MetroRouteClient()
details = client.get_station_details("RG") # Rajiv Chowk
print(details)
client.close()
```

---

## 📚 Full API Reference

Both `MetroRouteClient` and `AsyncMetroRouteClient` expose the exact same methods (the async version just requires `await`).

### 🚆 Delhi Metro (DMRC) Endpoints

#### 1. `get_lines()`
Fetches a list of all currently operating Delhi Metro lines, including their hex colors and terminal stations.
- **Returns**: `List[dict]`

#### 2. `get_stations_by_line(line_code: str)`
Retrieves every station on a specific line sequentially.
- **Parameters**: 
  - `line_code` (str): The identifier for the line (e.g., `"YELLOW"`, `"BLUE"`).
- **Returns**: `List[dict]`

#### 3. `search_stations(name: str)`
Fuzzy-searches for stations matching the given name query.
- **Parameters**:
  - `name` (str): Search term (e.g., `"Rajiv"`).
- **Returns**: `List[dict]`

#### 4. `get_station_details(station_code: str)`
Retrieves comprehensive details about a specific station, including gates, platforms, and interchange information.
- **Parameters**:
  - `station_code` (str): The station's unique code (e.g., `"RG"` for Rajiv Chowk).
- **Returns**: `dict`

#### 5. `plan_journey(from_station: str, to_station: str)`
Calculates the optimal route between two DMRC stations, providing the exact fare, travel time, and a step-by-step path including interchanges.
- **Parameters**:
  - `from_station` (str): Starting station code.
  - `to_station` (str): Destination station code.
- **Returns**: `dict`

#### 6. `get_notifications()`
Fetches the latest official alerts, delays, and notifications directly from DMRC.
- **Returns**: `List[dict]`

---

### 🚊 Noida Metro (NMRC) Endpoints

#### 7. `get_nmrc_stations()`
Fetches all operational stations on the Noida Metro Aqua Line.
- **Returns**: `List[dict]`

#### 8. `plan_nmrc_journey(from_station_id: str, to_station_id: str)`
Calculates the fare and route for a journey entirely within the Aqua Line network.
- **Parameters**:
  - `from_station_id` (str): Numeric string ID of the starting station (e.g., `"1"` for Sector 51).
  - `to_station_id` (str): Numeric string ID of the destination station.
- **Returns**: `dict`

## ⚙️ Configuration
By default, the client points to the live production server. You can override the `base_url` during initialization if you are hosting the API yourself:
```python
client = MetroRouteClient(base_url="http://localhost:8000/api/v2")
```
