Questions tagged [rest]

Representational state transfer, or REST, is an architectural style for networking software to transfer information through the web.

Filter by
Sorted by
Tagged with
24
votes
6answers
3k views

What to call an HTTP API that is not RESTful? [closed]

What would you call an API that is HTTP-based, uses URI to name resources and HTTP verbs (PUT, POST, DELETE, GET...) to manipulate those resources? According to Roy Fielding's complaints it is not ...
23
votes
4answers
35k views

What is the need of Odata when I have JSON?

I am trying to understand the point of Odata and when it would make sense. Right now how I work is I use ASP.NET and MVC/WebApi controller to serialize/deserialize objects into JSON and have ...
23
votes
3answers
13k views

Recommended HTTP status code for “plan limit exceeded” response

I'm designing a REST API for a project where users are always on one of several "plans" - each plan defines some resource limits, such as the max number of users an account may have or the max number ...
23
votes
5answers
26k views

How best do you represent a bi-directional sync in a REST api?

Assuming a system where there's a Web Application with a resource, and a reference to a remote application with another similar resource, how do you represent a bi-directional sync action which ...
23
votes
2answers
9k views

Levels of user permissions in a RESTful API

Let's say I have a company that ranks the cutest cats on the internet. I offer a resource at /cats/ which provides users with the latest, cutest adorable cats. Users can either get just the top 3 ...
23
votes
5answers
2k views

Providing friendly URLs for a website vs. realities of database IDs

We have a database of resources, be they products, blog posts or something. We need to design a URL scheme to address them, for the public website. Here are two examples that are database ID bound: ...
22
votes
2answers
12k views

What is the best pattern for adding an existing item to a collection in REST API?

I'm designing a pragmatic REST API and I'm a little stuck on how best to add existing entities to a collection. My domain model includes a Project that has a collection of Sites. This is a strict many-...
21
votes
4answers
35k views

REST vs RESTful vs “normal” web service - the same or not?

I've read a couple of definitions and discussion on REST and/or RESTful applications, but I still do not understand the real meaning of it. I usually work with the apps which either fetch data via ...
21
votes
5answers
15k views

How does a REST API fit for a command/action based domain?

In this article the author claims that Sometimes, it is required to expose an operation in the API that inherently is non RESTful. and that If an API has too many actions, then that’s an ...
21
votes
2answers
31k views

The best way to implement authentication for a REST API

We develop social-based applications for mobile. Every application consumes RESTful API web-services. When I implement login I usually store the username and password somewhere on device. Then I send ...
21
votes
4answers
16k views

Is it OK to partially change a collection with PUT or DELETE?

I have a collection of products in a product group e.g.: product-groups/123/products If I need to add to the collection, is it OK that I pass only some products with PUT? If I need to delete some ...
21
votes
7answers
22k views

A Web application as a REST API client: how to handle resource identifiers

Several concepts related to REST conflict in my head when I try implementing it. I have a REST-ful back-end API system that holds the business logic, and a web application that provides the UI. From ...
21
votes
4answers
18k views

Large file / data transfer in a Microservice Architecture

My company is currently working on adopting a microservice architecture but we are encountering some growing pains (shock!) along the way. One of the key contention points we are facing is how to ...
20
votes
5answers
28k views

Pros and Cons of RESTful architecture [closed]

The most common discussion I've seen regarding the pros and cons of REST tends to frame that discussion relative to SOAP. I have no experience in either. I am currently faced with a decision which my ...
20
votes
5answers
26k views

OAuth2 ROPC vs Basic Auth for public REST APIs?

The specific use case I'm interested in here is authenticating REST clients against publicly-available server endpoints (such as a public REST API). The simplest solution here is Basic Auth. But I ...
20
votes
4answers
6k views

What is the need for 'discoverability' in a REST API when the clients are not advanced enough to make use of it anyway?

The various talks I have watched and tutorials I scanned on REST seem to stress something called 'discoverability'. To my limited understanding, the term seems to mean that a client should be able to ...
20
votes
3answers
12k views

