Stack Exchange Network

Stack Exchange network consists of 174 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
0answers
14 views

Preferred method signature for API method involving DB interactions

I recently got into discussion about how the method signature should look like for an API method which doesn't expose internal objects used by application to caller. Here is how situation looks: Our ...
1
vote
4answers
123 views

User calling REST APIs on behalf of a different user

Here's an example: GET /posts POST /posts GET /posts/{post_id} PUT /posts/{post_id} This api is being used by SUPER_ADMIN as well as CONTENT_WRITERS. Its working great. If user is logged in as a ...
-2
votes
0answers
22 views

Angular 6 should create separate app or separate module for admin dashboard if the app is big?

I am currently working on a angular 6 project to create a website ( a company website ) with following features Website which act as a company website + Online Store with landing pages where ...
-2
votes
1answer
56 views

Python API Design for workload automation software

I want to expose APIs in python for my workload automation software. I have a Job class as defined/outlined below. Instance of this job class represents a particular Job run. Job can have multiple ...
5
votes
4answers
184 views

Information Hiding v.s. Static Type Safety

I'm working on a project with others and we have a discussion about information hiding and static type safety. Our scenario is described below. Language: C++11 Scenario: We want to create a tree-...
1
vote
2answers
75 views

Is passing an ErrorMessage to be populated inside the receiving method an anti-pattern?

