Questions tagged [api-design]
Application Programming Interface (API) Design discusses best practices for creating interfaces between computer programs, web servers or libraries intended for general purpose or public use. In contrast to a user interface, which connects a computer to a person, an application programming interface connects computers or pieces of software to each other.
1,173 questions
10
votes
5
answers
1k
views
How to deal with public vs private version of same resource in a RESTFul API?
I am having a hard time to deal with one particular issue in API design that might be very common. Let me give the concrete example I have: I am writing a RESTFul API for a store and have the ...
2
votes
5
answers
448
views
Is this proper usage for std::expected and std::optional?
I am trying to improve the readability of my code and make things more self documenting (or at the very least learn new things about C++) for example:
// OLD
Texture LoadTexture(const std::string& ...
0
votes
1
answer
109
views
Is This A Good API Design For A Programming Language C API? [closed]
I am designing an interface for C code to add functions and modules to my programming language. I am wondering if this is an OK design for a println function.
This function would take in a vararg of ...
1
vote
3
answers
470
views
How to pass arguments of a complex search in RESTful API request params
I’m building an app that lets users manage data across multiple tables. I also expose an API so they can fetch their data and process it in external services.
I’d like to enhance the API to support ...
2
votes
3
answers
333
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 ...
2
votes
1
answer
256
views
Serving several external APIs in Django + Angular application
I'm working on a web-based app that uses Django and Angular. This app uses several external APIs to fetch environmental data from different monitoring networks. We then use these data to perform ...
1
vote
2
answers
710
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. ...
341
votes
14
answers
94k
views
Should you write your back-end as an API?
I had a heated discussion today about our MVC application. We have a website written in MVC (ASP.NET), and it usually follows the pattern of do something in the view -> hit the controller -> ...
1
vote
1
answer
248
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 ...
2
votes
8
answers
607
views
Contract extensibility as it relates to enums and type unions
Say I have a contract returning a type:
type CreditCard = {
scheme: "Visa" | "Mastercard"
}
and later we decided to include Amex as card type, then making this change:
type ...
0
votes
2
answers
240
views
Is exposing full backend entities to a Vue frontend a bad practice? A case for DTOs?
I am doing the frontend for a Java Spring backend. The project uses JavaFX for the front but I a migrating it for web usage (with VueJS). When I make an API call to retrieve an object, I am receiving ...
2
votes
3
answers
3k
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 ...
134
votes
14
answers
22k
views
Should the solution be as generic as possible or as specific as possible?
Say I have a entity that has "type" attribute. There could be 20+ possible types.
Now I'm asked to implement something that would allow changing the type from A->B, which is the only use case.
So ...
57
votes
7
answers
16k
views
Why do so many standards for JSON API response formats contain a "success" property in the response body instead of just using HTTP status codes?
I was researching about best practices for standardised JSON response formats for APIs, according to various sources available online general consensus looks something like this:
//Successful request:...
0
votes
1
answer
207
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 ...