A small package to get data from OpenStreetMap API directly
This package get Node, Way, and Relation geometry data directly from OSM API(instead of Nominatim API) by provided OSM object ID, and parse it into Shapely objects. due to heavy dependencies of GeoPandas, GeoDataFrame export excluded. but you can easily convert Shapely to GeoPandas, here is an example:
def get_relation_as_gdf(osm_id: str) -> geopandas.GeoDataFrame:
polygon = osm_api.get_relation(osm_id)
data = {'geometry': [polygon]}
gdf = geopandas.GeoDataFrame(data)
return gdf
import osm_api
polygon = osm_api.get_relation(osm_id='537701')
line_string = osm_api.get_way(osm_id='440582504')
lat_lng = osm_api.get_node(osm_id='25960293')