Questions tagged [api-design]
Application Programming Interface (API) Design discusses best practises for creating libraries intended for general purpose or public use.
1,170 questions
2
votes
3
answers
183
views
API Design: Should I explicitly check for and throw on nullptr parameters if I have full control?
Say I have the following header
#ifndef WINDOW_HPP
#define WINDOW_HPP
// includes...
namespace window
{
struct Window
{
GLFWwindow *handle = nullptr;
};
struct ...
1
vote
1
answer
128
views
Should pagination metadata like totalCount be included in the ETag for cached paginated API responses?
I am currently rethinking my API response schema and caching strategy while implementing ETag-based caching for a paginated REST API (for example, listing places).
Each paginated response looks like ...
1
vote
2
answers
569
views
Is there anything that rest APIs can do that GraphQL still cannot do?
I just started learning about the specification, but I still have some doubts about why GraphQL simply hasn't replaced REST since it was created.
REST APIs are very inflexible and straightforward. ...
0
votes
1
answer
151
views
Microservice Architecture Design
I want to create one service that reads data from two databases and passes it to the customer devices. Is this an overall bad design decision? I think that since it is only read-only, it should be ...
2
votes
1
answer
179
views
Should I split endpoints by parameter requirements?
Preface: This will not be available publicly or to third parties, so I am not concerned about users having the background knowledge to properly form GET requests. These are also not only analytical ...
2
votes
3
answers
282
views
Allowing POST as fallback for GET when query would exceed maximum length of URL
A typical search query looks something like
GET example.com/entity/search?q=John
If we want to add some filtering to this endpoint, we could for example add ...&filter= followed by a URL encoding ...
1
vote
1
answer
241
views
System design for tracking viewed posts and returning unseen posts
I came across this system design question and have been wondering what is a good approach.
Requirement :
We have a typical blog or a mini social media kind of website where users create "Posts&...
0
votes
1
answer
269
views
Should I let objects, whose copying is "costly", be naively copyable?
I'm devising an API - or actually, a wrapper API for another, lower-level API - in a programming language with objects.
This API represents some entity E which is reference-counted (for example - a ...
2
votes
3
answers
2k
views
How to design for API use cases that need different data from the same table?
I am building a web application. This application is meant to be a home for player rankings and tournament results for a competitive community. I have planned to do this in three layers: a database to ...
1
vote
3
answers
151
views
How to put reference to external data in API input
This may be one example of a very general design question. Suppose I am building a service and I want the client to provide the location of some data on S3 which I will then read and process.
How do I ...
-1
votes
1
answer
81
views
Why would SMHI's weather API have this scaling for cloud coverage?
SMHI´s API have the below documentation for its properties. What intrigued me is the value range (0-8) for 'tcc_mean'.
Not only does it differ from other properties on the API, for example humidity ...
0
votes
1
answer
524
views
Should you use nested routes within NestJS for a "RESTfull" API
Here is an Example API for managing companies, employees, and their children. My entity relationships are as follows:
company -1:n-> employees -1:n-> children
I’ve structured the API routes ...
0
votes
2
answers
292
views
Is caching external calls considered a state change in the context of safe HTTP methods
Starting Point:
According to https://www.rfc-editor.org/rfc/rfc9110.html#name-safe-methods, when making a GET call, the client is not requesting and not expecting the call to lead to any state changes....
1
vote
1
answer
201
views
Background thread processing vs queue based processing for relatively short tasks (max 30-40 seconds)
I need suggestion / recommendation on the design approaches mentioned below.
UseCase: I have a usecase where a client uses my system to generate some recommendations. Now, these recommendations are ...
7
votes
4
answers
2k
views
How to maintain consistency when retrieving partial vs. full data in an API Resource
I'm working on a API for the logistics department, and I have a resource called logisticTransport, which is an entity in our database. I'm facing a challenge with maintaining consistency when ...
1
vote
1
answer
231
views
REST API with swappable backends
What would be the best way to have a single REST API but with multiple "backends" (Not sure if this is the correct terminology)? Currently we have a basket/cart API that handles product ...
0
votes
1
answer
218
views
How to handle data when source of truth is through API
I am making a webapp that deals with money movement. All the financial actions are done through an API. For example, right now I can create an account for a user, add funds to their account, transfer ...
-1
votes
2
answers
593
views
Idempotency for a financial transaction API
Say you have a REST API endpoint like POST /move-money which transfers money from your main account to a savings pot. There are three path parameters
accountId for the user's account
potId for the ...
0
votes
1
answer
138
views
Designing a restful API for a desktop application to facilitate communication with other APIs
Just for some context, I am a CS student in my second-year who is working on a C++ desktop application (using the Qt framework) made by an engineering professor.
The application is an educational tool ...
11
votes
5
answers
3k
views
Why split up data retrieved from a database into multiple endpoints, if we need ALL the data anyway?
I have a "Games" API which retrieves video game data from a large database.
The /games endpoint returns some very basic information about the game, such as the title, description, etc.
More ...
0
votes
1
answer
704
views
POST and PATCH for a nested resource in REST API
One post can have many comments.
How can I design REST API urls for HTTP POST and HTTP PATCH for comments.
My idea is to have the following endpoints:
HTTP GET: /posts/{postId}/comments
HTTP GET (all ...
0
votes
3
answers
655
views
Where should my users permissions live?
I'm building an application that allows the creation of users. These users can have profiles which define their permissions, as well as be given specific permissions.
Now I'm struggling on deciding ...
1
vote
3
answers
350
views
Should this request return a status of 404 or a different status
We have an API that allows clients to POST some request which takes some time to complete, so the API simply places it on a message queue and returns a 202 (Accepted) and a new GUID in the body.
The ...
-1
votes
1
answer
72
views
Sending Notification pattern
I am new to backend development and I was building a feature for my project where I can send notifications to various channels (for example slack).
I have a written notification class, which loads the ...
1
vote
2
answers
81
views
Hierachy and API design for a CSS-selector-related Python library
I'm writing a Python CSS-selector library that allows one to write these kinds of expressions in Python as a pet project. The goal of the library is to represent selectors in a flat, intuitive and ...