WordPress’s REST API should provide the information you need.
If you’re after a post with the slug the-slug-you-want
, then you can request the data about any post(s) with that slug using the URL https://example.com/wp-json/v2/posts/?slug=the-slug-you-want
. This returns the post(s) with that slug, and in the post’s/posts’ JSON objects the ID is available.