Conectando...
TrenesRadar

API Pública

Documentación de la API REST de TrenesRadar

Base URL https://trenesradar.com
GET /api/trains
Probar

Returns all currently active trains.

Query Parameters

Parameter Description
type Filter by train type (cercanias, ave, alvia, regional, all)
bounds Filter by geographic bounds (north,south,east,west)

Response

Array of Train objects
GET /api/trains/:id

Returns details for a specific train including position history.

Response

Train object
GET /api/stations
Probar

Returns stations, searchable by name.

Query Parameters

Parameter Description
q Search query (min 2 chars)
nucleus Filter by cercanías nucleus
limit Max results (default 50)

Response

Array of Station objects
GET /api/stations/:id

Returns station details.

Response

Station object
GET /api/stations/:id/board

Returns departure/arrival board for a station.

Response

{ departures: BoardEntry[], arrivals: BoardEntry[] }
GET /api/alerts
Probar

Returns all active service alerts.

Response

Array of Alert objects
GET /api/stream

Server-Sent Events stream of real-time train positions.

Response

SSE stream with "positions" events

Data Types

Train

{
  id: string,
  tripId: string,
  line: string,
  label: string,
  lat: number,
  lng: number,
  status: "MOVING" | "STOPPED" | "INCOMING",
  nextStopId: string | null,
  delay: number,
  type: "cercanias" | "ld" | "ave" | "unknown",
  operator: string,
  updatedAt: string
}

Station

{
  id: string,
  name: string,
  lat: number,
  lng: number,
  nucleus: string | null,
  municipality: string,
  province: string,
  hasCercanias: boolean,
  hasLd: boolean
}

Alert

{
  id: string,
  routes: string[],
  stops: string[],
  description: string,
  startTime: string,
  active: boolean
}