Overpy or Overpass Turbo: How to get nodes by their IDs

overpass-apioverpass-turbo

I got relation data using Overpy, and I got a list of member node IDs and member ways IDs.
As members of a relation, they don't have all their attributes.
So as another step I want to query Overpy by the list of IDs to get those nodes/ways with all their attributes.

Using the wizard in Overpass turbo I tried:

[out:json][timeout:25];
(
  node["id"="1926700039"]({{bbox}});
);
out body;
>;
out skel qt;

But it returns nothing.

How do I query nodes and ways by lists of IDs?

Best Answer

I didn't get any answers or hints, nor could I find any examples of doing this (except in Overpass API, which has a slightly different syntax), but by trial and error I discovered the answer (which is actually very similar to the method for Overpass API).

For one node, this worked:

[out:json][timeout:25];
(
  node(1926700039)({{bbox}});
);
out body;
>;
out skel qt;

and for multiple nodes:

[out:json][timeout:25];
(
  node(id:1926700039, 6224865808, 6186983783)({{bbox}});
);
out body;
>;

It works the same for ways as well.