Is it normal design to completely decouple backend and frontend web applications and allow them to communicate with (JSON) REST API?

I am creating new business web application and I want to achieve: Use the best technologies from their respective realms. I want reliable backend framework with solid ORM. And I want the most ...
20
votes
1answer
15k views

Alternatives to OAuth?

The Web industry is shifting / has shifted towards using OAuth when extending API services to external consumers & developers. There is some elegance in simple....and well, the 3-step OAuth ...
19
votes
4answers
19k views

Should HTTP status codes be used to represent business logic errors on a server?

I'm at a bit of a crossroads with some API design for a client (JS in a browser) to talk to a server. We use HTTP 409 Conflict to represent the failing of an action because of a safety lock in effect. ...
19
votes
10answers
15k views

When does SOAP make more sense than REST? [duplicate]

From my understanding of REST, the implicit assumption is that all operations are CRUD operations. Sometimes, you are not doing CRUD operations and are doing some more complex logic. In this case, is ...
19
votes
1answer
18k views

Nested REST urls and parent id, which is better design?

Okay, we have two resources: Album and Song. Here is API: GET,POST /albums GET,POST /albums/:albumId GET,POST /albums/:albumId/songs GET,POST /albums/:albumId/songs/:songId We know that we hate some ...
19
votes
3answers
2k views

Does decoupling trump DRY in REST?

I am building a REST API to expose most of functionality of an existing Java API. Both APIs are for internal use within my organization; I do not have to design for external use. I have influence ...
19
votes
3answers
4k views

Conceptual mismatch between DDD Application Services and REST API

I'm trying to design an application that has a complex business domain and a requirement to support a REST API (not strictly REST, but resource-oriented). I have some trouble coming up with a way to ...
18
votes
5answers
3k views

RESTful API represent the absence of a thing

Imagine an API to identify whether a person has selected their spirit animal. They can only have zero or one spirit animals. Currently: /person/{id}/selectedSpiritAnimal when they have selected an ...
18
votes
3answers
2k views

Why is REST commonly used instead of RPC-like mechanisms in web applications?

I started very recently at a company that uses a rather unusual custom framework for their web applications, at least compared to the typical web application frameworks I know. Instead of a RESTful ...
17
votes
6answers
2k views

REST endpoint to show a preview before POSTing

