Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [api-design]

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

0
votes
1answer
64 views

What is the best practice for sending a large array of strings to an API

I'm building a simple app that is a client web application and an API behind it. I'm combining two third-party APIs, one needs to be called from my client application (for ease of authentication) and ...
0
votes
0answers
5 views

Problem to structure code permissions (ACL) [migrated]

I have a problem here to structure the code to validate the permissions. Let's suppose I have three actions: read:own_users, read:my_users, read:all_users. And I have a route get/users. I want this ...
0
votes
0answers
23 views

Designing the API of a VMF (Variable Message Format) Parser [closed]

Variable Message Format (VMF) is covered by the MIL-STD-2045-47001 and MIL-STD-6017. The tl;dr for these standards and the format is, that it represents a message format, which contains variable ...
1
vote
2answers
46 views

API Microservices bundle multiple services as one deployment Vs separate deployable for each service

So I am going to be developing atleast 5-6 Res end points . ( all distinct and stateless ) Now I am debating on the following: Should they be combined as single war / ear or deploy each service ...
1
vote
3answers
91 views

Affecting the behaviour of a REST API POST

I have an API that has a POST method to create a new Product. The creation of the new Product is handled by POSTing to a ProductService. Now I want to be able to instruct the API when creating the new ...
-1
votes
1answer
98 views

how to expose complex actions in RESTApi using http verbs

consider the following REST resource Account { number:"number-000", name: "name", customer : {}, type : {}, status : "status", balance : 0, rating : 0.0 } Now say we have the ...
2
votes
2answers
151 views

Should smart pointers be exposed in a C++ API?

Exactly as the name says, should smart pointers be exposed in a C++ library API? I've used quite a few C++ libraries and haven't ran into exposed smart pointers yet. Given that it's very common to ...
3
votes
2answers
100 views

How do I create database records based on rules?

I'm creating an application in which people meet certain criteria to receive a payout at certain milestones. In order to earn these milestones, users will record activity in a log, and when they have ...
0
votes
0answers
4 views

Should my unittest code be much more than my code for a REST API? [migrated]

I am currently developing a Django Rest Framework API with TDD. I have 15 tests and counting for two views, which doesn't seem right to me. It takes me a lot of time to write the tests and a lot of ...
4
votes
1answer
232 views

How to properly version an API?

I'm designing an API for our web application, that will be consumed by mobile developers that will create our mobile app. I chose to document it using Swagger / OpenAPI 3.0.0. I'm surprised that ...
0
votes
1answer
34 views

Best way to make insert data in logs web API. REST or WebSockets

I want to make a centralized log web API, so it will have a large amount of data per seconds. the logs will comming from others WEB API I was thinking if i make the REST API, all of the POST made ...
4
votes
2answers
229 views

Heavy task exposed via a REST API

A part of a system I am currently reviewing, consists of a master node which calls several slave nodes using REST APIs. The slave nodes are scattered throughout the world on different servers, and ...
2
votes
1answer
81 views

How to design document exchange system

I am trying to come up with a design of document exchange system. System should be for business-to-business communication. Description: There will be possibly 100+ clients(consumers) - they will have ...
2
votes
1answer
58 views

Keep Hitting 3rd party API or Store Commonly Queried Data In DB?

Colleague and I have begun a long (and hopefully fruitful) project. I've been building and have come to my first crux, and now I ask the experts of the Stack Exchange for their guidance. I'll keep ...
0
votes
2answers
61 views

backwards compatibility of REST API for update/patch when adding new fields

Context: Suppose the current way to update a person is to use HTTP PATCH, where you can set the firstname and lastname: { "firstname": "john", "lastname": "doe" } And you want to add an extra ...
5
votes
2answers
280 views

Is it bad practice to use a single endpoint to do multiple similar tasks?

So the scenario is that I'm asked to redesign and refactor a REST API by combining multiple endpoints that do similar tasks. For example, now I have 10 different endpoints that are all used to upload ...
0
votes
0answers
95 views

