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
1answer
36 views

Is it permissible to have relationships to parents of parents for JSON:API resources?

I have the following hierarchy: venue -> concert -> booking And within booking I have a relationship for the concert. But should the booking also have a relationship to the venue? Or is it bad ...
-2
votes
0answers
16 views

How to provide value in analyzing an existing organization's API?

I have an agreement where I am being hired for a few hours to look over a company's API and provide any suggestions on how to improve their system/where they are lacking. This would be the first part ...
0
votes
3answers
35 views

Offline Synchronisation with Changing Access Rights

We got a distributed application where a client syncs certain data portions to its offline storage and performs modifications on it. The data is structured in container entities "Container" and ...
0
votes
1answer
52 views

Check that a POST request is the origin of the application and not of a user

Hello, I want to secure access to a POST request so that the user cannot forge it via software such as postman. Let’s say a player plays a game and gets a score. At the end of the game, the score is ...
1
vote
0answers
37 views

What's the most intuitive way to organize a set of endpoints to fetch users and their roles in groups?

What's the most intuitive way to organize a set of endpoints to fetch users and their roles in groups? i.e. Users and their roles in a specified group. Groups a user is in, and their role in each ...
-1
votes
1answer
38 views

Confused about data access layers and modelling or filtering layers

I've created a database and included in the tables are these three relatives Game GameHasPlayer Player I've created a data access API project, with simple methods for getting filtered results: ...
0
votes
1answer
63 views

Should List(Get) and Search be the same endpoint API (method)?

Here are two endpoints (or methods): ListResources(user_id) - Fetch the resources based on the given user id. SearchResources(query_options) - Fetch the resources with specified conditions. The ...
-3
votes
1answer
239 views

How do I overcome the limit of 4000 results returned from the REST API?

I have an application which records the company man hours of employees and other related details. Because it gets updated everyday or when a new employee is added, it tends to lead to a very large ...
0
votes
2answers
149 views

Should I assign a default value for this property in the constructor?

I'm currently creating a class in C# that will be utilized to help standardize calls to restful web services in my company's code. While the majority of my code has been written and well tested, I ...
0
votes
8answers
1k views

Is there a use case for boolean parameters? [closed]

Most programmers (including me) believe that methods with a boolean flag parameter should be refactored into two methods without the flag parameter. Are there any use cases for a boolean parameter ...
1
vote
1answer
71 views

Atomicty with two points of failure