I'm designing a new web application which is powered by a REST backend and HTML+JS frontend. There's one POST method on it to change one entity (let's call Config), that has several side effects in ...
17
votes
1answer
11k views

RESTful HTTP and websocket in the same application?

If an application has already an opened WebSocket for live feeds, should I use it over AJAX for the other communications with the server? Because the connection is already opened, should we use it ...
17
votes
2answers
6k views

What is the benefit of hypermedia (HATEOAS)?

I don't understand the benefit to HATEOAS for APIs intended for use by programs (as opposed to humans directly browsing your API). Sure, the customer isn't bound to a URL schema but they are bound to ...
17
votes
1answer
24k views

Where to place an API key: a custom HTTP header VS the Authorization header with a custom scheme

I'm designing a REST API using authorization/authentication via an API Key. I tried to figure out what is the best place for it and found out that many people suggest using a custom HTTP header such ...
17
votes
2answers
12k views

How should an API use http basic authentication

When an API requires that a client authenticates to it, i've seen two different scenarios used and I am wondering which case I should use for my situation. Example 1. An API is offered by a company ...
16
votes
3answers
24k views

Handling token renewal / session expiration in a RESTful API

I'm building a RESTful API that uses JWT tokens for user authentication (issued by a login endpoint and sent in all headers afterwards), and the tokens need to be refreshed after a fixed amount of ...
16
votes
4answers
13k views

Is it a good idea to merge multiple HTTP requests to save bandwidth?

I am preparing a single page application that would be sometimes used over slow mobile connection. Some of its part are quite heavy in terms of API requests (fetching ten different resources for a new ...
16
votes
7answers
69k views

What is faster? Using REST API or querying a database directly?

What is faster performance wise? Creating a REST API and having your web app use the REST API to do all interactions with your database OR querying your database directly (i.e. using whatever typical ...
16
votes
1answer
36k views

How can I unit-test my REST web service?

I am new to unit testing, I've one REST web method that just calls DB and populates a DTO. Pseudo code is public object GetCustomer(int id) { CustomerDTO objCust = //get from DB return objCust; } ...
16
votes
2answers
14k views

When to use nested resources in a RESTful API

I have two resources: users and links. Users can have several links associated with them. I have designed my RESTful API so that you can reach the links associated with a user at the following URI: /...
16
votes
2answers
4k views

Event sourcing and REST

I came across Event Sourcing design and I would like to use in an application where a REST client is needed (RESTful to be precise). However I fail to connect these together as REST is quite CRUD-like ...
16
votes
3answers
2k views

Which .NET REST approach/technology/tool should I use?

I am implementing a RESTful web service and several client applications that are mostly in Silverlight. I am finding a litany of options for developing both the server-side and client-side of the API ...
16
votes
1answer
8k views

REST API security: HMAC/key hashing vs JWT

I just read this article that is a few years old but describes a clever way of securing your REST APIs. Essentially: Each client has a unique public/private key pair Only the client and the server ...
15
votes
3answers
2k views

Versioning REST APIs. Each API has its own version

It's very common to specify the version of REST APIs in the URL, specifically at the beginning of path, i.e. something like: POST /api/v1/accounts GET /api/v1/accounts/details However, I haven't ...
15
votes
2answers
16k views

Is this a good Visual Studio solution structure for a domain driven design RESTful web service?

I am building a .NET 4.5 C# Web API RESTful solution and I would like someone to tell me if my project solution is correct and/or wise(-enough?) for a solution designed using Domain Driven Design, ...
15
votes
2answers
22k views

REST API Design: Multiple calls vs. single call to the API

We are developing a Rest API for eCommerce website which will be consumed by mobile apps. In the home page of an app we need to call multiple resources like Sliders, Top Brands, Best Selling Products,...
15
votes
3answers
14k views

Represent actions(verbs) in REST URI

I have a print operation to perform for my customer documents. I need the other standard operations to be performed as well, like add,update, delete. so, I have following: For creating new customer:...
15
votes
1answer
13k views

Authenticate native mobile app using a REST API

I'm starting a new project soon, which is targeting mobile application for all major mobile platforms (iOS, Android, Windows). It will be a client-server architecture. The app is both informational ...
15
votes
1answer
7k views

Proper response for a REST insert - full new record, or just the record id value?

I'm building a REST API which allows inserts (POST, not idempotent) and updates (PUT, idempotent) requests to add/update database to our application. I'm wondering if there are any standards or best ...
15
votes
2answers
37k views

What is the best way to create REST API error response model and error codes system?

My REST implementation will return errors in JSON with next structure: { "http_response":400, "dev_message":"There is a problem", "message_for_user":"Bad request", "some_internal_error_code":...
15
votes
1answer
4k views

Why is 'aggregation' not supported in most API Gateway solutions?

When reading about API Gateway, one of things that come up every single time is that API Gateway is a place where you should aggregate results from multiple endpoints. That sounds really nice. However,...
15
votes
3answers
6k views

How to support different API Versions

I am writing a Rest API and am wondering how best to handle supporting the different versions. By this I don't mean how to define a URI as V2 or V3, but rather how to structure the code given that it'...
14
votes
5answers
2k views

Is REST and HATEOAS a good architecture for web services?

If I understand correctly, REST was formalized by Roy Fielding as a descriptive model of the architecture of the web. AFAIK Fielding didn't claim REST was any good, he was just describing the de-facto ...
14
votes
4answers
30k views

How is oData different from a REST service?

I am looking into writing a web service API and I am thinking of creating a REST service. What does OData means in this context? Can you please explain the difference between OData and REST?
14
votes
1answer
8k views

RESTful API and i18n: how to design the response?

We are designing a RESTful API that is mainly intended to meet the needs of a single client. Because of its very particular circumstances, this client has to make as few requests as possible. The ...