Search code examples
javajavascripthttpfacebook-graph-apicurl

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


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?


Solution

  • 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: