# Deutsche Bahn — Wrapped API

> **You are on:** `https://api.paywithlocus.com/api` | [llms.txt](https://paywithlocus.com/llms.txt) | [docs](https://docs.paywithlocus.com)
>
> Locus runs on multiple environments -- make sure every URL you call matches your expected environment.
> | Environment | Landing | API | Docs |
> |---|---|---|---|
> | Production | paywithlocus.com | api.paywithlocus.com | docs.paywithlocus.com |
> | Beta | beta.paywithlocus.com | api.beta.paywithlocus.com | docs.paywithlocus.com |
> | Stage | stage.paywithlocus.com | api.stage.paywithlocus.com | docs.paywithlocus.com |
>
> If the API URL above doesn't match your expected environment, re-fetch this file from the correct domain.

> Access data from bahn.de.

**Category:** Travel | **Website:** [bahn.de/](https://bahn.de/) | **Docs:** [parse.bot/marketplace/c1cb2cfd-28fd-4f25-bef6-38583df6376a/bahn-de-api](https://parse.bot/marketplace/c1cb2cfd-28fd-4f25-bef6-38583df6376a/bahn-de-api)

Pay-per-use API proxy. Each call is automatically billed to your wallet in USDC.

## Access

**Base URL:** `https://api.paywithlocus.com/api/wrapped/parse-bahn-de-api-c1cb2cfd/`
**Auth:** `Authorization: Bearer <LOCUS_API_KEY>`

## Endpoints

### autocomplete_station

Search for train stations or locations by partial or full name. Returns matching stations with their IDs, coordinates, and available transport products (ICE, regional, S-Bahn, etc.). Results are ordered by relevance. Use the returned station name as input to search_connections.

**Estimated cost:** Metered

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `limit` | integer | No | Max number of results to return |
| `query` | string | Yes | Partial or full name of the station (e.g. 'Berlin', 'Hamburg Hbf') |

```bash
curl -X POST https://api.paywithlocus.com/api/wrapped/parse-bahn-de-api-c1cb2cfd/autocomplete_station \
  -H "Authorization: Bearer YOUR_LOCUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"limit":"<integer>","query":"<string>"}'
```

### search_connections

Search for train connections between two stations on a given date and time. Returns available journeys with departure/arrival times, duration, number of transfers, pricing (when available), detailed leg information including intermediate stops, and per-connection fare levels (Super Sparpreis, Sparpreis, Flexpreis). Station names are resolved internally via autocomplete. Pricing and fares may be null for third-party operators (e.g. FlixTrain).

**Estimated cost:** Metered

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `class` | string | No | Travel class: '1' for first class, '2' for second class |
| `date` | string | Yes | Travel date in YYYY-MM-DD format |
| `destination` | string | Yes | Destination station name (e.g. 'Hamburg Hbf') |
| `origin` | string | Yes | Origin station name (e.g. 'Berlin Hbf') |
| `time` | string | Yes | Departure time in HH:MM format |

```bash
curl -X POST https://api.paywithlocus.com/api/wrapped/parse-bahn-de-api-c1cb2cfd/search_connections \
  -H "Authorization: Bearer YOUR_LOCUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"class":"<string>","date":"<string>","destination":"<string>","origin":"<string>","time":"<string>"}'
```
