Questions tagged [api-design]
API design is the process of determining and exposing a set of consistent method signatures, return values, and documentation intended for use by other developers to allow programmatic access to data.
2,077
questions
-1
votes
0
answers
29
views
How to Rate Limit existing XML based API without much code change at client side
I need to rate limit a live XML based API implemented in Android SDK.
The SDK is already live and multiple clients are using it.
Hence I need to design a solution which will require minimal OR no code ...
0
votes
0
answers
25
views
What should my parameter type be for a REST API service using Prisma ORM and typescript?
Prisma Model
model User {
id Int @id @default(autoincrement())
name String
org Org @relation(fields: [orgId], references: [id])
orgId Int
...
-1
votes
0
answers
35
views
Using Optional inside helper method vs outside [duplicate]
I have a couple of design questions? It is more readable to use Optional inside a helper function vs outside it? Is it better to use many Optional in code vs exceptions?
I personally feel that too ...
0
votes
2
answers
25
views
POST or PUT instead of DELETE when delete is blocked at web server
We have an crud API developed with POST, PUT, DELETE and GET methods supported. We have since discovered that DELETE is blocked at web server level in our organization so any requests to the API for ...
0
votes
1
answer
34
views
What is the best practice to write an API for an action that affects multiple tables?
Consider the example use case as below.
You need to invite a Company as your connection. The sub actions that needs to happen in this situation is.
A Company need to be created by adding an entry to ...
0
votes
2
answers
36
views
What's special about deflateInit2 that prevents deflateSetHeader be used with deflateInit?
I'm trying to learn how to use zlib functions in my C language project. I need to support both RFC-1950 zlib format as well as RFC-1952 gzip format in my application.
To use gzip format, the ...
0
votes
1
answer
31
views
Message validation for async messaging systems
I'm looking for the best approach as to how I can go about doing validation of a message as its enqueued in async messaging based systems.
Scenario:
Let's say we have a two services A and B where they ...
0
votes
1
answer
21
views
HTTP status code for GET requests when entity is corrupted
How should servers respond to GET requests for corrupted entities?
Let's say I have a Person schema
Person {
firstName: optional string
lastName: required string
}
And due to an issue in the ...
1
vote
1
answer
51
views
integrating user management between two or more laravel systems
I am developing a helpdesk ticketing system for my main website, and I'm looking for best practices to integrate the userbase.
the ticketing system should work as an external system and in the future, ...
0
votes
0
answers
23
views
OneLogin API List users from a CSV list to get their IDs
Trying to use Postman with the OneLogin API to remove the license of users who are no longer with our company, as we didn't have this automated in until recently. Even with the automation we are ...
0
votes
1
answer
48
views
Associate methods of an object to API URL routes with Python Flask
I want to associate a few methods of a (real world) object to Flask URL routes:
class Door:
def __init__(self, location):
pass
def open(self):
pass
def close(self):
...
0
votes
1
answer
23
views
Paginating API error (Nested 'next' link)
I am trying to build a class to automate requests to our suplier, but i am having trouble with pagination.
This is the working snippet so far, but the api limits the request to 1000 records, and if ...
0
votes
1
answer
87
views
REST API filter queries - handling OR operations
I am trying to create a nice helper class to parse some query parameters so they can be used to filter an array of data.
I am using the following syntax for my query parameters:
?filter[name,contains,...
0
votes
1
answer
24
views
What should the response status code be in a REST API when the given ID is a valid ID but there's no matching document?
I'm using MongoDB for my Express app and I know that when an ID is an invalid ID for the corresponding database, the response status code is 400 (Bad Request). But what if the ID is a valid ID but ...
0
votes
2
answers
46
views
REST: handling nested resources and paths
I have three resources, owner, dog, and puppy and I am designing the REST endpoints for the puppy. I already know who the owner is with every request via JWT authentication, so I never need to expose ...
0
votes
0
answers
14
views
Where to place dbGetQuery in R API?
I have made an R API with the package plumber for the first time. I have a main.R script, a plumber.R script, a controller_main.R script, and five service scripts where the main calculations take ...
1
vote
2
answers
66
views
What is the correct way of adding parameter to ignore case for search text in a REST API
I have an API endpoint to retrieve all users. There are 3 query parameters for searching/filtering the results as follows.
GET /users?name=test&age=23&area=abc
Now I want to introduce an ...
0
votes
1
answer
40
views
How to specify subtypes of some resource type in a RESTful API?
(Couldn't find a tutorial or clear description of this in guides like REST API Tutorial and StackOverflow's blog on REST API best practices, and a SO question on subtypes discusses another angle.)
How ...
0
votes
0
answers
31
views
Can you access a parent field from a child object in Django?
tl;dr: I want to express something like [child.child_field_value, child.parent_field_value] on a Django child model and get an iterable like ['Alsatian', 'Dog'] or similar.
Context: I'm trying to ...
0
votes
1
answer
15
views
light request version in sqlalchemy
I have the following models:
class Parent(Base):
__tablename__ = 'parent'
id = Column(Integer, primary_key=True)
children = relationship("Child", backref="parent")
....
-1
votes
1
answer
33
views
SQL Association Count Best Practice
Imagine I have a Parent.hasMany(Child) relationship, if I have an API to query a Parent but also need to surface how many children this parent has, I have 2 immediate options:
Run a query on COUNT(...
0
votes
1
answer
23
views
Should login and get profile be two different api endpoints?
I am designing api for mobile application.
I am not sure should I have one endpoint login which will return tokens & user profile
Or have two endpoints and after login call getProfile endpoint.
I ...
0
votes
0
answers
125
views
Discuss - How to make an application registration and OTP generation/verify service to be RESTful
We are developing a portal application where an already existing customer can register their account to see the details of their account (something like you have a credit card and then you register on ...
0
votes
0
answers
36
views
How should an API gateway handle a slow microservice when scaling
I'm in the process of creating a kubernetes application. I have one microservice that performs an operation on data that it receives.
My API does some basic authentication and request validation ...
0
votes
1
answer
33
views
How to correctly pass return of one method to another in JSON-RPC in one request?
I'm making typical JSON-RPC API (based on json-rpc Python library) for the serverless E-Commerce site.
I want to register users when they are ordering something. And I'd like to do this in one request ...
1
vote
1
answer
85
views
Should I use the existing websocket connection for request/response operations?
I'm designing a game that makes use of websockets for realtime communication of game moves and chat between participants.
I also need clients to make metadata operations, such as:
create a new game ...
2
votes
1
answer
137
views
Subdomain for Laravel Rest API not working correctly - IONOS using Plesk
I've got a VPS with IONOS (was 1&1) and running Plesk Obsidian and I am up to date using Laravel 9. Now I've hit a snag, all I want to do is add a simple subdomain :-
api.trolleyspotting.fun
So ...
-1
votes
1
answer
34
views
Best practice of Read-Modify-Write Rest Api Design
I have a restful api to update the bunch of objects on the server side. For example, I have an object like this:
{
counter: int,
bit_mask: int,
other_value: string,
}
on the client side, I want ...
0
votes
1
answer
70
views
What is the best practice to design a phone number field for API payload?
Among the following two payload structures, what is the best practice and why? I have searched a few services that has phone number fields in their payload, but I got a fifty-fifty result. Some use ...
0
votes
1
answer
145
views
Designing POST response body for different types of responses
From my client application I make a POST call to a \validate end-point. This call is made to execute the controller on the server side and not to create any resource. In response, server can provide ...
0
votes
2
answers
29
views
Where to place the resource root id in the url?
I have resources linked like this:
A->B->C->D
I want to design a REST API to retrieve the D elements inside of A
Which is the best design approach?
api/v1/A/{a-id}/D
api/v1/D/A/{a-id}
api/...
0
votes
0
answers
18
views
How to change resource way , to support multiple future instances in Raml like city and airport?
/{ca}/{en}/{v1}:
uriParameters:
ca:
description: Country of users have to specify with two letter country code.
type: string
required: true
minLength: 2
maxLength: ...
1
vote
1
answer
44
views
What is the point of encrypting user passwords on the frontend?
I'm working with an API that requires the user's password to be encrypted with the server's public key before sending to the server. If the whole request, including username/password/etc. is being ...
0
votes
1
answer
24
views
How to structure a microservice management layer calls
I am building a microservice that will have a management layer, and another corresponding microservice for a public api. The management layer's client will be imported into the api service as well as ...
2
votes
1
answer
47
views
Approach on API/System design
I was watching a video on "Design Uber api mock interview".
for most of the APIs, the candidate just used "userId" and left on the system to resolve "rideId"
Example - ...
-1
votes
1
answer
25
views
www-form-urlencoded string parameter not recognized in API communication
It is difficult to give a reproducible exemple, I summarise here the main components:
We have a front-end/back-end system on an ubuntu 18.04 server.
The client side is a web plateform where users can ...
0
votes
0
answers
74
views
Proper API calls and server-side data storage - Blazor
I'm trying to learn Blazor while bringing some of my ideas to live as I think that the best way to learn is by practice. I want to build a card viewer for CCG (collectible card game) and I've stumbled ...
0
votes
1
answer
72
views
Handle external API calls inside an api
I have a simple HTTP server where you can create and manage todos. You can also add plugins in order to, for example, send an email to the people who starred a todo when that todo has been completed. ...
0
votes
0
answers
20
views
appropriate error handling within abstraction layers/apis
If i have a class that contains basic functions that return errors and do nothing else then i have an api that makes those functions easier to use. I then use that api within my main program, I want ...
1
vote
0
answers
27
views
Enabling debugging content in REST API responses
I'm designing a REST API. I'd like to provide to API caller optional debugging information in responses (e.g. execution times of some activities and internal details).
Let me give you an example of ...
0
votes
0
answers
32
views
Designing large GraphQL APIs: group fields?
Let's think about some sufficiently large project with a GraphQL API. Suppose, it has about a hundred mutation fields.
Flat
We can put all these fields (semantically, methods) to the top level:
type ...
0
votes
1
answer
81
views
API best practices for batch operations [closed]
We have a requirement to develop an API with CRUD operations that supports batch inputs for each of create, read, update and delete operation.
For ex.
Request for "Create" will be an array ...
0
votes
0
answers
26
views
System API design - questions
We're designing a new service orchestrator which will provide a multi-staged flow for the user and will be communicating with several foreign services internally.
I'm preparing API for it and I have a ...
0
votes
0
answers
64
views
REST: how to handle partial success for atomic endpoints?
I have an endpoints that does multiple critical tasks, and if a latter one failed I need to handle the previous successes.
Here is an example:
Task A
Task B
Task C
Save to DB
In the above scenario, ...
0
votes
1
answer
115
views
Should we abbreviate REST-API endpoints?
I'm wondering what I should do about this REST Api Endpoint: /api/events/<event_id>/instances/<instance_id>/positions
Basically there are events which can have instances and those ...
1
vote
2
answers
297
views
.Net Core Web API undocumented 204 Response
I am trying to create a .net core 6 Web Api that calls Microsoft Graph on behalf of what amounts to be an eventual Vue.Js client end user (with office 365 account and Azure Active Directory Registered)...
1
vote
0
answers
37
views
RESTful resource creation in multiple steps
There are situations where resource creation requires more than one step.
Example
A session resource is created when a user authenticates. So the API call responsible for authentication would be a ...
0
votes
1
answer
221
views
How do I make API call for city name instead of zip code?
I am utilizing API calls from https://openweathermap.org/current
As of now, I have a program that displays the weather after a zip code is inserted. I want to change the program to display weather ...
0
votes
0
answers
29
views
node js api design and waiting for long process excution
I have 2 tables
pin codes - list of pin codes [lets take 5000]
addresses - corresponding addresses-from an API
I want to write an API like '/update-addresses' by using Node Js
After updating the ...
0
votes
1
answer
64
views
What's the best practice for a similar API called by Client vs User authentication
In a situation where you want to get user info from an api, and you may be calling as a User (end-user) token or a Client (owned service) token, is it better to have separate endpoints, or to share an ...