Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 994
4m1r Avatar asked Mar 11 '15 17:03

4m1r


People also ask

How do you find the endpoints of API?

Through the dataset URL: You can get the API endpoint by simply taking the dataset's UID and replacing it in this string: https://domain/resource/UID.extension *where the extension is the data format you's like to pull the data as.

How do I get all API endpoints in spring boot?

Mapping Endpoints In a Spring Boot application, we expose a REST API endpoint by using the @RequestMapping annotation in the controller class. For getting these endpoints, there are three options: an event listener, Spring Boot Actuator, or the Swagger library.

CAN REST API have multiple endpoints?

Often, each REST API offers multiple endpoints from which you can get the data.


2 Answers

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:

  • Swagger
  • And people also like API Blueprint.
like image 66
Gergely Bacso Avatar answered Sep 21 '22 15:09

Gergely Bacso


Some RESTful APIs publish a Web Application Description Language resource (WADL - pronounced like the walk that ducks do - for short). JAX-RS, or at least Jersy webapps will do this by default at the application root URL /application.wadl. It doesn't appear that Twitter's API is one of these. Many REST purists would argue that the API should be self describing and self discoverable simply by interacting with it and seeing what other endpoints it will give you.

More about WADL from wikipedia...

like image 31
David Avatar answered Sep 23 '22 15:09

David