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
14 views

Design pattern - update join table through REST API

I'm struggling with a REST API design concept. I have these classes: user: - first_name - last_name metadata_fields: - field_name user_metadata: - user_id - field_id - value - unique ...
0
votes
1answer
68 views

How to authenticate against an API?

In a enterprise distributed system, a user of a web portal can sign into one site, be redirected to a federation provider. Once they log in with, for example, a facebook account, that user is ...
2
votes
3answers
65 views

Recommended HTTP status code for “plan limit exceeded” response

I'm designing a REST API for a project where users are always on one of several "plans" - each plan defines some resource limits, such as the max number of users an account may have or the max number ...
2
votes
1answer
33 views

Status transitions with extra information in RESTful interfaces

How would you design a REST interface that triggers a status change of an object, but requires additional properties in that moment? For example, the deliverer of a package needs to change the status ...
1
vote
1answer
28 views

Combining simple and complex APIs in a web application?

We use C# MVC and Angularjs as the primary tools to develop our web applications. We've recently been discussing best practices, with an eye towards revising our development approaches into something ...
2
votes
0answers
42 views

How to handle complex calculated fields in an ORM

In our API we've got a few central datatypes which need to be "decorated" (so to speak) after retrieval from the database with calculated values. The database is accessed through an ORM which follows ...
5
votes
3answers
92 views

REST API: Resource Ownership

Let's say there are Users and Pets. Each Pet has a single User as its owner, and a globally unique id. Endpoints could be /users/1/pets/2 /pets/2 I feel like the first option could be unintuitive ...
216
votes
13answers
32k views

Should you write your back-end as an API?

I had a heated discussion today about our MVC application. We have a website written in MVC (ASP.NET), and it usually follows the pattern of do something in the view -> hit the controller -> ...
1
vote
1answer
82 views

Correct approach for creating api contract

