Skip to content

Commit 7ea82d9

Browse files
committed
update api
1 parent abd90fd commit 7ea82d9

22 files changed

+414
-1160
lines changed

README.md

Lines changed: 164 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,182 @@
1-
## A fully typed Tbilisi Transport Company API Wrapper
1+
# ttc-api
22

3-
### [Documentation](docs/modules/ttc.md)
3+
A fully typed TypeScript wrapper for the Tbilisi Transport Company (TTC) API, providing real-time access to public transport data in Tbilisi, Georgia.
44

5-
### Installation
5+
[![npm version](https://img.shields.io/npm/v/ttc-api.svg)](https://www.npmjs.com/package/ttc-api)
6+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7+
8+
## Features
9+
10+
- 🚌 Real-time bus locations and arrival times
11+
- 🗺️ Route planning and navigation
12+
- 🎯 Bus stop information
13+
- ⌚ Live arrival predictions
14+
- 📝 Full TypeScript support
15+
- 🌍 Multilingual support (Georgian and English)
16+
17+
## Installation
618

719
```bash
820
# npm
9-
$ npm install ttc-api
21+
npm install ttc-api
1022

1123
# yarn
12-
$ yarn add ttc-api
24+
yarn add ttc-api
1325

1426
# pnpm
15-
$ pnpm add ttc-api
27+
pnpm add ttc-api
1628
```
1729

18-
### Usage
30+
## Usage
31+
32+
### Basic Examples
1933

2034
```typescript
2135
import { ttc } from "ttc-api";
2236

23-
const arrivalTimes = await ttc.stopArrivalTimes("1946").then((arrivalTimes) => {
37+
// Set preferred language (optional, defaults to 'en')
38+
ttc.setLocale("en"); // or "ka" for Georgian
39+
40+
// Get all bus stops
41+
const stops = await ttc.stops();
42+
43+
// Get arrival times for a specific stop
44+
const arrivals = await ttc.arrivalTimes({
45+
stopId: "1946",
46+
ignoreScheduledArrivalTimes: false,
47+
});
48+
49+
// Get real-time bus locations
50+
const busLocations = await ttc.locations({
51+
busId: "123",
52+
forward: true,
53+
});
54+
55+
// Plan a route
56+
const journey = await ttc.plan({
57+
from: [41.7151, 44.8271], // [latitude, longitude]
58+
to: [41.7099, 44.7929],
59+
locale: "en",
60+
});
61+
```
62+
63+
### Advanced Usage
64+
65+
#### Get Routes for a Specific Stop
66+
67+
```typescript
68+
const stopRoutes = await ttc.stopRoutes({
69+
stopId: "1946",
70+
locale: "en",
71+
});
72+
73+
stopRoutes.forEach((route) => {
74+
console.log(`Bus ${route.shortName}: ${route.longName}`);
75+
});
76+
```
77+
78+
#### Monitor Real-time Arrivals
79+
80+
```typescript
81+
const monitorArrivals = async (stopId: string) => {
82+
const arrivals = await ttc.arrivalTimes({ stopId });
83+
84+
arrivals.forEach((arrival) => {
85+
console.log(
86+
`Bus ${arrival.shortName} arriving in ${arrival.realtimeArrivalMinutes} minutes`
87+
);
88+
console.log(`Status: ${arrival.realtime ? "Real-time" : "Scheduled"}`);
89+
});
90+
};
91+
```
92+
93+
## API Reference
94+
95+
### Core Functions
96+
97+
#### `setLocale(locale: "ka" | "en")`
98+
99+
Set the preferred language for responses.
100+
101+
#### `stops(params?: { locale?: "ka" | "en" })`
102+
103+
Get all bus stops in the network.
104+
105+
#### `stop(stopId: string)`
106+
107+
Get detailed information about a specific stop.
108+
109+
#### `routes(params?: { locale?: "ka" | "en" })`
110+
111+
Get all bus routes.
24112

25-
for (let at of arrivalTimes) {
26-
console.log(`${at.RouteNumber} arrives in ${at.ArrivalTime} minutes`);
113+
#### `plan(options: PlanOptions)`
114+
115+
Plan a journey between two points.
116+
117+
```typescript
118+
interface PlanOptions {
119+
from: [number, number]; // [latitude, longitude]
120+
to: [number, number]; // [latitude, longitude]
121+
locale?: "ka" | "en";
122+
}
123+
```
124+
125+
#### `locations(options: LocationOptions)`
126+
127+
Get real-time locations of buses on a route.
128+
129+
```typescript
130+
interface LocationOptions {
131+
busId: string;
132+
forward?: boolean;
133+
}
134+
```
135+
136+
#### `arrivalTimes(options: ArrivalOptions)`
137+
138+
Get arrival predictions for a stop.
139+
140+
```typescript
141+
interface ArrivalOptions {
142+
stopId: string;
143+
locale?: "ka" | "en";
144+
ignoreScheduledArrivalTimes?: boolean;
27145
}
28146
```
147+
148+
### Types
149+
150+
The library includes comprehensive TypeScript definitions for all API responses. Key types include:
151+
152+
```typescript
153+
type Locale = "ka" | "en";
154+
155+
interface BusStop {
156+
id: string;
157+
code: string | null;
158+
name: string;
159+
lat: number;
160+
lon: number;
161+
vehicleMode: "BUS" | "GONDOLA" | "SUBWAY";
162+
}
163+
164+
interface BusArrival {
165+
shortName: string;
166+
color: string;
167+
headsign: string;
168+
realtime: boolean;
169+
realtimeArrivalMinutes: number;
170+
scheduledArrivalMinutes: number;
171+
}
172+
173+
// ... and more
174+
```
175+
176+
## Acknowledgments
177+
178+
- Built with [requestly](https://www.npmjs.com/package/requestly) for HTTP requests
179+
180+
## Support
181+
182+
If you encounter any issues or have questions, please [open an issue](https://github.com/sunneydev/ttc-api/issues) on GitHub.

docs/.nojekyll

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/README.md

Lines changed: 0 additions & 10 deletions
This file was deleted.

docs/enums/types.Color.md

Lines changed: 0 additions & 43 deletions
This file was deleted.

docs/enums/types.Mode.md

Lines changed: 0 additions & 32 deletions
This file was deleted.

docs/enums/types.TransportType.md

Lines changed: 0 additions & 32 deletions
This file was deleted.

docs/interfaces/types.ArrivalInfo.md

Lines changed: 0 additions & 43 deletions
This file was deleted.

docs/interfaces/types.ArrivalTimesResponse.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)