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
0answers
38 views

How to best design this communication module/library?

Introduction A customer of ours has embedded products with sensors and actuators. Now they would like to connect this device to the cloud so they can remotely monitor and configure it. It should ...
1
vote
5answers
183 views

Should a parseInt function return null, NaN, or throw an exception?

When providing JavaScript's parseInt with a non-parsable string it returns NaN. I'm trying to understand the reasons for designing a parsing function this way. When I write a parsing function I ...
0
votes
1answer
33 views

Allowing a client to specify whether parameter is Required or Preferred

I am enhancing an existing API to provide shipping rates for a b2b web service. This specific endpoint returns a single rate based on matching request parameters such as the service level and package ...
-1
votes
1answer
38 views

Method parameter ordering [closed]

Assume that I am implementing a method that takes a data source in a system. Assume that it's a multi-tenant system, so a data source belongs to an organization (as other relevant entities, like users/...
1
vote
1answer
66 views

How to manage versioning for changes that only affect some pieces of a package?

I'm designing a new language and the package-management system for it (something like NPM, Cargo, Pip, Gem, Cpan, Cabal, NuGet or the like). I'm trying to decide what's a good way to handle the ...
1
vote
1answer
40 views

Use multiple or a single endpoint to modify different related ressources

To simplify I'll say I'm using a list containing an array of Movies, and Movies. Problem I have two options to update both the note in the list, and the global note of the Movie. Single Calls POST www....
-3
votes
1answer
49 views

Standarized prefixes for naming REST POJO (Bad or good practice)? [closed]

We are building a software application for a client with a particular naming convention for REST services. For example if you use a POJO for your request or response in a REST service something like ...
2
votes
0answers
47 views

Is it possible to use an SPA as the UI for an OAuth 2.0 authorization server?

Using SPAs as the UI in front of an API has become standard practice, with OAuth 2.0 / OIDC being the common authz mechanism for this. This approach generally entails the SPA receiving its access via ...
-1
votes
0answers
16 views

Request Forwarding Websockets with Nodejs

So the architecture I am currently working with, we have an api-gateway that gets all the requests and publishes them to our Eventsystem/ or directly to our essential services(auth, etc). Now we want ...
1
vote
3answers
99 views

How to make Request from Client to Server more evenly distributed (over 24 hrs)

I'm trying to write a new API that can support many devices. There will be at least 50k devices in the beginning that will connect to the server using an HTTP API on a daily basis to receive updates. ...
2
votes
2answers
155 views

What are the best practices to authorize every REST request?

