Check out the journal article about OSMnx.

OSMnx can now download street network elevation data for anywhere in the world. In one line of code it downloads the elevation in meters of each network node, and in one more line of code it can calculate every street (i.e., edge) grade. Here is the complete street network of San Francisco, California, with nodes colored according to their elevation:

Here we find that the average street grade in San Francisco is 4.0% and the median street grade is 2.6%. OSMnx uses the Google Maps Elevation API to determine the elevation of each node in the network, given their latitude-longitude coordinates. For full details and demonstration, check out this notebook in the OSMnx GitHub repo or read the documentation.