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

learn more… | top users | synonyms

0
votes
0answers
31 views

Make an android app “Re-configurable”

Story: I am the sole developer of an android app, which is the flagship product at my workplace. The app renders business workflow forms written in XML. These forms have simple structure and provide ...
2
votes
1answer
101 views

Many small requests vs. few large requests (API Design)

I'm currently working on a project with an organization as follows: Client - Gets data from the main server via REST api. Server - Requests data from various other servers via third-party APIs ...
1
vote
1answer
49 views

Technique to synchronize error codes in a same-project-API

In the project I am working right now, we have some python and some C# code. At some point, I call from python a subprocess which starts a C# executable. This C# code returns an error code, which has ...
0
votes
1answer
28 views

How to API design architecture for long delay process

Im trying to start an API design using Django Rest Framework, and the problem Im trying to solve is the following: Request endpoint is like this: POST http://server:8080/api/v1/device attribute: ...
0
votes
1answer
39 views

Why does this API include a static “kind” parameter in the request and response?

I am looking at the Google QPX Express API and noticed that each group of parameters includes a kind parameter that is set to a specific string. For example, on the request: { "request": { ...
0
votes
1answer
37 views

best way to export binary data with additional text attributes to a stream

I would like to create a command line API in a Java application to export a binary blob to stdout. I would additionally like to export certain attributes about the blob, ideally in a non-binary ...
1
vote
1answer
46 views

Do RESTful API controllers typically only provide resources related to their own type?

Let's say my API has the following routes: GET /theaters GET /theaters/:id GET /theaters/:id/movies GET /movies GET /movies/:id GET /movies/:id/theaters And then I have the following controllers ...
0
votes
2answers
309 views

REST API - Should API Return Nested JSON Objects?

When it comes to JSON APIs is it good practice to flatten out responses and avoid nested JSON objects? As an example lets say we have an API similar to IMDb but for video games. There are a couple ...
2
votes
1answer
138 views

Trying to process partial POST of data in REST when some data is successful?

I have a resource that accepts array of numbers. Each number is proceed interdependently, and computation fails are expected. How should I communicate to API client "some of your numbers couldn't be ...
0
votes
0answers
65 views

Web Api design - Using Nouns vs verbs

I have this design situation at work. We have a internal Web-Api application and a Asp.Net Web forms application(UI). The web-application is calling Web-Api to update a Contractor. public Class ...
1
vote
1answer
111 views

Does ORM at any point become a “requirement” for RESTful API?

I've started building a RESTful API in PHP's Slim framework. The framework appealed to me because of its light-weight design and routing features. I am using PostgreSQL for the database. However, ...
1
vote
2answers
39 views

HTTP status code for mobile clients

There was a debate with one of the platform engineers (as a mobile dev), about the codes being returned. The scenario is: when trying to create a resource the server is returning a 201 with the ...
1
vote
2answers
36 views

Using many Resource URI to create a Record and handling failure

Hi Guys, I have a decision to make to solve a problem, I’m describing the problem below. Application Overview I have an ASP.NET MVC 4 webApp which uses Rest Api for almost all the tasks, from Login ...
3
votes
1answer
117 views

Web API Design advice

I am developing a Web API as services layer for a ASP.NET web forms application. There are two controllers ContractorController (gives details about the contractor) and PaymentsController (gives ...
1
vote
2answers
132 views

Is it better to perform a calculation in the field's setter or have a different method?

I'm implementing a simple Quota object which determines a usage percentage based on the maximum and the used. private int maximum; private int used; public Quota(int used, int maximum) { ...
1
vote
1answer
28 views

Best way to keep consistent data in model across devices?

I have a model for an app that is fairly large, all of which needs to be on a users' device at the same time. For example, a spreadsheet. If a user makes a change to the model on one device, I want ...
1
vote
0answers
36 views

Individual methods or parameters for Google Analytics abstraction on Android

A coworker and I are having a discussion around the best way to build our abstraction on top of Google Analytics for an Android application. A couple of data points. We have auto-tracking enabled ...
3
votes
4answers
293 views

int * vs int [N] vs int (*)[N] in functions parameters. Which one do you think is better?

When programming in C (or C++) there are three different ways to specify the parameter in a function that takes an array. Here is an example (implementing std::accumulate from C++ in C) that shows ...
4
votes
1answer
152 views

Using macros to protect assignment to global variables

Because there is no language feature in C to protect assignment to global variables would you recommend doing something like this? Take this example: We have a module with the header file called ...
0
votes
0answers
187 views

How can I use protected Tastypie resources within Angular?

I have a working Django 1.7 project with an API (Tastypie) made available for mobile clients (ApiKeyAuthentication). I am using Angular with Chart.js, and so I need to GET some queryset using ...
3
votes
1answer
90 views

What is the correct way to publish a runtime? Should it be a singleton?

I have a compiler for a programming language that targets JavaScript. That language needs some global functions such as: alloc, memcpy, write and so on. My question is: where should I position those ...
2
votes
4answers
60 views

Handle server-side/client-side when for showing missing information as placeholders

I have a database table which stores Incident details. Each Incident can have an image saved for it. There are some Incidents which will not have an image for it. I have an API which pulls the image ...
3
votes
4answers
350 views

Why is the hashCode method usage of HashSet not specified in the API?

I was trying to debug my code which uses a HashSet and searching through the SO, I found out that I needed to override the hashCode method as well. The strange part is, checking the related API, I did ...
0
votes
0answers
22 views

Posting different-shaped json documents to the same resource in an API

Is it a good idea to create an API in such a way that clients can post different shaped JSON documents to the same Resource? Let me give you an example and and explanation to why I am asking this. I ...
2
votes
1answer
113 views

Should a web app for a service access its data via its own API or directly?

I'm building a service that will consist of mobile and desktop apps, which will require me to build my own RESTful web API to easily keep the data for the service in sync. I am also building a web ...
4
votes
2answers
116 views

Changing method signature while keeping backwards compatibility

I've inherited an API to maintain. Users can pass a callback function to the class which gets called on some event. The callback function is currently passed in a single argument. I need to change ...
0
votes
0answers
58 views

OO Design Question - Library/Objects for API which includes id references

Public api: getClients / getClientById - returns a json object like: { clientid: 1, name: "Client1" } getProjects / getProjectById - returns a json object like { projectid: 5, name: ...
22
votes
3answers
1k views

RESTful API: HTTP verbs with shared or specific URLs?

While creating a RESTful API, should I use HTTP Verbs on the same URL (when it's possible) or should I create an specific URL per action? For example: GET /items # Read all items GET ...
4
votes
3answers
181 views

How to safely chain several API requests for a single user

I am writing a web application with Python and Flask. At a high-level, the web service takes an ID, downloads a file from a third-party API based on that ID, reads and analyzes the data inside the ...
2
votes
2answers
128 views

How to deal with multiple “entry points” for an action in a REST API?

Let's say we have two kinds of resources, user and group. Every user can belong to multiple groups and each group can have many members. Thus I can model my API like this / |_ /users/{id} | |_ ...
3
votes
1answer
250 views

Why PATCH method is not idempotent?

I was wondering about this. Suppose I have a user resource with id and name fields. If I want to update a field I could just do a PATCH request to the resource like this PATCH /users/42 {"name": ...
0
votes
1answer
93 views

What should my RESTful API method look like for a Roulette game?

I'm building a roulette game for fun, and the game will use a RESTful API. I'm building out the functionality for spinning the roulette wheel. I'm using MongoDB and have a collection for players _id ...
3
votes
1answer
172 views

A “Composite API” layer

We are giving services a complete overhaul at work: Swapping soap for rest, resculpting the domains to give better separation of concerns, etc. These new services will be publicly available. During ...
2
votes
2answers
165 views

Designing an API with access tokens, how to handle GET requests?

I am building an API that will utilize access tokens so that I can track usage among various departments and for access control. My plan is to utilize the HTTP verbs appropriately - GET will retrieve ...
0
votes
0answers
39 views

Java API initialization step

I am developing an Android Library which involves both Network and Bluetooth communication. In order to start using the library it must be configured. In other words a request to the backend must be ...
0
votes
0answers
28 views

How to Handle Multiple Versions of a REST API [duplicate]

At an interview I was asked the following question. You are giving out a rest API and you know that there will be multiple versions of it. The API methods will remain the same across versions but the ...
0
votes
1answer
82 views

Sending multiple resources under REST endpoints

I am designing an API where- 1. There can be multiple devices under a gateway. 2. There are multiple sensors on every device. GET /devices/d1/sensors/s1 returns the status of sensor s1 on device ...
0
votes
0answers
23 views

Add new/modify existing callback to/in API

I am working on a common API for a user interface. My colleagues use this framework in all their projects, but the UI is not our main aspect here, so the knowledge of the UI framework is somewhat ...
0
votes
1answer
33 views

Migrating single-layer ORM based app to multi-layer API

I'm trying to understand what is the best way of migrating a website that works in a single layer and gets all the data via an ORM, to one that uses multiple layers, using an API backend to get the ...
2
votes
3answers
406 views

Which one of these would be the better way to implement object copying in c#?

I would like to be able to copy an object and only change a few values. I have come up with two different ways to do this. // OPTION A - create a copy constructor and use property // ...
5
votes
2answers
806 views

Why does java collections not supply a function for the index of max value?

I have been using Collections.max(list) for many projects, but I occasionally want to find the index of that maximum element. I feel silly writing a function to do this for myself in every program I ...
2
votes
1answer
152 views

Gradual reveal in REST APIs [closed]

In the article Building Web Services the REST Way, the author states: Design to reveal data gradually. Don't reveal everything in a single response document. Provide hyperlinks to obtain more ...
1
vote
1answer
114 views

WebAPI authorisation for other apps

I would like to create a WebAPI application that can serve some of my web sites. My goal is to abstract some common task such as email sending, address resolving etc by providing an API to all of my ...
3
votes
5answers
457 views

Storing a pointer to an argument passed by (non-const) reference

When designing an interface for passing objects which are meant to be stored for later use and which should not be 'null', I am always a bit uncertain if the argument should be passed by reference or ...
0
votes
0answers
85 views

API for accessing CTS and DSR signals of serial port

I'm trying to improve another abstraction of the serial port. The project involved often needs to check one of the single control signals CTS and DSR. This is currently done by a call to ...
-1
votes
1answer
45 views

API design: Giving the signin endpoint a noun name [closed]

Nouns are good and verbs are bad. HTTP codes + the endpoint /user/123 can signify user create, read, update and delete operations. But what should the signin and signout endpoint be called? How can ...
2
votes
3answers
145 views

Proper interface for calculator library?

As practice, I'm planning to implement a multivariable calculator library. The idea is that you can define a function, such as f(x, y) = sin(x)^2 + 3*y^3, and then you can evaluate it with specific ...
0
votes
1answer
361 views

REST API design for associations/aggregation

I am building RESTful API that manages persons and lists. There can be many List and many Person each with its own set of properties. Person can be in zero or more lists, List can contain zero or more ...
1
vote
2answers
392 views

Is RESTFUL API as back-end service one of the best (or suitable) choice for Mobile App? [closed]

I have a background on .NET development, recently I was asked to code back-end service for a mobile app. I had experiences on MVC, and now I'm trying to understand more on Restful Web API. My ...
0
votes
0answers
118 views

Single result as REST/ODATA response on GET

In an API which should be both restful and support OData for different client types. I have an endpoint that always returns a single result. Should I: Return the entity as a single entity? Put it ...