The API allows you to get question data based on ID, so since all forms of question URLs for Stack Exchange sites have an ID in them, you can pull that value out and pass it to the /questions/{ids}
route.
Likewise, if you don't know the specific site in advance, you can pull out the hostname and pass that inpass that in dynamically.
As an example, I parse out similar information in a userscript I maintain.