Get a remote post ID via API given URL

The Posts endpoint accepts a slug parameter when querying for posts, so if you can get the slug from the URL, then you can make request to /wp-json/wp/v2/posts?slug=<slug>.

So if the URL is http://example.com/hello-world/ and you know the slug is hello-world, then for example in JavaScript, you can do something like:

fetch( 'http://example.com/wp-json/wp/v2/posts?slug=hello-world' )
    .then( res => res.json() )
    .then( posts => console.log( posts[0].id ) );

Or you could create a custom endpoint.. if you’ve got control over the WordPress site. See this for more details.