Questions tagged [restful-url]

Representational state transfer (REST) is a style of software architecture for distributed hypermedia systems such as the World Wide Web.

https://en.wikipedia.org/wiki/Representational_state_transfer

1351 questions
724
votes
9 answers

Hyphen, underscore, or camelCase as word delimiter in URIs?

I'm designing an HTTP-based API for an intranet app. I realize it's a pretty small concern in the grand scheme of things, but: should I use hyphens, underscores, or camelCase to delimit words in the URIs? Here are my initial…
Josh Johnson
  • 8,832
  • 4
  • 25
  • 31
466
votes
8 answers

When do I use path params vs. query params in a RESTful API?

I want to make my RESTful API very predictable. What is the best practice for deciding when to make a segmentation of data using the URI rather than by using query params. It makes sense to me that system parameters that support pagination, sorting,…
cosbor11
  • 14,709
  • 10
  • 54
  • 69
299
votes
9 answers

How to create REST URLs without verbs?

I'm struggling to determine how to design restful URLs. I'm all for the restful approach of using URLs with nouns and not verbs don't understand how to do this. We are creating a service to implement a financial calculator. The calculator takes a…
Marcus Leon
  • 55,199
  • 118
  • 297
  • 429
192
votes
15 answers

What’s the best RESTful method to return total number of items in an object?

I'm developing a REST API service for a large social networking website I'm involved in. So far, it's working great. I can issue GET, POST, PUT and DELETE requests to object URLs and affect my data. However, this data is paged (limited to 30 results…
Martin Bean
  • 38,379
  • 25
  • 128
  • 201
152
votes
7 answers

RESTfully design /login or /register resources?

I was designing a web app and then stopped to think about how my api should be designed as a RESTful web service. For now, most of my URI's are generic and might apply to various web apps: GET /logout // destroys session and redirects to / GET …
Qcom
  • 18,263
  • 29
  • 87
  • 113
152
votes
3 answers

RESTful - What should a DELETE response body contain

Let's say I have an API where you can get users: GET /RESTAPI/user/ And you can delete users by: DELETE /RESTAPI/user/123 What is the RESTful convention on what the DELETE's response body should contain? I expected it should be the new list of all…
tmuecksch
  • 6,222
  • 6
  • 40
  • 61
89
votes
5 answers

How to access the services from RESTful API in my angularjs page?

I am very new to angularJS. I am searching for accessing services from RESTful API, but I didn't get any idea. How can I do that?
anilCSE
  • 2,461
  • 3
  • 23
  • 29
89
votes
6 answers

Passing array in GET for a REST call

I have a url to fetch appointments for a user like this: /user/:userId/appointments How should the url look like if I want to get appointments for multiple users? should it be: /appointments?users=1d1,1d2.. Thanks, Chris.
ChrisOdney
  • 6,066
  • 10
  • 38
  • 48
73
votes
7 answers

What is the difference between @PathParam and @PathVariable

To my knowledge both serves the same purpose. Except the fact that @PathVariable is from Spring MVC and @PathParam is from JAX-RS. Any insights on this?
suresh
  • 943
  • 2
  • 8
  • 22
69
votes
6 answers

How to add method description in Swagger UI in WebAPI Application

I am using Swagger as my API tooling framework and it is working out great so far. I just came across this page https://petstore.swagger.io/ and saw how each method has a description. For example, POST: pet/ is described by add a new Pet to the…
Lost
  • 12,007
  • 32
  • 121
  • 193
49
votes
2 answers

RESTful URI trailing slash or no trailing slash

Is there an authoritative position I can cite when it comes to a trailing slash on a Restful URI? One from Roy Fielding would be great. The web has authoritative opinions both ways. The two positions are: The trailing slash indicates a resource…
Stephen
  • 868
  • 1
  • 9
  • 18
48
votes
4 answers

Confusion Between Noun vs. Verb in Rest URLs

I have studied over the internet about restful APIs that it focuses on nouns not verbs in the url pattern, but now I am seeing multiple links that use verbs in the URL. Here is an example. POST…
Syed Uzair Uddin
  • 3,296
  • 7
  • 31
  • 47
46
votes
4 answers

Proper route for checking resource existence in a RESTful API

What's the best/restful way to design an API endpoint for checking existence of resources? For example there is a user database. While new user tries to sign up I want to check if email has been used on-the-fly. My idea is: POST /user/exists and…
x1a0
  • 9,984
  • 5
  • 22
  • 30
40
votes
7 answers

RESTful POSTS, do you POST objects to the singular or plural Uri?

Which one of these URIs would be more 'fit' for receiving POSTs (adding product(s))? Are there any best practices available or is it just personal preference? /product/ (singular) or /products/ (plural) Currently we use /products/?query=blah…
Arron S
  • 5,511
  • 7
  • 50
  • 57
39
votes
6 answers

Spring MVC Controller: Redirect without parameters being added to my url

I'm trying to redirect without parameters being added to my URL. @Controller ... public class SomeController { ... @RequestMapping("save/") public String doSave(...) { ... return "redirect:/success/"; } …
user871611
  • 3,307
  • 7
  • 51
  • 73
1
2 3
90 91