My question may sound very naïve to someone, but it is what it is. I have below scenario: Relational MySQL Database with BIGINT primary keys and foreign keys Spring boot as a backend (technology ...
1
vote
1answer
116 views

Templates for generic code and code flexibility

I have a data which is a std::vector of a "small collection" of items of a given type struct Bunny {};. I was vague about "small collection" because for now it's a collection of ...
14
votes
6answers
3k views

How to design for an ordered list of unrelated events

This is a bit of an invented example but I think it best illustrates my question: Say I'm creating a chess replay event API. Say I have a lot of different "events" I want to keep track of, ...
2
votes
3answers
144 views

Indexable iterators

Suppose someone designs an indexable iterator class, i.e. an iterator that supports __getitem__ for (non-negative) integer indexes such as the following: In [1] it = indexed_iter("abcdefghij"...
0
votes
3answers
295 views

Is there a way to signal that an endpoint should be called before another in REST?

I have 2 endpoints: enpoint A can only be called if endpoint B has been called before at least once. After endpoint B has been called, endpoint A can be called multiple times. endpoint B can be ...
1
vote
3answers
79 views

API Versioning when changing a single HTTP Method of an entity

When making a decision to version an API. If you are making a change to an entity but are only making changes to the one of the HTTP Methods. For example POST /api/v1/customers accepts a list of ...
0
votes
2answers
58 views

Should I return user data in an authentication endpoint using JWT?

I implement an auth endpoint which takes an email and password and returns a JWT token. Inside the JWT there is a payload containing the user ID. Does it matter from a REST/JWT standards perspective ...
0
votes
2answers
54 views

Setting custom callbacks in a Javascript applet?

I'm designing a 3D visualisation applet in Javascript. When used, a Canvas will be created and placed inside an HTML element on a webpage, specified by the developer who is implementing the applet. ...
2
votes
1answer
47 views

Manager node makes HTTP request to self?

I am working on a distributed application that uses the Manager Worker pattern. The application's manager node submits work to worker nodes through a WorkerNode object (allowing WorkerNode to be ...
0
votes
1answer
141 views

What should we consider when designing a load balancer with minimum cost

Given a set of processes running on a cluster of hosts, I'm designing a system that load balances the hosts through live migrations (carried out by an external service) of the processes. The goal of ...
3
votes
1answer
113 views

Design that hides cache as an implementation detail

I have a type which is fairly heavy (maintains an off-heap object), and which can be uniquely derived from a String. It requires cleanup, so of course the type has a close() method, but it is used in ...
2
votes
3answers
130 views

Good ways to prevent client side logic duplication without HATEOAS?

I know HATEOAS can be a bit of a heated topic. Some people like it, some people don't. That is not what I want to discuss. What I want to discuss is what technology other than HATEOAS (or some form of ...
1
vote
1answer
56 views

Handling multiple REST API versions in one codebase

I have a REST API (v1) which routes through to a Java springboot component for which I now need to introduce a number of breaking changes to add new and changed functionality (v2). I understand how I ...
1
vote
1answer
134 views

C#: Should I define methods as async?

I have a C# (WPF) application which consumes a particular 3rd party API/tool (let's call this Tool A). My colleagues and I are trying to decouple that from our application, so that it is possible to ...
-1
votes
1answer
47 views

Checking caller has access to an API resource - Design

We have a managers api (/api/managers/-/staff), which will get a list of staff that the currently logged in manager has been granted access to. It is the Managers service. We also have a staff api (...
0
votes
1answer
46 views

Normalize timestamp values or have multiple SQL queries

I have a Spring Boot application to implement a RESTful API. One of the GET requests have two query parameters: from and until (of type date). Those parameters are optional, so user-agents can send ...
0
votes
1answer
56 views

Logging microservice - error level in URI or body?

For my use case I need to create a microservice that receives log messages through HTTP. I'm wondering about the reasons to pick either of these: Method: POST URI: /{logLevel}/ Body: { "message&...
0
votes
1answer
83 views

RESTful API design when a “resource” is split between storage locations

Let's say you have a database-credential resource that stores a few things: whitelist of IPs that can connect connection password for the user When GETting / POSTing these, should they be under one ...
0
votes
1answer
47 views

IOT data interpretation

This is a more architectural question and I am hoping to get more ideas out of this thread. I have a computer vision model detecting daily life activities and sending data to the server every second. ...
2
votes
1answer
120 views

API development - Exposing new version VS updating current version

Context There is a back end and a front end team. Back end exposes an endpoint to the front end app: PATCH car/{carID}/tire Problem I want to update the aforementioned PATCH request functionality ...
1
vote
1answer
109 views

Building a Microservices App — Can you give feedback on architecture?

I did some googling, and I was directed to Software Engineering to ask architecture questions. If you know of a different forum that could help me, please direct me to it I recently started learning ...
-1
votes
1answer
33 views

Opinions on using standardized J2EE APIs over specific over vendor APIs

I have always advocated the use of standardized api, and currently use it on my code. However i always get very strong resistance when it comes to code review, even on projects i have designed and ...
0
votes
3answers
65 views

REST API path parameter with multiple meanings

I have an API that manages projects. You can get a single project via this endpoint, where {id} is a numeric project ID: /projects/{id} Each project can have one or more tags. Now I want to add an ...
1
vote
5answers
296 views

What http codes should i return when user request file which doesn't meet his requirements

i have a case where user can filter and download multiple pdf documents merged into single file. The client should display an error message when no document's meets the filter, and ask for ...
-2
votes
1answer
122 views

When writing code to consume an external API, should you default to production or testing?

I'm currently writing some code to interact with an API that doesn't have any official libraries. The provider has given me two sets of credentials - one for testing and one for production. I'm ...
0
votes
2answers
46 views

How to cache duplicate fetch and save calls that are fired within the same second

I have a service which provides an endpoint that fetches from another service, saves, and returns an record. Here are the details: The caller calls the endpoint using an identifier (say a customer's ...
0
votes
1answer
82 views

Should an http API client hide the http response object?

I'm using a client library for an HTTP API. The client exposes objects and methods matching the domain, e.g. Api::Document.download, but the return value is just the http response from the API. As the ...
-2
votes
3answers
332 views

RESTful API User Accounts

I'm trying to expose RESTful API endpoints for creating user accounts to access my API. So, this would be one of the first things my consumers would use. I'm trying to figure out if this is how I ...
1
vote
1answer
63 views

Correct format to receive datatime data from consumer

I am working on a service in a sprint boot microservice application. The consumer for my service can be another service, as well as a UI component. The are 5 entities in my service, each entity having ...
1
vote
1answer
48 views

Securing API with JWT and elevated access using MFA

At my company we have a central auth server running IdentityServer. There are a number of applications providing some API to client applications. API requests are authenticated with JWT tokens issued ...
2
votes
0answers
30 views

Reading (GET) Facebook Ads From Ad Library and Reading (GET) Personal Ad Account Billing Data in my Android Application

I'm trying to create an android application for personal use to do the following: Get ads from the Facebook ad library (commercial ones) not the ones with politics topics etc. and then insert them ...
-1
votes
3answers
75 views

best practice posting complex object to api

i am trying to figure out what is the best practice on doing POST calls when creating new complex objects. example assume this is the complex object i wish to send: { "firstname": "...
1
vote
1answer
73 views

Consuming complex JSON service that does not have schema

Hi I have this weird situation where I have a JSON producing service that represents a very complex object graph and this bject graph does not have a JSON schema that it is based on. The reason for ...
1
vote
1answer
71 views

How to manage huge chunks of validation data inside a REST API

TL;DR What are common practices to separate validation logic inside a rest API & thereby keep the code clean and straight forward? (code example) Context & Example Let's say I'm developing a ...
-1
votes
1answer
46 views

How to design API endpoints for resources that relate on eachother?

I am developing REST API using node.js and Express. I have Houses collection and Rooms collection. Every Room belongs to exactly one House for it's entire lifetime. I'm not sure how to design API ...
1
vote
4answers
93 views

Replace Rest verbs with custom object to drive resource operations

One of my clients has a Restful API on which I'm supposed to work on that only exposes two verbs: POST and GET. The POST endpoint is used in lieu of the standard Rest verbs: PUT, DELETE, PATCH. The ...
0
votes
2answers
67 views

Structuring optional REST resource hierarchy

I am designing a REST service with multiple end points which will be servicing the following hierarchy: Department has many Category Groups Category Group has many Category(-ies) Category has many Sub-...
21
votes
9answers
6k views

Declaring that a function never returns

If I have a function that never returns (it contains an infinite loop) how do I declare/communicate that it will never return to the user of the function? The user does not see the source code, only ...
1
vote
1answer
84 views

REST : Static API design

Lets say, I have a scenario where I have to expose an api to fetch supported shirt sizes(small , medium and large) My initial thought was /v1/shirts/sizes - But this clashes with the existing fetch ...
3
votes
1answer
165 views

Where should the circuit breaker go?

I'm developing a new REST API and I've seen some projects place the circuit breaker in the Controller. I used to place it in the DAO. First difference I can say is that placing it in the DAO is that ...

1
2 3 4 5
19