How to maintain cohesion in my REST API?

1

I have two features of a REST API Specialists and Services. A specialist can perform various services.

I needed to list all services that have at least one partner specialist.

get services /? criteria get experts /? criteria

How could I make this request without leaving the api very confused and maintaining cohesion?

    
asked by anonymous 05.05.2018 / 02:05

1 answer

0

Based on some documentation (even from Microsoft's WebAPI), we have a "REST standard" to keep the API organized and "beautiful."

Your domain api/servicos

GET List = > api/servicos

GET Single = > api/servicos/{ID} or api/servicos?id={ID}

POST Create = > api/servicos

PUT Update = > api/servicos/{ID} or api/servicos?id={ID}

DELETE Delete = > api/servicos/{ID} or api/servicos?id={ID}

This is the basics that the documentation shows, so we have a standard to keep the API more cohesive.

In your case, to keep the API cohesive and self-explanatory, nothing better than simple (KIS - Keep It Simple)

then we would have: GET Listar = > api/servicos/com-especialista .

I believe that anyone who accesses your API documentation, by looking at the URL name, will have a good idea of what it will return in response.

I recommend taking a look at Swagger , it will help you a lot to document your API, and save you a lot of time, hehehe.

link

    
05.05.2018 / 04:56