Overpass API bus station id to GTFS id

Hi! How to convert ID bus station from overpass API to id GTFS?
This is my request:

node
  [highway=bus_stop]
  ({{bbox}});
out;

This is respone:

  <node id="367890809" lat="59.8747355" lon="30.3895274">
    <tag k="bench" v="yes"/>
    <tag k="bin" v="yes"/>
    <tag k="bus" v="yes"/>
    <tag k="highway" v="bus_stop"/>
    <tag k="lit" v="yes"/>
    <tag k="name" v="Пражская улица"/>
    <tag k="public_transport" v="platform"/>
    <tag k="shelter" v="yes"/>
    <tag k="tactile_paving" v="no"/>
    <tag k="trolleybus" v="yes"/>
  </node>

I need to converte id from this to id GTFS

PTNA provides a set of GTFS feeds and analyses OSM data w.r.t. GTFS and vice versa

The response is XML data and you have to parse that using your $PROGRAMMING_LANGUAGE

But you can use the following:

[out:json];
nwr
  [highway=bus_stop]
  ({{bbox}});
out;

It will

  • output JSON formatted data which can be read more easily by Python, …
  • it will also include Ways and Relations
    • although highway=bus_stop is defined for Nodes only
    • I’ve seen a lot of platforms as ways, areas and relations having highway=bus_stop attached to it

In general, it is not recommended to use the ‘id’ of an OSM object for further processing - permanent storage. The ‘id’ may and will change over time (delete, create new object).

However, since the GTFS feed data (*.zip) is a snapshot and has to be consistent only inside the *.zip (not over time in various GTFS feeds), you may use this approach.

You then can add the following to “stops.txt” (GTFS file)

  • ‘id’ as ‘stop_id’
  • ‘lat’ as ‘stop_lat’
  • ‘lon’ as ‘stop_lon’
  • ‘name’ as ‘stop_name’
  • set ‘localtion_type’ to 0

Hello! This doesn’t answer my question, unfortunately.
I mean that the id from the overpass api is not comparable to the id in GTFS,
and the geolocation and name of the stop may differ. i need to get GTFS id of station? not id in overpass api. I will then use this id in another api? and neet only GTFS ID

there are similar gtfs:stop_id keys, but they don’t work or I’m not using them correctly

OK, misunderstanding on my side.

There’s a description of GTFS tagging in OSM.

Your example does not show any “gtfs:*” tags in OSM. Without gtfs:stop_id or ref:IFOPT or … attached to the highway=bus_stop Node/Way/Relation… there is no way to derive the GTFS id from OSM.

In addition to “gtfs:stop_id” you must also add the name of the GTFS feed as describe in the Wiki.
This can be done

  • by “gtfs:stop:id:feedname”
    • preferred version
    • instead of the simple “gtfs:stop_id”
    • replace “feedname” by the name of the feed data (e.g. “DE-BY-MVV” or “NL-OVApi”
  • or by adding “gtfs:feed=feedname”

Could you send me a complete request, otherwise I always get an empty list

First, the “gtfs:stop_id” has to be added to OSM objects, then you can search for it:

My approach would be:

[out:json];
nwr
  [~'^gtfs:stop_id'~'.']
  ({{bbox}});
(._;>;);
out;

This will show all nodes/ways/relations where there is a non-empty tag which starts with “gtfs:stop_id”, it will also find “gtfs:stop_id:xyz”.

But: it will not find all stops which do not have the tags. The result will definitely only be a subset of all stops in the area.

Oh, this is something wrong, since this request does not return stops

[out:json];
nwr
  ["gtfs:stop_id"]
  ({{bbox}});
out;
{
  "version": 0.6,
  "generator": "Overpass API 0.7.62.1 084b4234",
  "osm3s": {
    "timestamp_osm_base": "2024-07-02T10:35:52Z",
    "copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL."
  },
  "elements": [



  ]
}

it is honover

Then there is no OSM data (nodes) in your area at all with “gtfs:stop_id”

This would be the correct one!

[out:json];
nwr
  [~'^gtfs:stop_id'~'.']
  ({{bbox}});
(._;>;);
out;

See this here in the south-east of Munich, Germany - opens automatically

I’m probably looking in the wrong place.

If it is not possible to convert id`s, then is it easier to make a service for finding locations by bbox from stops.txt gtfs?

can be used only with the Overpass-Turbo of course, searching in the visible area on the right.