Where should the API reside?

I have a microservice(opsApiServ) which hosts API to do operations(ops). /ops - POST, GET /ops-item - GET ops-item is just a single unit of operation, and ops is collection of operations (ops-item). ...
1
vote
1answer
92 views

Have generic methods that transfer DTO's from different packages, but contain same fields

I have 3 services Service A, B, C which put and get data to/from Service D +============================================+ | Service A | Service B | Service C | +==============================...
0
votes
1answer
62 views

Microservice on top of an API

I have an Odata API server that I can't change only access it, I can do CRUD operations on it. However I'd like to authenticate users, that are stored on this server. I can retrieve a user (his email, ...
0
votes
0answers
30 views

Good practices: using member routes or filter on search scopes?

I want to know which practice is more convenient having the following example, (my app is a Rails app but this can be applied on any framework) I am trying to create an endpoint which contains author ...
0
votes
1answer
82 views

Way to describe a coordinate system without external points of reference?

I'm writing an API for a JavaScript library to let my users offset an object from another. I have to provide my user with a way to describe a "vertical" and "horizontal" offset. My problem is that I ...
0
votes
1answer
60 views

Use same API for both website and other clients or not?

Lets say I am building some large application ( multi-page app ) using Laravel. And laravel will allow me to make an API and a website on the same application. Since the website and the API ...
2
votes
3answers
204 views

Is something like “answers/{id}/downvote” considered RESTful?

Looking at Stack Exchange API docs, I see methods like answers/{id}/downvote answers/{id}/downvote/undo comments/{id}/delete. Should this be considered a RESTful API? (The docs does not mention the ...
-2
votes
1answer
69 views

Is it a good idea to ask for requestId in each API call?

I see some services which takes a requestId from client as the mandatory attribute while some services doesn't. I feel it is a good idea to have a request Id from the clients because it helps in ...
-2
votes
2answers
68 views

REST API acceptable design flexibility

I design and works on lot of projects involves REST APIs. But one question is always occur to me if it is acceptable way to do REST. So according to REST manuals online, REST is build upon two major ...
0
votes
0answers
45 views

How would design a wrapper for a large, multi-response api like the one described below?

Let me explain. Lets say there exist some service at some organization that exposes information on a company's assets, from employees company-issued devices(laptops and issues) to the the large xerox ...
0
votes
0answers
71 views

Separating models in a Backend-For-Frontend (BFF) API

At the moment I have a frontend client calling several backend REST APIs. For example a call may be to get information about a certain vehicle. Then the client will call REST API A to get some ...
0
votes
1answer
63 views

Avoid numerous dynamic_cast_ptr in the API design of polymorphic types

I am trying to design a geometric intersection API. Below is the code to represent geometric elements. #include <iostream> #include <memory> // Since I did not write the Shape class I ...
-2
votes
1answer
120 views

How to implement HTTP PUT correctly

I'm really looking for one good example how to PUT operations should be implemented correctly. What I understood until now: The operation must be idempotent When the resource doesn't exists it will ...
3
votes
2answers
131 views

Is this data as a result of business logic or is this content as a result of GUI logic?

I'm aware of the general distinction between data and content, namely context, but here I have a case that is clearly causing a lot of confusion and debate within the company I work for. There is a ...
5
votes
2answers
288 views

Why use multi-purpose getters that take an enum value, rather than separate getters?

I'm designing a C API which will have about a dozen getter functions for various values. Something like: bool getSomeBool(); bool getSomeOtherBool(); ... int getSomeNumber(); int getSomeOtherNumber();...
0
votes
0answers
24 views

Creating an API for adding third-party JIT support to a VM

I have created my own VM/runtime environment engine and I would like to give my runtime environment an API so that a developer could interface any type of JIT compiler to my VM. So far I've created ...
2
votes
5answers
259 views

Which layer should have responsibility for rounding numbers?

I am developing a financial system and want to have a defined policy for rounding monetary values. Given the following layers: View API Entity Model Persistence If I am passing a monetary value ...
0
votes
0answers
16 views

what's the proper way to interpret SREM results from REDIS

Background I am writing a REST API that exposes a method that allows the caller to delete a resource from the REDIS database. Because I'm using a SET, when you try to do an SREM, it will just return ...
1
vote
1answer
157 views

Why read and write API are good or why not?

While designing a complex system some of my colleges came back with the idea of having two separates APIs, one that will perform the writes into de databases and another one that will only do the ...
3
votes
1answer
446 views

C# .Net Core API design - interfaces vs DTOs

I'm designing a relatively simple web application using .net core. I've mostly done desktop development in my career so far, so I'm a bit new to the nuances between desktop and web development. In ...
50
votes
9answers
11k views

Should you guard against unexpected values from external APIs?

Lets say you are coding a function that takes input from an external API MyAPI. That external API MyAPI has a contract that states it will return a string or a number. Is it recommended to guard ...
2
votes
3answers
113 views

filesystem::path vs. optional<filesystem::path> as argument to function

Sometime ago in a code-review (C++) I suggested to change the input argument from Path type to Optional<Path>, where the function has specific logic for unset path. It looks for me intuitively ...
9
votes
8answers
686 views

Is an interface exposing async functions a leaky abstraction?

I'm reading the book Dependency Injection Principles, Practices, and Patterns and I read about the concept of leaky abstraction which is well described in the book. These days I'm refactoring a C# ...
2
votes
3answers
88 views

Permissive vs. Strict API Message validation

We had a interesting debate today over what our REST API should default to doing when validating a request body where unexpected fields are present. I think we ended the conversation in a good place, ...
-1
votes
1answer
69 views

Making the REST API to act as a playlist

Imagine the application I am building as a normal media playlist (Video / Music). On the client side, I select the files I want to play (Files are located on server), and I send its paths to the ...
1
vote
0answers
31 views

API as system controller

I'm developing a system, and I've had a question that might help other people. The system would be written in PHP, with a lot of chance of turning a mobile app later, too. Normally, I would create it ...
1
vote
0answers
28 views

Spring Boot and Mustache app separation of concerns

I am wondering how best to slice up a Java Mustache web app which has: Data layer (JPA, Repos, Entities, etc) Service layer getting data from other company web services outside the package Web/...
2
votes
2answers
72 views

Designing a Python API with defaults

I'm designing an API for a Python library. The user will create objects with several parameters. In most cases, the user will either leave these at their default values or will set them globally, for ...
1
vote
3answers
194 views

How can I resolve this **kwargs antipattern?

I am a hobbyist programmer, working on a much more complex Python project than I've attempted before, which is in the form of a Python library. I find that I'm often passing **kwargs around (as ...
6
votes
3answers
311 views

Should a high-performance API expose low-performance utility functions?

Context: I'm working on an open source project to solve a problem that comes up in ad-tech and social media data mining: indexing boolean expression trees, and matching them against incoming documents....
0
votes
2answers
88 views

Should we override all method overloads

Usually method overloads delegate their parameters to the more detailed overloads with default values. here is an example A(x) => A(x, null); A(x, y) => A(x, y, null); A(x, y, z) => ...; ...
2
votes
6answers
226 views

Difference between REST & HTTP REST implementations

REST principles are described here: https://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm#sec_5_2 https://en.wikipedia.org/wiki/Representational_state_transfer#...
1
vote
1answer
105 views

Is GraphQL REST compliant (almost)?

I am writing an article about traditional REST vs GraphQL. However, after doing some research about REST (not just a specific implementation of REST), I started to see that GraphQL actually abides to ...
3
votes
1answer
205 views

params T[] vs IEnumerable<T> as parameter type

I know there's a proposal for params IEnumerable<T>. When designing an API, when should we choose params T[] (params array) over IEnumerable<T>. Or should both be implemented for better ...