Lets say we have an API that receives requests to commit a money transaction. The API receives the requests from a certain client and calls for a certain 3rd party service (lets say provided by the ...
-2
votes
1answer
118 views

Where to conform the API? [closed]

I have a software accepting a HTTP request like this (and I'm happy with that): /products?page=2 /products?category=123&page=1 /product?id=123 /cart?show=table Now there is a consumer third-...
2
votes
1answer
70 views

Error Codes with Properties Files or Database

I'm about to implement Error codes for my company API, so, based on rfc7807 I will include a type which is an error type which is basically an error category, and inside those categories we have a ...
5
votes
3answers
196 views

How to design a rest API that connects to other API's

I'm having a architecture challenge. Simplified scenario: We have a CRM-system (for now called This-Is-Our-CRM) that contains person data. We created a rest API so our data could be accessed outside ...
1
vote
1answer
86 views

Public class members in PIMPL

I'm attempting to use the PIMPL idiom. This is my public header file in include/foo.h: class FooPrivate; class Foo { public: Foo(); ~Foo(); private: FooPrivate* p_impl; }; ...
1
vote
1answer
85 views

How should REST resources relate to the server database schema?

I am trying to understand whether resources in a RESTFUL API should directly represent the underlying database or not. In particular, a problem that I have is that I usually use highly normalized ...
4
votes
5answers
152 views

How to represent business logic in restful API

Let's imagine that I have an employee resource. { "id": 1, "name": "John", "role": "Office manager" } And I want an endpoint that promotes them. As part of that I want some side effects to ...
-4
votes
3answers
70 views

REST API design: Best practice for POST to create an object to a list

I have an API that return list of Employee. This API will have an offset and limit for pagination purpose. On the frontend, I use Single-Page Framework (Vue/Angular/React..). This SPA have a Employee ...
1
vote
2answers
111 views

Retry a failed REST API request - Java/Postgres

We have a REST API which calls a third-party REST API to Send Emails. The Third Party API is not super reliable and randomly fails every now and then with a 500. Our Clients do not want to retry at ...
1
vote
1answer
121 views

Corrrect to send JSON object in params?

Maybe I'm being dense, but is it common practice to create an API which requires users to submit GET params as an object? I've encountered one which has me submitting GET requests like... http://www....
-2
votes
1answer
85 views

Create a single api with one big post request vs multiple apis with smaller post requests

We are building a backend RESTful service for a workflow builder. The service's responsibilities will be to accept workflow definitions from a frontend and store them in a database. We are trying to ...
2
votes
1answer
92 views

Does it make sense to qualify an error as an HTTP error without an HTTP client-server communication

I am writing a C# client SDK to a REST Api. This SDK sends JSON-serialized models to the API, and implements a first level of verification of the parameters. If the verification fails, it throws an ...
0
votes
0answers
49 views

Ist good practice adding Converter Between api and client

I just want to curious about adding a converter is a good practice or not. I have multiple API and I always convert API return fields to my client fields. Like=> function ConvertFromAPI(apidata){ ...
0
votes
0answers
10 views

Using both jwt tokens & api lifetime tokes in Laravel app

Previously I had some experience using JWT tokens when making SPA. The workflow is: User enters email & password, gets JWT token, the token is stored in local storage and is passed in each ...
-2
votes
1answer
39 views

Endpoint returning only new and updated records

let me state some items. I have this endpoint that returns a list of objects, and I would like to return only the changed ones. I have an App calling this endpoint that caches this list, and today it ...
38
votes
6answers
7k views

Is there a pattern for handling conflicting function parameters?

We have an API function that breaks down a total amount into monthly amounts based on given start and end dates. // JavaScript function convertToMonths(timePeriod) { // ... returns the given time ...
-1
votes
2answers
73 views

Hiding other configuration values from the consumer of an API

Let's assume we have a required attribute foo for an API call. This can have valid values of 1 and 2 which denote some valid option in the system. Since this field accepts an integer, if we provide ...
4
votes
2answers
142 views

client / server division of responsibility

It makes sense to give the server applications as much responsibility as possible as to avoid having to rewrite logic across different types of clients. In my case I am developing a data structure ...
1
vote
2answers
318 views

Why do large organizations struggle to build standard APIs?

I work for a company with 580+ cloud APIs (with every API implementing different functionality, but with a lot of overlap) and even more micro services. There have been many attempts integrate all ...
2
votes
1answer
153 views

C++ API design: using references vs smart pointers in a getter API

I'm trying to design an API for an object manager that registers and retrieves different related objects. When I want to retrieve an object, I can query it by its object id. I'm wondering if I should ...
0
votes
1answer
24 views

Contemplating about API design of a typescript/nodejs library for querying a remote storage service

I am working on a Typescript library (to be used by many users within my org, possibly open-sourced) which provides access to some remote storage. I am contemplating between several variants for the ...
1
vote
1answer
49 views

mongodb queries architecture - resolving lots of nested referenced objects

I have an angular 8 application, with a Python + MongoDB API on the backend. At present, I have 4 collections, namely: Users, Tasks, Companies and Groups. All of these resource types are retrievable ...
1
vote
2answers
76 views

REST: How to reference existing resources in a HTTP POST request body?

This question relates to a somewhat more specific case than the one discussed in How can I create a RESTful calculator? It should be assumed that the values to be calculated are not simple integers, ...
1
vote
1answer
108 views

One API used by multiple clients with small variation in the flow

I am working on refactoring codebase for a JAVA API thats used by multiple clients. Though the api provides the same overall functionality for all clients, actual flow changes a little bit between ...
0
votes
1answer
53 views

Should two different set of login APIs follwing REST have write access to the same DB?

Like for example, /api_1/login and /api_2/login writing in the same table of the same database.
6
votes
3answers
258 views

Domain-Driven Design: Cross-Domain Search

I have two systems (for sake of example, and orders and an account domain). Their interfaces consist of an api per system (an orders api and an account api). I have a UI that is sitting on top of ...
-3
votes
1answer
36 views

An entity belongs to another entity. Should a REST API provide just the ID of its parent, or its endpoint?

Say a dictionary belongs to a language. For the endpoint dictionary/{id}, which is preferable out of: {..., 'language_id': {id}, ...} and: {..., 'language': '/language/{id}', ...} ?
2
votes
1answer
158 views

C++ How to build a common interface with the possibility to call functions specific to only one class

I am building a common interface for several different backends that are shared libs loaded at runtime dependend on the used platform. It looks basically like the code below. My problem is, that while ...
0
votes
1answer
64 views

API design refrence , Empty list response (REST, SOAP, …) type compatibility

Not sure where to go for an authoritive/text book answer for this question. Suppose a service returns a list of something e.g. Customer, Employee, Fruits, etc. What should be returned when the list ...
2
votes
1answer
72 views

Distributing library which internally using COM library

I would like to create a dll library that will be loading in runtime. The library'll be using internally COM objects with MTA flag. The library will be created in main thread. So I have question: ...
0
votes
1answer
53 views

Designing Rest API endpoint for viewing bearer access token

We have several endpoints which were authenticated using a bearer access-token. There was another endpoint which will renew/generate a new bearer access-token on passing valid secret_id and client_id. ...
0
votes
2answers
93 views

How do I effectively build a Product on my on my public API?

I want to develop a new product on top of an existing public API. This will require functionality to be added to that API. How do I develop and API for both public use (by other organisations) and ...
2
votes
0answers
27 views

Should custom Django Admin be separate from client endpoints?

I am currently in the process of creating a Django REST framework project for a client server web app. I would like to ask the following: Should I write a custom admin if I want my app to be ...
1
vote
1answer
46 views

How to handle or design review system with pagination?

In typical online review system if any user give review on specific post or others thing, then when that user view that post his review show first. The perfect example of this is Google Play Store. If ...
-2
votes
2answers
140 views

Confused about how APIs are called

I'm new to APIs. Conceptually, I understand what an API is, but I get confused when it comes to the some of the technical details. All of the tutorials I've read talk about URLs and endpoints, and ...
1
vote
1answer
51 views

How do I create an HTTP PUT request that modifies the resource in many ways

I have a NodeJs backend that interacts with MySQL database. Let us assume that I have a schema similar to this: Book id name Author id book_id name So, I have two tables named Book and ...
1
vote
1answer
147 views

Designing an Entity Component System for interfacing with a scripting language

I am currently building an Entity Component System (ECS) in cython in order to speed up operating on large numbers of game objects in python. In the process of building this system, I ran into the ...
0
votes
0answers
42 views

How do you expose the field that caused the error?

Context: field errors Given an input in the form: { "list": [ { "username": null }, { "username": "test" }, { "username": "" } ] } Some APIs expose errors in the ...
-1
votes
1answer
40 views

Adding resources to subresource REST API

I'm trying to build an web API that closely represents a library of books. I currently have the following routes. GET /api/books GET /api/books/:bookID GET /api/libraries POST /api/libraries This ...
1
vote
0answers
32 views

Assigning default filtering values for complex API request model before passing it to business domain?

I am writing an API (web-service) for my customers and there is an endpoint which allows to search for the documents in my storage (files, folders) by applyingg complex filters. Initially, client ...