Questions tagged [api-design]

Application Programming Interface (API) Design discusses best practises for creating libraries intended for general purpose or public use.

Filter by
Sorted by
Tagged with
0 votes
4 answers
110 views

API design: Should a count() of a set of consecutively-id'ed elements return a size type?

I'm writing C++ code, where the standard library has an idiomatic type for representing sizes: std::size_t. Now, I'm writing a function which counts certain kinds of objects; and these objects have ...
user avatar
  • 2,427
0 votes
1 answer
54 views

Correct selection of flags for extension

In my library (DLL), I have extensions for List like the next one. <Runtime.CompilerServices.Extension> Public Sub Store(Of TVal As IFullyOperable)(items As List(Of TVal), w As BinaryWriter, ...
user avatar
-1 votes
1 answer
189 views

rest api design for bulk post [closed]

Is it OK for an API to accept either an object or an array on the same endpoint? I want to allow the user to post multiple items at once. I am thinking of creating a different endpoint, but then it ...
user avatar
  • 125
-2 votes
1 answer
103 views

How often should I request a token when communicating with a third-party API?

I have an ASP.net web API. I would like to call another API that has an authentication token inside my API. The code flow is as follows: My API is called → Get authentication token from 3rd party API →...
user avatar
1 vote
1 answer
296 views

MVC-like architecture: Model-Controller communication of results/status

I'm struggling on designing a solid architecture for my project. In particular, I don't know how to handle the communication between the models and the controllers. My goals are: Following the ...
user avatar
1 vote
2 answers
227 views

Should a client / server share error codes?

I am in two minds about sharing client / server errors codes. We are writing both ends of the system, if our API was external this would not be possible, but that requirement is very unlikely. So an ...
user avatar
  • 161
0 votes
0 answers
16 views

How should I design a web application that will show outputs and issue commands on devices using MQTT?

I'll be developing web application (most probably an Express.js REST API) that will include user management, device management by users. There will be users which will sign in and log in to the system....
user avatar
0 votes
1 answer
73 views

How to Properly Design an API Prefetch System

I'm creating an API for a web service. There are a couple of endpoints in this API that require some time (lets say +5min) to compute, so I'm creating a prefetch system that will call in the ...
user avatar
  • 131
-1 votes
1 answer
137 views

Why is `replace(dataclass, **kwargs)` a function, and not a member?

Imagine a simple data class: @dataclass class Settings: m: int s: str old = Settings(m=10, s="ten") It feels normal to write new = old.replace(m=1), but we have to write new = replace(...
user avatar
  • 334
1 vote
3 answers
140 views

REST API partially incorrect request handling

I'd like some insight/heuristics on how to tackle a specific kind of situation. Entity A, B have a parent child relationship with Entity C. Entity A creation is done thru a POST /createA API in ...
user avatar
0 votes
1 answer
160 views

Wrapping the UI framework

I want to write an application where I would delegate certain functionalities to 3rd party libraries. To make sure the code remains modular, I want to put these libraries behind an interface so I can ...
user avatar
0 votes
2 answers
78 views

How to structure URL when retrieving a REST resource by an attribute that isn't the ID?

Let's say I have a collection of cars, all identified by VIN, such that cars/xyz123 will return the car with that VIN. Furthermore, I can get subsystems (children) by using URIs similar to cars/xyz123/...
user avatar
  • 103
2 votes
4 answers
362 views

Should a REST API always document its response content?

I am using a REST API that is being developed at my workplace. The documentation clearly states the HTTP request type (POST), the URL endpoint, and the "payload" in curly brackets, i.e., ...
user avatar
0 votes
0 answers
32 views

How to validate against changes to "illegal paths" in backend requests for complex data structures?

We are building a backoffice web application where people are making changes to an array of nested objects. Because of totally non relevant business reasons there are things that users cannot change ...
user avatar
  • 519
8 votes
6 answers
1k views

How should an API handle unsupported fields?

Let's assume I have this API on /api/v2/persons that enables me to create new entries by POSTing this JSON: { "name": "me" } The API is implemented using Spring Boot and if ...
user avatar
  • 225
4 votes
1 answer
250 views

Can an api gateway handle websockets requests besides regular http requests at the same time?

I am working on social platform with a distributed architecture. The platform should offer a chat module, but since the most efficient way to implement a chat is using websockets. I am not sure what ...
user avatar
  • 149
-4 votes
2 answers
321 views

One rest api endpoint for multiple resources [closed]

Hello im about to create dasbord for my website.. Dashboard will have multiple subpages like users, posts, roles etc.. I was thinking i would use only one rest api endpoint for those resources like /...
user avatar
  • 111
-2 votes
1 answer
151 views

rest api - can two endpoints return different models if both return order?

Is it under the rules of REST to return a different model of 'order' if someone call: /me/orders/222 Return values: - OrderId - Price or /customers/111/orders/222 Return values: - OrderId - Price - ...
user avatar
0 votes
1 answer
431 views

Best way to enable field removal through PATCH

I am developing a REST API and I would like to allow the users to remove a field of the object through PATCH. My idea was to use a null field on the PATCH body as a signal to remove this field of the ...
user avatar
  • 19
1 vote
3 answers
174 views

Is the "archetype controller" really complies with REST architectural style

I've read the Fielding's thesis that defines the REST architectural style and noticed that the defined style appears to significantly conflicts with the so called "archetype controller", ...
user avatar
1 vote
1 answer
200 views

Should I combine or separate APIs for related but distinct entities?

Right now I'm working on a project that's basically a marketplace. The project separates backend (Django + DRF) and frontend where frontend can hit different endpoints based on user interactions with ...
user avatar
  • 129
4 votes
4 answers
277 views

API Design: Sending errors in the response

Suppose I have a products API: /products GET: List of products POST: Creates a product /products/12345 GET: Get a specific product PUT: Updates a specific product So is this a good idea for the ...
user avatar
0 votes
1 answer
58 views

API Design: For servers with multiple functions

Suppose I have a server with the following two jobs: Handle a payment using Stripe Connect to a DB with a list of posts/products/items What would be the best approach: Have all the calls go to /api/...
user avatar
2 votes
4 answers
740 views

REST API endpoint returning detailed or summary data

I'm designing a REST API that returns a collection of elements that can contain some verbose metadata, similar to one that might return books from a library. Is there a REST API design pattern to ...
user avatar
  • 181
0 votes
2 answers
202 views

Is it bad to use checked exceptions as API response?

Consider the following code: public class User { private String password; public void changePassword( String oldPassword, String newPassword) throws ...
user avatar
  • 705
6 votes
3 answers
377 views

How to simplify exception handling for library users?

Suppose of having a library exposing the following piece of functionality: public static class AwesomeHelpers { public static async Task<int> ComputeSomethingImportAsync(CalculationInputs ...
user avatar
-1 votes
1 answer
60 views

How do I authenticate API request when I dont have credentials for the other end

I am developing an app in which I have to fetch data through company provided APIs. All the authentication is done on their end, so I don't have to build my own APIs. However, There are some ...
user avatar
0 votes
3 answers
220 views

Should I separate the public and private portions of an application into two separate apps?

So I'm currently running an analysis task for my company. I won't go into too much detail but we are dealing with medical records and other confidential data. Previously this application was only used ...
user avatar
2 votes
1 answer
83 views

What is a good approach to handle editing product images?

You have the following situation: You have an SQL database containing two tables product and product_images You would like the user to be able to add, remove, or move around existing images They can ...
user avatar
3 votes
2 answers
139 views

parameter longer than the length limit of GET into a RESTful interface

In a Restful API, it is better to use GET to list a collection. However, in our scenario, we allow people query with a list of parameters (say CodeList) and then return details. As we allow upto 500 ...
user avatar
  • 141
2 votes
1 answer
136 views

Best practice for designing a WebAPI for exposing data in a SQL database interacting with C++ and C# applications

I am looking for general guidance or any relevant links for a complex project. We are a small business that sells a construction materials testing software. The client is a Windows application with ...
user avatar
1 vote
2 answers
89 views

API for input stream operation read until

I want to create a stream class The input stream should read/parse a continuous range from left to right providing convenience methods. The implementation isn't a problem but choosing a consistence ...
user avatar
  • 119
1 vote
2 answers
171 views

How to effectively handle a large API call

I have an API call that returns products to be displayed on a Point-of-Sale system. the current account I have has about 7000 products. Initially I made the API return all products at once, this works ...
user avatar
  • 21
0 votes
1 answer
71 views

How to design a rest api for updating collection(ArrayList) of Resource in Spring boot?

I have a resource called Client and it has the following attributes id, name, redirect URLs(ArrayList). class Client{ int id; String name; List<String> redirectUrls; } I have all CRUD ...
user avatar
0 votes
3 answers
96 views

Handling multiple possibile response types in API design

I have an app which uses barcode scanning to gather information about fruit. A barcode could be bound to either an Apple or a Pear: the app asks a remote API which one is it, and then stores the ...
user avatar
  • 59
0 votes
1 answer
170 views

How to define API notations for multiple tables data in the response

The question is specific to the API notation shown in the screen under the heading Table Name with the comment Joins Multiple Tables. I am using Spring Boot with JPA (Database: RDBMS) I have defined ...
user avatar
  • 103
0 votes
1 answer
72 views

Who to manage AAA , gateway or business service

In a debate with our solution architect, there were 2 proposed solutions to handle (illustrated below on the figure) In the first, the API Gateway manages Authentication, Authorization and Accounting ...
user avatar
1 vote
0 answers
44 views

Request and response validation

I am currently working on a project using Flask to make REST apis, blablabla. But, working with request validation tools that we use, I am thinking of whether it would be necessary to validate the ...
user avatar
1 vote
1 answer
72 views

Centralizing vs decentralizing of rounding-off and summation of data

Let's say there is a database that persists transaction data , e.g transaction items list of sale invoices , in raw format. Something like this InvoceId Item Price 1 Product-1 2.8592 1 Product-2 ...
user avatar
  • 103
0 votes
1 answer
56 views

API controllers modeling

I'm developing an API with ASP.NET, but I'm having some questions about the best way I should develop the controller layer for the products. I'm having these questions because each product will have ...
user avatar
0 votes
2 answers
151 views

Low level C driver API

Recently I had my first experience writing a wrapper around FTD2XX driver for a desktop tool that communicates with an embedded device. The library provided some common device specific functionality ...
user avatar
0 votes
3 answers
632 views

How to design RESTful API for response object properties dependent on request parameter

I have a RESTful service where clients provide product codes, start date and end date. In response, the service returns a list of price metrics for the products over the date range. Start date is ...
user avatar
  • 285
2 votes
7 answers
370 views

Representing a large list of complex objects in JSON

I am currently developing an API that returns JSON structures. One of the domain objects returned is a time series, which is a potentially large list (many thousands of elements) of complex objects. ...
user avatar
  • 184
0 votes
3 answers
174 views

Should the client silently fix a possible error or should it let the user of the client know about the error?

I'm building a client for an API. The API takes a query param that looks something like this 2-10, that's a range and notice that it uses a hyphen (-). Usually, data comes from another place using en ...
user avatar
3 votes
2 answers
951 views

Communication between two apps

I am thinking of creating two applications, one of which (App 1) will be in Django (DRF) and other (App 2)might be Django but might be another more lightweight framework (maybe Flask or plain Django ...
user avatar
  • 151
-1 votes
2 answers
193 views

Enum and Programming to Interface and best practices

I am learning stuff and have made 2 microservices, Listener and MyApp. Listener is a jms listener (consumer of messages) and MyApp is the app sending messages to queue. I have 2 type of events CREATE ...
user avatar
0 votes
2 answers
558 views

Move from mft to api REST style to get or post large data 200mb , is it best practice?

I am designing the API architecture for my client: My client actually exchange huge files (csv) with his Partner with MFT ( SFTP ) **Partner ==> MFT ==> Client ** The requirement is to move to ...
user avatar
0 votes
1 answer
173 views

Expose or consume API REST?

I am preparing the software architecture for my client project based on APIs REST The idea is that any data exchange between my client and his partner will be via API REST call The specification is ...
user avatar
0 votes
2 answers
77 views

Designing an API where an image can be supplied

I am designing an API whereby some other system can supply an image in their POST. As such this is an API for integration purposes, with no front-end. Postman is used for testing the API. Below is the ...
user avatar
  • 109
-2 votes
1 answer
140 views

Recommended way of caching weather information

I'm developing an application that will show some weather information based on the user's location. Since the weather forecast is just a very small feature of the app that complements the main ones, I ...
user avatar
  • 117

1
2
3 4 5
22