An open API service indexing awesome lists of open source software.

https://github.com/dnnskrgr/easytrias-php-proxy

PHP-based Proxy API for querying real-time departure data via the TRIAS interface
https://github.com/dnnskrgr/easytrias-php-proxy

api php public-transit public-transport trias

Last synced: 23 days ago
JSON representation

PHP-based Proxy API for querying real-time departure data via the TRIAS interface

Awesome Lists containing this project

README

        

# easyTRIAS โ€“ Proxy API for the TRIAS interface
**easyTRIAS** is an unofficial PHP-based proxy API for querying **real-time departure data from stops** via the **TRIAS interface**.

The API supports **multiple output formats**, **simple caching**, and can be deployed on any standard web server with minimal setup.

## โ„น๏ธ What is TRIAS?

TRIAS is an **XML-based, standardized exchange format for travel information systems** developed by the VDV (Verband Deutscher Verkehrsunternehmen). It is used for structured communication between passenger information systems, timetable services, and third-party applications.

TRIAS is flexible, standardized, and powerful โ€“ but is **currently not in widespread use in Germany**. However, many transport companies and timetable data pools are working on deploying TRIAS or are in pilot phases.

You can find more information about TRIAS and its documentation here: https://www.vdv.de/ip-kom-oev.aspx

## ๐Ÿ”ง Requirements
- Web server with **PHP 7.2 or higher**

- **Write permissions** for the configured cache directory

- **Access to a TRIAS endpoint** (e.g., via [Connect Niedersachsen](https://connect-fahrplanauskunft.de/datenbereitstellung) or [MobiData BW](https://www.mobidata-bw.de/dataset/trias))

## ๐Ÿ“ฆ Features
- Query real-time departure data via the TRIAS interface

- Multiple output formats: `json`, `xml`, `csv`, `html`, `raw`

- Caching to reduce external API requests

- Walking time filtering

- Transport Types with icon & color coding

## ๐Ÿงฎ Input parameters
| Parameter | Type | Required | Default | Description |
|------------------|----------|----------|-----------|---------------|
| `stopPointRef` | string | โœ… | โ€“ | TRIAS stop ID (e.g. `de:03241:31`) |
| `format` | string | โŒ | `html` | Output format (`json`, `xml`, `csv`, `html`, `raw`) |
| `walkingMinutes` | integer | โŒ | `0` | Walking time to the stop in minutes โ€“ earlier departures are filtered |
| `forceRefresh` | `0`/`1` | โŒ | `0` | If set to `1`, the cache will be bypassed and a fresh request is made |

## ๐Ÿงช Example calls
1. **HTML table:**
```bash
https://example.com/departures.php?stopPointRef=de:03241:31
```
2. **JSON with walking time filter:**
```bash
https://example.com/departures.php?stopPointRef=de:03241:31&format=json&walkingMinutes=5
```
3. **Raw TRIAS XML for debugging:**
```bash
https://example.com/departures.php?stopPointRef=de:03241:31&format=raw
```

## ๐Ÿ—ƒ๏ธ Caching
- Each query is cached for **10 minutes** by default to reduce external API calls

- Cache files are stored in the `/cache` directory, which is created automatically if it doesn't exist

- You can change the cache duration and directory path in the `/.env.ini` configuration file

- To disable caching, set the cache duration to `0`.

## ๐ŸŽจ Transport icons & colors
- Each transport mode (e.g., bus, train, tram) can be assigned a unique icon and color

- These mappings are defined in the `/src/Dictionaries.php` file

- The base URL for icon images can be configured in the `/.env.ini` file

## โš–๏ธ License
This project is licensed under the [Apache 2.0 License](https://opensource.org/license/apache-2-0).

You may **freely use, modify, and redistribute** the code, even in commercial projects โ€“ as long as the license and copyright notices are retained. Liability is excluded.

## ๐Ÿค Author
๐Ÿ‘ค Dennis Krรผger

๐Ÿ“ Hanover, Germany

๐ŸŒ [https://www.denniskr.de](https://www.denniskr.de)

## ๐Ÿ“ฌ Contact / Feedback
Do you have ideas, feedback, or would like to collaborate?

Feel free to open an issue on GitHub or reach out directly via email: [email protected]