I come from a Java background, and my colleague is from .NET. We are working on a Java project and I saw him create a method like this: public Object myMethod(Object[] param1, ErrorMessage ...
-1
votes
1answer
26 views

Measuring the usability / ease of use of RESTful API in Mobile Cloud Computing?

APIs vary in their complexity, functionality and also usability. In Mobile Cloud Computing (MCC) applications, which are mainly mobile applications that offloads processing / storage to the cloud, ...
1
vote
2answers
107 views

Is it RESTFul for an endpoint without a path parameter to always have a single resource as a result?

While creating tools for an api, I've noticed the following inside the api specification: GET /cookie-orders returns the following structure as a 200 result: { "first":true "last":false ...
0
votes
0answers
42 views

Do you aggregate your APIs into a single FQDN?

Currently we have one API running on server1.example.com, and though we'd publish the API behind our load balancer using a dedicated FQDN like this: api.example.com/cars -> server1.example.com api....
0
votes
1answer
53 views

Is there an equivalent to HTTP status codes for WebSockets messages?

I'm developing a WebSocket API and I was wondering if there was either a standard or best practice for responding to client messages. For example, if my API is expecting only stringified numbers but ...
2
votes
1answer
55 views

What to choose, ioctl-like interface or a set of distinct methods?

I am implementing a messaging protocol between nodes on a network and i am wondering how to expose the messaging system interface to the programmers. The messaging protocol supports a set of commands ...
0
votes
1answer
44 views

Check or not objects in a Javascript API?

I'm writing an API in JavaScript, and I'm confused whether or not I should check if the API user is passing me the correct type on which the API expects to work. Actually not the type, but if you are ...
0
votes
1answer
47 views

Fastest way to return a list of records depending on many many-to-many relationships

I'm developing an API in Rails and the following requirement is established (it's really more complicated, but I want put a simple example): There are users and messages. users have a gender (...
0
votes
1answer
56 views

What HTTP action and return value should be used on resource's action

I have a question about how I should implement a new action for a resource on my API layer. I have a Timesheet which is used by people to let us know how many hours they worked on a job. This ...
1
vote
1answer
36 views

Repository pattern, call another API that updates a SOR's from service or repository class?

We are working on API's that call other API's that will inevitably retrieves/update a system of record like an SQL, MySQL or other database. Sometimes we'll have 3/4 layers of API's before the SOR is ...
0
votes
0answers
31 views

Using the API provided by a class internally

I've implemented a class with a __getitem__ method to allow users to access some data by its key in a dict-like way, i.e. obj["key"]: class A: def __init__(self): self.data = [] def ...
2
votes
0answers
67 views

Is “equivalent” functions / methods readability worth its maintanability cost?

First of all, I am sorry if it is a duplicate, I could not think of any "correct" wording to search about this. Second let me clarify: By "equivalent" I mean methods that are meant to have the same ...
2
votes
5answers
334 views

In a REST API, should you correct user input on server side?

We have a REST API with an endpoint accepting JSON data from the client. One of the JSON fields is a URL that will be rendrered to other users as a hyperlink to a website page associated to the ...
0
votes
2answers
114 views

How to handle state of an object? And how to enrich the state transition logic?

I am designing a class that has a state. I wonder if I should expose that state in the interface in view of allowing a decorator to enrich the state transition logic. Shall my design expose ...
-2
votes
1answer
40 views

Should API also authenticate users from front end app?

I am building an API using Laravel and am looking at using Laravel/Passport for authentication - but I am struggling with a design decision. The API will be consumed by multiple other applications / ...
6
votes
3answers
401 views

What reasons are there AGAINST using only POST HTTP verb in an API?

I am researching before starting to work on an API for a web-service I am building. The goal is to be very quick and easy to adapt and use for other developers but fairly hidden for clients using a ...
1
vote
2answers
90 views

C++ - Is it a good idea to make separate headers as API?

Let's say I have a library code main.cpp, where are 3 classes implemented: Inner1, Inner2 and Outer. Inner1 and Inner2 are only being used in main.cpp and they're not going to be used anywhere else. ...
0
votes
1answer
66 views

Dealing with child collections updates in Web API

Let's take some classic enterprise example: Order and OrderItem public class Order { public Guid Id { get; set; } public ICollection<OrderItem> Items { get; set; } } public class ...
0
votes
0answers
39 views

What goes in the meta attribute in an API

I am using the JSON:API standard to write my API: http://jsonapi.org/ An example is as follows: { "data": { "type": "offer", "id": "1", "attributes": { "title": "50% off!", ...
0
votes
2answers
83 views

Support multiple request formats for single REST endpoint

I'm building an REST API that exposes a callback method for a 3rd-party service. Let's imagine that there are two similar (but not identical) 3rd-party services. They both call back my API (POST /...
1
vote
1answer
40 views

Board support driver for custom board - API design - MCU resource configuration

I have got to implement a board support package for a custom board, and I would like to know your opinion about the different approaches of designing board support drivers. My custom board pupulates ...
0
votes
2answers
37 views

Best practice for getting a resource in many different ways?

An example of this problem: I'm writing a function allowing a user to find a student by their studentId, so I create the function: GetStudent(int id) or GetStudentById(int id) Then the users want to ...
0
votes
1answer
50 views

An options parameter vs chained functions for object initialization?

What concrete objective advantages do chained functions have vs an options parameter for object initialization? What do I mean? Well as one example there's a library called dat.GUI that uses the ...
1
vote
3answers
116 views

Designing a REST API with resource relationships?

I'm working to design a REST API to be consumed by a React SPA. The client-side of the SPA queries data about a relationship between two entities: Team and Player where Teams have many Players and ...
0
votes
0answers
32 views

API Caching strategy for user favorites

I am working on a music web app (api/SPA), and the following is the response form one of the API endpoints. It returns song information that looks like the following. This would be the result of ...
-1
votes
1answer
34 views

With a Web API, list of objects or dictionary with list?

Sorry if the question is worded badly, I couldn't think of a short way of explaining it without examples. My question is if you are hosting a JSON API, which is better: [ { "name": "Foo", "...
3
votes
1answer
71 views

Future/Promise objects in Controllers - Best practice - MVC

I was going through some articles related to Futures and Callables today and was thinking about the best practices when working in an MVC based environment. I was wondering, should one be creating ...
1
vote
0answers
22 views

What are some design ideas for a data mapping and transformation application?

Here is a high level outline of the project: We frequently need to convert data from a new incoming system to our in house system (sort of a basic ETL process) We would prefer to do this dynamically, ...
3
votes
1answer
107 views

How to deal with friend requests in social API REST

I'm designing an API that a social network app will consume. I need to manage friend requests between users. I have this endpoint: POST /users/{userId}/friend-requests { requesterId: string } ...
0
votes
1answer
84 views

API Design - User Management

I work for an ecommerce site and we are looking to expose much of our core functionality via a set of APIs. We plan on re-writing some of our own public facing websites (e.g. the main shop website) to ...
-1
votes
1answer
64 views

APIs: Many minimal ones or a few bigger

I'm currently working on a project/product which consists of ~60 REST APIs and one client (Web app) I find many downsides on this design, and not so many benefits, and I'd like to know if this is ...
0
votes
1answer
101 views

Professionalism of implementing the HTTP “QUERY” method in an API

Some years ago, the w3c documented a proposal for a method called QUERY, where query information may be passed in as the request body rather than on the request line in query parameters. You can see ...
2
votes
1answer
40 views

recommendations regarding resource uri

lets say we have a "door api" and I want to create a resource to close the door. I could do this in 3 ways: traditional way using PUT with payload {id: XX, color: YY, closed: true} advantages: ...
0
votes
2answers
55 views

RESTful API authorization for updatable fields

I've got a resource as follows where state is a enum: { id: 123, industry: { id: 245, name: "Farming" }, "scheduleDate": "2018-01-01", "state": "Requested|Approved|Standardized|...
2
votes
1answer
51 views

Dependency management for facades/adapters to cloud services (SemVer?)

Suppose I have a library, that basically works as a facade to some cloud service (e.g. JavaScript API that wraps around network calls to some RESTfull service). And once that service introduces a ...
2
votes
1answer
77 views

Web API: REST-ish pattern for flexible querying of time-series data

I'm working on a product that exposes a RESTful API to interact with system entities (the usual CRUD), which works very well. In addition to CRUD, we've recently encountered a need to expose the ...
-2
votes
1answer
68 views

Should I use a strongly typed programming language for an integration with a JSON RPC 2.0 API?

I have to integrate with another company's API, which they unfortunately decided to write in JSON RPC 2.0. If you're not familiar with JSON RPC, it's a lightweight RPC protocol that defines a ...
0
votes
0answers
93 views

Compute and assign value to an attribute during class instantiation python

I am new to OOPs and don't have software engineering/computer science background. I am trying to define a class where I want to compute and assign a instance attributes under def __init__(): as ...
-1
votes
1answer
103 views

API gateway for web-fronted applications, is it worth it?

So am in the process of developing a new application and am welling to adopt a micro-services based architecture (am new to that). The problem is that the application will be exposed to the final ...
2
votes
1answer
40 views

Gradle/Java separation public private API

I have a project that has a public API and an internal code. The public part is published on MavenCentral. I thought about making a package each, but everything from the 'internal' package that ...
1
vote
3answers
177 views

HATEOAS APIs and front end development

We are developing a tool from scratch based on a Spring backend and VueJs frontend. I am primarily working on the backend and came to know about the HATEOAS principle of developing REST APIs and ...
48
votes
10answers
9k views

What should be the http status code for “Service not available in your area” error?

Our service is in 5 cities right now. If someone tries to call our service API from any other city, we want to throw this error Service not available in your area. The question is, what is the ...
3
votes
1answer
85 views

API design and storing custom queries from Db to cache

I was thinking about how people actually implement utilising results from a cache before a doing database lookup. When designing an API, should there always be a manual check to the cache first before ...
1
vote
1answer
45 views

Determining tenant for anonymous multi tenant api endpoint

I'm in the process of building a new api that needs to support multi tenancy. I can figure out how to implement reading and writing the data securly without having to worry about clients being able ...
1
vote
0answers
38 views

API Architecture Decision on Authorization & Validation levels

We are designing an authorization mechanism for a Product API where users have their own claims. The api has a patch request like this: PATCH https://product-fcd.com/api/product -d {"Products": []} -...