Is there a way to discover all endpoints of a ReST API?

4m1r picture 4m1r · Mar 11, 2015 · Viewed 73.1k times · Source

I'm wondering if its possible to programmatically discover all the endpoints of a particular API.

So for example if I GET this URL with a browser or curl: https://api.twitter.com/1.1/

I might get something like this as a JSON response:

{"TwitterAPI":{
    "version" : 1.1,
    "GET" : {
        "search/" : ["users", "trending"],
        "users/" : ["id", "handle"]
    }
}

Of course Twitter could choose to publish or not publish this format. So as a side question, are there any libraries for Java or Javascript that will automatically map and publish the API routes you created in your controllers?

Answer

Gergely Bacso picture Gergely Bacso · Mar 11, 2015

There is no way of programmatically discovering REST services as they do not have a standard registry service.

Apart from doing something insane brute-force search there is no way of finding the right URLs ( not to mention the right parameters). So the only option is documenting your API. For that the best choice I have seen so far is: