### Start Development Server Source: https://context7.com/openrailwaymap/openrailwaymap-api/llms.txt Run the API server locally for development using `api.py serve`. Dependencies like `python3-werkzeug` and `python3-psycopg2` must be installed. The `--cors` flag enables cross-origin requests, and `--port` customizes the listening port. ```bash # Install dependencies apt install python3-werkzeug python3-psycopg2 ``` ```bash # Start the development server on the default port (5000) python3 api.py serve ``` ```bash # Start with CORS enabled for all origins on a custom port python3 api.py --cors "*" --port 8080 ``` ```bash # Test that the server is responding curl "http://127.0.0.1:5000/facility?name=Berlin&limit=3" ``` -------------------------------- ### Install WSGI for Production Deployment Source: https://github.com/openrailwaymap/openrailwaymap-api/blob/master/README.md Installs Apache WSGI module for deploying the API on a production server. ```shell apt install apache2 libapache2-mod-wsgi-py3 ``` -------------------------------- ### Database Setup for Facilities Source: https://context7.com/openrailwaymap/openrailwaymap-api/llms.txt The `prepare_facilities.sql` script sets up the necessary PostgreSQL materialized views and functions for the `/facility` endpoint. It requires the `unaccent` extension and defines functions for text normalization and ranking. ```bash # The `prepare_facilities.sql` script creates the PostgreSQL materialized views and supporting functions required by the `/facility` endpoint. It installs the `unaccent` extension, defines the `openrailwaymap_hyphen_to_space` function (normalizes intra-word hyphens to spaces for full-text matching), builds the `openrailwaymap_ref` view (for ref/uic_ref lookups with BTREE indexes), and builds the `openrailwaymap_facilities_for_search` view (full-text GIN-indexed view with route-count ranking via `openrailwaymap_name_rank`). ``` -------------------------------- ### Install Test Dependencies Source: https://context7.com/openrailwaymap/openrailwaymap-api/llms.txt Installs the necessary Python packages for running the API integration tests. Ensure you have Python 3 and pip installed. ```bash pip install requests termcolor pyyaml ``` -------------------------------- ### Production Deployment (WSGI) Source: https://context7.com/openrailwaymap/openrailwaymap-api/llms.txt Instructions for deploying the API as a WSGI application, typically with Apache and `mod_wsgi`. The WSGI callable is `api.application`. Ensure necessary packages like `apache2` and `libapache2-mod-wsgi-py3` are installed. ```bash # For production, deploy as a WSGI application (e.g., Apache mod_wsgi): # The WSGI callable is: api.application apt install apache2 libapache2-mod-wsgi-py3 ``` ```apache # Apache VirtualHost snippet: # WSGIScriptAlias / /path/to/api.py # WSGIDaemonProcess openrailwaymap python-path=/path/to ``` -------------------------------- ### Install API Dependencies (Debian/Ubuntu) Source: https://github.com/openrailwaymap/openrailwaymap-api/blob/master/README.md Installs necessary Python packages for the API using apt. Ensure Python 3, Werkzeug, and Psycopg2 are available. ```shell apt install python3-werkzeug python3-psycopg2 ``` -------------------------------- ### Verify Database Views Source: https://context7.com/openrailwaymap/openrailwaymap-api/llms.txt Command to list all materialized views and views in the 'gis' database, useful for verifying that the setup scripts have run correctly. ```bash sudo -u osmimport psql -d gis -c "\dv openrailwaymap_*" ``` -------------------------------- ### Milestone API Response Example Source: https://github.com/openrailwaymap/openrailwaymap-api/blob/master/README.md Example JSON response for the milestone endpoint, detailing the properties of found railway features. ```json [ { "osm_id": 3479484133, "railway": "milestone", "position": 18.405, "longitude": 8.7064769, "latitude": 49.0315238996845, "ref": "4201", "operator": "Albtal-Verkehrs-Gesellschaft mbH" }, { "osm_id": 3479484134, "railway": "milestone", "position": 18.2, "longitude": 8.7045853, "latitude": 49.0327703996842, "ref": "4201", "operator": "Albtal-Verkehrs-Gesellschaft mbH" } ] ``` -------------------------------- ### Facility Search Example Source: https://github.com/openrailwaymap/openrailwaymap-api/blob/master/README.md Demonstrates how to search for facilities by name. The API returns detailed information about the facility, including its OSM ID, name, railway type, and various OSM tags. The limit parameter controls the number of results. ```http GET https://api.openrailwaymap.org/v2/facility?name=Karlsruhe&limit=1 ``` ```json [ { "osm_id": 2574283615, "name": "Karlsruhe Hauptbahnhof", "railway": "station", "ref": null, "iata": "KJR", "uic_ref": "8000191", "website": "https://www.bahnhof.de/bahnhof-de/bahnhof/Karlsruhe-Hbf-1019530", "operator": "DB Station&Service AG", "wikidata": "Q688541", "iata:note": "AIRail Flughafen", "max_level": "1", "min_level": "-1", "platforms": "7", "ref:IFOPT": "de:08212:90", "wikipedia": "de:Karlsruhe Hauptbahnhof", "short_name": "Karlsruhe Hbf", "wheelchair": "yes", "railway:ref": "RK", "ref:station": "3107", "internet_access": "wlan", "public_transport": "station", "internet_access:fee": "no", "internet_access:ssid": "Telekom", "internet_access:operator": "Deutsche Telekom AG", "railway:station_category": "1", "internet_access:fee:description": "30min kostenlos", "longitude": 8.4020518, "latitude": 48.9936163996939, "rank": 176 } ] ``` -------------------------------- ### Milestone Search Error Handling Source: https://context7.com/openrailwaymap/openrailwaymap-api/llms.txt Examples demonstrating error responses for missing required parameters or invalid input for the `/milestone` endpoint. These typically result in an HTTP 400 Bad Request. ```bash # Error — missing required parameters (HTTP 400) curl "https://api.openrailwaymap.org/v2/milestone?ref=4201" ``` ```bash # Error — non-numeric position (HTTP 400) curl "https://api.openrailwaymap.org/v2/milestone?ref=4201&position=abc" ``` -------------------------------- ### Create Database Views for Facilities Source: https://github.com/openrailwaymap/openrailwaymap-api/blob/master/README.md Creates necessary database views for handling railway facilities. Run as the 'osmimport' user. ```shell sudo -u osmimport psql -d gis -f prepare_facilities.sql ``` -------------------------------- ### Prepare and Update Facilities Database Views Source: https://context7.com/openrailwaymap/openrailwaymap-api/llms.txt Run these SQL scripts to prepare and refresh materialized views for the /facility endpoint. The prepare script should be run once after importing OSM data, and the update script should be run after applying OSM diff updates. ```bash sudo -u osmimport psql -d gis -f prepare_facilities.sql ``` ```bash sudo -u osmimport psql -d gis -f update_facilities.sql ``` -------------------------------- ### Create Database Views for Milestones Source: https://github.com/openrailwaymap/openrailwaymap-api/blob/master/README.md Creates necessary database views for handling railway milestones. Run as the 'osmimport' user. ```shell sudo -u osmimport psql -d gis -f prepare_milestone.sql ``` -------------------------------- ### Prepare and Update Milestone Database Views Source: https://context7.com/openrailwaymap/openrailwaymap-api/llms.txt Scripts to set up and refresh materialized views for the /milestone endpoint. Run prepare_milestones.sql once after importing OSM data, and update_milestones.sql after OSM updates. ```bash sudo -u osmimport psql -d gis -f prepare_milestones.sql ``` ```bash sudo -u osmimport psql -d gis -f update_milestones.sql ``` -------------------------------- ### Grant Database Read Permissions Source: https://github.com/openrailwaymap/openrailwaymap-api/blob/master/README.md Creates a database user and grants it SELECT permissions on public schema tables. Replace $USERNAME with the actual username. ```shell createuser $USERNAME sudo -u postgres psql -d gis -c "GRANT SELECT ON TABLES IN SCHEMA PUBLIC TO $USERNAME;" ``` -------------------------------- ### Run API Integration Tests Source: https://context7.com/openrailwaymap/openrailwaymap-api/llms.txt Execute the integration tests using the provided Python script. Tests can be run against a local development server or a remote API instance by specifying the API URL. ```bash python3 tests/tests.py -t tests/testcases.yml ``` ```bash python3 tests/tests.py -t tests/testcases.yml -a https://api.openrailwaymap.org/v2 ``` -------------------------------- ### General Facility Search with `q` Parameter Source: https://context7.com/openrailwaymap/openrailwaymap-api/llms.txt The `q` parameter allows for a comprehensive search across facility names, `railway:ref`, and `uic_ref`. It merges and deduplicates results by `osm_id`. Accented characters are handled transparently. ```bash # Search across name, ref, and uic_ref at once curl "https://api.openrailwaymap.org/v2/facility?q=Walheim&limit=10" ``` ```bash # Accented characters are normalized — ü/oe etc. handled transparently curl "https://api.openrailwaymap.org/v2/facility?q=Munchen" ``` ```bash curl "https://api.openrailwaymap.org/v2/facility?q=M%C3%BCnchen" ``` -------------------------------- ### Search Railway Facilities by Name Source: https://context7.com/openrailwaymap/openrailwaymap-api/llms.txt Use the 'name' parameter to search for railway facilities. Results are limited to 20 by default. Hyphens and spaces in names are treated as equivalent. An error is returned if no search argument is provided or if the limit is too high. ```bash curl "https://api.openrailwaymap.org/v2/facility?name=Karlsruhe&limit=1" ``` ```json # Expected response: # [ # { # "osm_id": 2574283615, # "name": "Karlsruhe Hauptbahnhof", # "railway": "station", # "ref": null, # "iata": "KJR", # "uic_ref": "8000191", # "website": "https://www.bahnhof.de/bahnhof-de/bahnhof/Karlsruhe-Hbf-1019530", # "operator": "DB Station&Service AG", # "wikidata": "Q688541", # "short_name": "Karlsruhe Hbf", # "wheelchair": "yes", # "railway:ref": "RK", # "ref:station": "3107", # "public_transport": "station", # "longitude": 8.4020518, # "latitude": 48.9936163996939, # "rank": 176 # } # ] ``` ```bash # Hyphen and space are treated as equivalent curl "https://api.openrailwaymap.org/v2/facility?name=Karlsruhe-Hagsfeld" curl "https://api.openrailwaymap.org/v2/facility?name=Karlsruhe%20Hagsfeld" ``` ```json # Both return: [{"name": "Karlsruhe-Hagsfeld", ...}] ``` ```bash # Search multiple facilities in Berlin with limit curl "https://api.openrailwaymap.org/v2/facility?name=Berlin&limit=5" ``` ```bash # Error — no search argument provided (HTTP 400) curl "https://api.openrailwaymap.org/v2/facility" ``` ```json # {"type": "no_query_arg", "error": "No argument with a search term provided.", # "detail": "Provide one of the following arguments: q, name, ref, uic_ref"} ``` ```bash # Error — limit too high (HTTP 400) curl "https://api.openrailwaymap.org/v2/facility?name=Berlin&limit=500" ``` ```json # {"type": "limit_too_high", "error": "Invalid paramter value provided for parameter \"limit\".", # "detail": "Limit is too high. Please set up your own instance to query everything."} ``` -------------------------------- ### Search Railway Facilities by Reference Code Source: https://context7.com/openrailwaymap/openrailwaymap-api/llms.txt Use the 'ref' parameter to search by operator-assigned infrastructure reference number. Only one search argument (q, name, ref, or uic_ref) can be provided per request. ```bash # Search by railway operator reference code curl "https://api.openrailwaymap.org/v2/facility?ref=RK" ``` ```json # Expected response: # [ # { # "osm_id": 2574283615, # "name": "Karlsruhe Hauptbahnhof", # "railway": "station", # "railway:ref": "RK", # "longitude": 8.4020518, # "latitude": 48.9936163996939 # } # ] ``` ```bash # Error — multiple search arguments (HTTP 400) curl "https://api.openrailwaymap.org/v2/facility?name=Berlin&ref=RK" ``` ```json # {"type": "multiple_query_args", "error": "More than one argument with a search term provided.", # "detail": "Provide only one of the following arguments: q, name, ref, uic_ref"} ``` -------------------------------- ### Update Database Views for Facilities Source: https://github.com/openrailwaymap/openrailwaymap-api/blob/master/README.md Refreshes materialized views for facilities after applying OSM diff updates. Run as the 'osmimport' user. ```shell sudo -u osmimport psql -d gis -f update_facilities.sql ``` -------------------------------- ### Search Facility by UIC Reference Source: https://context7.com/openrailwaymap/openrailwaymap-api/llms.txt Use the `uic_ref` parameter to find a specific railway facility. This is useful for precise lookups when the UIC reference number is known. ```bash curl "https://api.openrailwaymap.org/v2/facility?uic_ref=8000191" ``` -------------------------------- ### Update Database Views for Milestones Source: https://github.com/openrailwaymap/openrailwaymap-api/blob/master/README.md Refreshes materialized views for milestones after applying OSM diff updates. Run as the 'osmimport' user. ```shell sudo -u osmimport psql -d gis -f update_milestone.sql ``` -------------------------------- ### General Facility Search Source: https://context7.com/openrailwaymap/openrailwaymap-api/llms.txt Performs a combined search across name, railway:ref, and uic_ref. Results are deduplicated by osm_id. ```APIDOC ## GET /facility?q={query}&limit={limit} ### Description Performs a comprehensive search across name, `railway:ref`, and `uic_ref` simultaneously. Results are merged and deduplicated by `osm_id` before applying the limit. ### Method GET ### Endpoint /v2/facility ### Parameters #### Query Parameters - **q** (string) - Required - The search query string. Accented characters are normalized. - **limit** (integer) - Optional - The maximum number of results to return. ### Response #### Success Response (200) Returns a list of facility objects matching the query. ### Response Example ```json [ { "osm_id": ..., "name": "Walheim (Württemberg)", "railway": "station", "longitude": ..., "latitude": ..., "rank": ... } ] ``` ``` -------------------------------- ### Search Railway Facilities by UIC Reference Source: https://context7.com/openrailwaymap/openrailwaymap-api/llms.txt Use the 'uic_ref' parameter to search for facilities using the international UIC station reference number. This is useful for integration with European train booking systems. ```bash # Search by UIC Reference curl "https://api.openrailwaymap.org/v2/facility?uic_ref=8000191" ``` -------------------------------- ### Grant Read Access to API User Source: https://context7.com/openrailwaymap/openrailwaymap-api/llms.txt Grant SELECT privileges on all tables in the public schema to the API user (e.g., www-data). This ensures the API can read necessary data from the database. ```bash createuser www-data ``` ```bash sudo -u postgres psql -d gis -c "GRANT SELECT ON ALL TABLES IN SCHEMA PUBLIC TO \"www-data\";" ``` -------------------------------- ### Search by Railway Reference (`ref`) Source: https://context7.com/openrailwaymap/openrailwaymap-api/llms.txt Searches for railway facilities using the operator-assigned infrastructure reference number via the `ref` parameter. Only one search argument (`q`, `name`, `ref`, or `uic_ref`) can be provided per request. ```APIDOC ## GET /facility — Search by Railway Reference (`ref`) ### Description Searches for facilities by the operator-assigned infrastructure reference number using the `ref` parameter. This queries the `openrailwaymap_ref` materialized view. ### Method GET ### Endpoint /v2/facility ### Parameters #### Query Parameters - **ref** (string) - Required - The operator-assigned reference number to search for. ### Request Example ```bash curl "https://api.openrailwaymap.org/v2/facility?ref=RK" ``` ### Response #### Success Response (200) - **osm_id** (integer) - OSM ID of the facility. - **name** (string) - Name of the facility. - **railway** (string) - Type of railway facility. - **railway:ref** (string) - The operator-assigned reference number. - **longitude** (float) - Longitude coordinate. - **latitude** (float) - Latitude coordinate. #### Response Example ```json [ { "osm_id": 2574283615, "name": "Karlsruhe Hauptbahnhof", "railway": "station", "railway:ref": "RK", "longitude": 8.4020518, "latitude": 48.9936163996939 } ] ``` ### Error Handling - **400 Bad Request**: If more than one search argument is provided (e.g., `name` and `ref`). ``` -------------------------------- ### Search Railway Milestones by Line and Position Source: https://context7.com/openrailwaymap/openrailwaymap-api/llms.txt The `/milestone` endpoint finds railway position markers near a given kilometre position on a specified line. Both `ref` and `position` are mandatory. Results are clustered and ranked by proximity. ```bash # Lookup milestones near km 18.4 on line 4201 curl "https://api.openrailwaymap.org/v2/milestone?ref=4201&position=18.4" ``` ```bash # Lookup with a custom result limit curl "https://api.openrailwaymap.org/v2/milestone?ref=2160&position=9.4&limit=1" ``` ```bash # Negative mileage is supported curl "https://api.openrailwaymap.org/v2/milestone?ref=1234&position=-3.5" ``` -------------------------------- ### Facility Search Source: https://github.com/openrailwaymap/openrailwaymap-api/blob/master/README.md Search for railway facilities (stations, halts, junctions, yards, etc.) by name, UIC reference, or official reference. Supports full-text search and optional limit on results. ```APIDOC ## GET /facility ### Description Retrieves details of a railway facility based on provided search parameters. The request must include exactly one of `q`, `name`, `ref`, or `uic_ref`. ### Method GET ### Endpoint `/facility` ### Parameters #### Query Parameters - **q** (string) - Required - Search term (searches `name`, `railway:ref`, and `uic_ref` tags). - **name** (string) - Required - Search term (searches `name` tags only). - **ref** (string) - Required - Search by official facility reference number/code. - **uic_ref** (string) - Required - Search by UIC reference number (uses OSM tag `uic_ref=*`). - **limit** (integer) - Optional - Maximum number of results. Defaults to 20, must not exceed 200. ### Request Example ```http GET https://api.openrailwaymap.org/v2/facility?name=Karlsruhe&limit=1 ``` ### Response #### Success Response (200) Returns a JSON array of facility objects. Each object contains: - **latitude** (number) - Latitude of the facility. - **longitude** (number) - Longitude of the facility. - **osm_id** (integer) - OSM node ID of the facility. - **rank** (integer) - Importance rank of the facility. - All other OSM tags associated with the facility object (e.g., `name`, `railway`, `operator`, `uic_ref`). #### Response Example ```json [ { "osm_id": 2574283615, "name": "Karlsruhe Hauptbahnhof", "railway": "station", "ref": null, "iata": "KJR", "uic_ref": "8000191", "website": "https://www.bahnhof.de/bahnhof-de/bahnhof/Karlsruhe-Hbf-1019530", "operator": "DB Station&Service AG", "wikidata": "Q688541", "iata:note": "AIRail Flughafen", "max_level": "1", "min_level": "-1", "platforms": "7", "ref:IFOPT": "de:08212:90", "wikipedia": "de:Karlsruhe Hauptbahnhof", "short_name": "Karlsruhe Hbf", "wheelchair": "yes", "railway:ref": "RK", "ref:station": "3107", "internet_access": "wlan", "public_transport": "station", "internet_access:fee": "no", "internet_access:ssid": "Telekom", "internet_access:operator": "Deutsche Telekom AG", "railway:station_category": "1", "internet_access:fee:description": "30min kostenlos", "longitude": 8.4020518, "latitude": 48.9936163996939, "rank": 176 } ] ``` ``` -------------------------------- ### Search by UIC Reference (`uic_ref`) Source: https://context7.com/openrailwaymap/openrailwaymap-api/llms.txt Searches for facilities using the international UIC station reference number. This is useful for integration with European train booking systems or timetable data. ```APIDOC ## GET /facility — Search by UIC Reference (`uic_ref`) ### Description Searches for facilities using the international UIC station reference number, sourced from the OSM tag `uic_ref=*`. This queries the `openrailwaymap_ref` view. ### Method GET ### Endpoint /v2/facility ### Parameters #### Query Parameters - **uic_ref** (string) - Required - The UIC station reference number to search for. ### Request Example ```bash curl "https://api.openrailwaymap.org/v2/facility?uic_ref=8000191" ``` ### Response #### Success Response (200) - **osm_id** (integer) - OSM ID of the facility. - **name** (string) - Name of the facility. - **railway** (string) - Type of railway facility. - **uic_ref** (string) - The UIC reference number. - **longitude** (float) - Longitude coordinate. - **latitude** (float) - Latitude coordinate. #### Response Example ```json [ { "osm_id": 2574283615, "name": "Karlsruhe Hauptbahnhof", "railway": "station", "uic_ref": "8000191", "longitude": 8.4020518, "latitude": 48.9936163996939 } ] ``` ### Error Handling - **400 Bad Request**: If more than one search argument is provided (e.g., `name` and `uic_ref`). ``` -------------------------------- ### Search Railway Facilities by Name Source: https://context7.com/openrailwaymap/openrailwaymap-api/llms.txt Performs a full-text name search against railway operating sites. Results are ranked by an importance score. Supports searching by name, and allows specifying a limit for the number of results. ```APIDOC ## GET /facility — Search Railway Facilities by Name ### Description Performs a full-text name search against all railway operating sites (stations, halts, tram stops, yards, junctions, crossovers, and disused/proposed variants). Results are ranked by an importance score. ### Method GET ### Endpoint /v2/facility ### Parameters #### Query Parameters - **name** (string) - Required - The name to search for. - **limit** (integer) - Optional - The maximum number of results to return (default is 20, max is 500). ### Request Example ```bash curl "https://api.openrailwaymap.org/v2/facility?name=Karlsruhe&limit=1" ``` ### Response #### Success Response (200) - **osm_id** (integer) - OSM ID of the facility. - **name** (string) - Name of the facility. - **railway** (string) - Type of railway facility. - **ref** (string|null) - Operator-assigned reference number. - **iata** (string|null) - IATA code. - **uic_ref** (string|null) - UIC reference number. - **website** (string|null) - Website of the facility operator. - **operator** (string|null) - Operator of the facility. - **wikidata** (string|null) - Wikidata identifier. - **short_name** (string|null) - Short name of the facility. - **wheelchair** (string|null) - Wheelchair accessibility information. - **railway:ref** (string|null) - Specific railway reference tag. - **ref:station** (string|null) - Station reference number. - **public_transport** (string|null) - Public transport classification. - **longitude** (float) - Longitude coordinate. - **latitude** (float) - Latitude coordinate. - **rank** (integer) - Importance rank of the facility. #### Response Example ```json [ { "osm_id": 2574283615, "name": "Karlsruhe Hauptbahnhof", "railway": "station", "ref": null, "iata": "KJR", "uic_ref": "8000191", "website": "https://www.bahnhof.de/bahnhof-de/bahnhof/Karlsruhe-Hbf-1019530", "operator": "DB Station&Service AG", "wikidata": "Q688541", "short_name": "Karlsruhe Hbf", "wheelchair": "yes", "railway:ref": "RK", "ref:station": "3107", "public_transport": "station", "longitude": 8.4020518, "latitude": 48.9936163996939, "rank": 176 } ] ``` ### Error Handling - **400 Bad Request**: If no search argument is provided or if the limit is too high. ``` -------------------------------- ### Milestone Endpoint Source: https://github.com/openrailwaymap/openrailwaymap-api/blob/master/README.md The milestone endpoint returns the position of milestones or other items such as signals or level crossings with a mapped position on a line. The API will return features within a maximum distance of 10 km. The presence of an `operator=*` tag on the tracks is honoured to distinguish reference numbers. Mileage is read from OSM tags `railway:position=*` and `railway:position:exact=*`. Tracks must be tagged with a reference number (OSM tag `ref=*`) and not tagged with `service=*` (unless `usage=industrial/military/test`). Negative mileage is supported, but gaps or duplicated positions are not. ```APIDOC ## GET /milestone ### Description Retrieves the position of milestones, signals, or level crossings along a railway line. ### Method GET ### Endpoint `/milestone` ### Parameters #### Query Parameters - **ref** (string) - Required - Reference number of the railway route. - **position** (float) - Required - Position (can be negative) along the railway route. - **limit** (integer) - Optional - Maximum number of results. Defaults to 2, must not exceed 200. ### Request Example `GET https://api.openrailwaymap.org/v2/milestone?ref=4201&position=18.4` ### Response #### Success Response (200) - **osm_id** (integer) - OSM node ID. - **latitude** (float) - Latitude of the feature. - **longitude** (float) - Longitude of the feature. - **position** (float) - Mileage of the feature. - **railway** (string) - Type of the facility (e.g., `milestone`, `level_crossing`, `signal`). - **ref** (string) - Reference number of the railway line. - **operator** (string) - Operator of the infrastructure. #### Response Example ```json [ { "osm_id": 3479484133, "railway": "milestone", "position": 18.405, "longitude": 8.7064769, "latitude": 49.0315238996845, "ref": "4201", "operator": "Albtal-Verkehrs-Gesellschaft mbH" } ] ``` ``` -------------------------------- ### Query Milestone Endpoint Source: https://github.com/openrailwaymap/openrailwaymap-api/blob/master/README.md Use this endpoint to retrieve milestones, signals, or level crossings based on their position on a railway line. Requires a reference number and position. Results are limited to 10 km and a maximum of 200 items. ```http GET https://api.openrailwaymap.org/v2/milestone?ref=4201&position=18.4 ``` -------------------------------- ### Search Facility by UIC Reference Source: https://context7.com/openrailwaymap/openrailwaymap-api/llms.txt Allows searching for railway facilities using their UIC reference number. ```APIDOC ## GET /facility?uic_ref={uic_ref} ### Description Searches for railway facilities using a specific UIC reference number. ### Method GET ### Endpoint /v2/facility ### Parameters #### Query Parameters - **uic_ref** (string) - Required - The UIC reference number to search for. ### Response #### Success Response (200) Returns a list of facility objects matching the UIC reference. ### Response Example ```json [ { "osm_id": 2574283615, "name": "Karlsruhe Hauptbahnhof", "railway": "station", "uic_ref": "8000191", "longitude": 8.4020518, "latitude": 48.9936163996939 } ] ``` ``` -------------------------------- ### Search Railway Milestones Source: https://context7.com/openrailwaymap/openrailwaymap-api/llms.txt Locates milestones, signals, level crossings, and other railway position markers near a given kilometre position on a numbered line. ```APIDOC ## GET /milestone?ref={route_ref}&position={kilometre_position}&limit={limit} ### Description Searches for railway milestones, signals, and other position markers near a specific kilometre position on a given route reference. ### Method GET ### Endpoint /v2/milestone ### Parameters #### Query Parameters - **ref** (string) - Required - The route reference number. - **position** (float) - Required - The kilometre value (may be negative or decimal). - **limit** (integer) - Optional - The maximum number of results to return (defaults to 2). ### Response #### Success Response (200) Returns a list of milestone objects matching the criteria. ### Response Example ```json [ { "osm_id": 3479484133, "railway": "milestone", "position": 18.405, "longitude": 8.7064769, "latitude": 49.0315238996845, "ref": "4201", "operator": "Albtal-Verkehrs-Gesellschaft mbH" } ] ``` #### Error Response (400) - **type**: "no_query_arg" **error**: "One or multiple mandatory parameters are missing." **detail**: "You have to provide both \"ref\" and \"position\"." - **type**: "position_not_float" **error**: "Invalid value provided for parameter \"position\"." **detail**: "The provided position cannot be parsed as a float." ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.