Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3641

RESTFUL API: Using path parameters vs query parameters

$
0
0

First, I do know path parameters need to be used when you are pointing at a resource and query parameters are meant to be used when you define something that can add a "property" (or change in time).

However, let's assume I need to get data belong to a user.

In this case, I am a fan of writing the REST API URL like this.

https://mylink/user/getbyid

And not

https://mylink/user/get

In the way I write the REST API, I will call the URL like /user/getbyid?id=1. In the way, I do not write the API, you will call it /user/get/1.

Since I write my API calls like /user/getbyid, /user/getbyname, /user/getbyuid I rarely use path parameters. 99% of the time I am using query parameters.

Considering the way I write my API calls, am I going against the best practices? Or is what I do right or ignorable?


Viewing all articles
Browse latest Browse all 3641

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>