I need help regarding below: I am trying to design an API. For creating contracts below are the two approaches: Approach 1: public class MyController { public void MyAction1(Dictionary<string, ...
2
votes
2answers
43 views

WCF service with methods to fetch data

I'm planning on building a WCF service that will fetch data entities from a Sql Server database. And I'm currently struggling with best practices issues. The thing is that there's a few different ...
0
votes
0answers
21 views

Segmenting JSON API with subdomains

I am in the process of designing an API for a web service that I an building. The architectural style of the application is a coarse grained SOA. One thing I have thought to do was to break the api up ...
0
votes
0answers
23 views

API Architecture

I have a Laravel web application. Imagine if our company has many customers. Each customer has one or more addresses. Each Address can have multiple fences and each fence has points which define ...
0
votes
1answer
46 views

Api for CMS And Mobile applications either separate or same

I would like to ask an architect based question What is more secure and most standard way to follow.For let's say a mobile application, Should the Api for mobile interaction with server be ...
2
votes
5answers
102 views

Are there any downsides for the same API to perform two slightly different functions?

Take for example the following two GET requests with slightly different arguments: ../user/login_at which returns the last login date of the user, and ...
3
votes
1answer
108 views

null vs missing key in REST API Response [closed]

Say in my application, some users give us their last name, and others do not. In a REST API response, which body is preferred: With a "null" value: {"firstName": "Bob", "lastName": null} Or just ...
1
vote
1answer
90 views

REST - Recommendation route: POST or GET?

I'm building an api route which will pull data from our server. This data is sorted in an arbitrary (changing and unknown to the client manner), and will never return the same data more than once. ...
0
votes
2answers
83 views

How should an API or server respond when a device connects with a different account than it is bound to?

In my system we have users accounts and user devices. Rules: A user can have only one user account. Each user can have many devices. A device can be bound to only one user account. Upon initial ...
0
votes
1answer
39 views

API authentication with a single ID

A typical API authentication usually rely on a pair of API ID + SECRET, my question is: if the API ID is unique and randomly generated and is considered strong enough (e.g. SHA512), why a SECRET is ...
1
vote
2answers
116 views

When writing a library or an API, when should and when shouldn't I validate or automatically correct errors in data provided by another developer?

I have a fairly good understanding of when data validation should and shouldn't exist when it comes when writing an application that is only dealt with by an end-user, and all the different tiers of ...
6
votes
3answers
126 views

REST API design: POST (implicit userId) vs PUT (explicit userId)

For some routes on an API, like GET /news, one would asume the user only wants news that pertains to them, so the userId is implicitly taken from authentication info. However, some of the routes on ...
1
vote
1answer
67 views

Design consideration on JSON schema for an API

I have an API endpoint that retrieve data from 3 SQL tables on the server-side. At the moment, I do a SELECT with joins, consolidate/reorganize the selected data based on a JSON schema, and then send ...
2
votes
1answer
83 views

How should pagination allowing links to arbitrary pages be handled in a RESTful API?

How should a RESTful API handle pagination in the situation where a client may want the ability to jump to arbitrary pages? Let's assume we are using the Link header in the way the GitHub API does: ...
5
votes
2answers
87 views

Partitioning REST API resources into areas based on business domains

In a major application REST API that covers several related domains, does it make more sense to split resources into 'areas' based on the business domain they belong to or is it better to to maintain ...
0
votes
1answer
41 views

JSON schema design for variable response

I am drafting a JSON schema for an API. One of the responses aims to show all the updates to different properties of an given entity. The number of updates may vary from one response to another. For ...
0
votes
1answer
66 views

API design for modular apps

Let's assume a web app made of independent modules: example.com/accounting example.com/employees example.com/admin Next step is adding an API which normally might end like this: ...
0
votes
2answers
104 views

Idiomatic C API with regards to pointers

I am trying to get a better understanding of how one would structure an API in C. I create a struct Person I have a init function that sets data on that struct I have multiple "helper" functions ...
6
votes
1answer
150 views

RESTfully Returning Diagnostics Data With Response

In a REST API I am working with, under certain circumstances (ex/ request originated in network) diagnostics data is returned with the response. Right now, a property is appended to the root object of ...
7
votes
1answer
222 views

Should I build undo stack in model or its wrapper?

I am building an application (Python/PyQt). The first-order item will be a tree view/model with many helper functions to add new items, move them around in the tree, etc.. Then I will have a main ...
3
votes
1answer
106 views

Is it bad to use POST only on an API?

I'm about to develop a new API for our website. Part of the design I've considered to use the POST and GET methods but after reading some security stuff I realise that GET is a bit less secure(i.e. ...
1
vote
1answer
66 views

REST API, nested routes without providing identifiers at every nested level

Obviously a RESTful API could contain base routes such as: api/competitions api/competitions/{id} api/teams api/teams/{id} api/players api/players/{id} And nested routes such as: ...
1
vote
3answers
69 views

Representing a “Belongs to” relationship in an API endpoint

Consider the following pseudo code models: class Post int Id string Title int CategoryId Category Category class Category int Id string Name Note that Post belongs to ...
0
votes
0answers
31 views

API Design when modifying resource data based on user roles (access levels)

I'm trying to figure out the best (and most RESTful) way to handle user roles in regards to the data returned. For example, for a resource named user, we only show obfuscated_id to regular users and ...
0
votes
0answers
45 views

Richardson Maturity Level 3. What about form input

In many ways RMM level 3 is similar to the world wide web we know where every resource is available with the click of a link. In www we have links, but we also have forms where a form with ...
1
vote
1answer
61 views

What is the idiomatic way in REST to handle field level permissions?

REST APIs conventionally expose resources addressed at the object level. While it's easy to do object level permissions using the appropriate HTTP responses, handling field level permissions is a bit ...
8
votes
6answers
763 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 ...
2
votes
2answers
148 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
56 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
64 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
105 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
75 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 ...
1
vote
2answers
1k 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
177 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 ...
1
vote
0answers
150 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
223 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
47 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
42 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
156 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
150 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
50 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
43 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 ...