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

learn more… | top users | synonyms

2
votes
3answers
171 views

How do I recreate this Access Control/Group/ whatever methodology in OO/MVC

I am looking at trying to rewrite an application that is mostly procedural to an MVC/OO approach in order to teach myself a deeper understanding of both. BUT, I am having some conceptual issues with ...
21
votes
6answers
1k views

Why use an opaque “handle” that requires casting in a public API rather than a typesafe struct pointer?

I'm evaluating a library whose public API currently looks like this: libengine.h /* Handle, used for all APIs */ typedef size_t enh; /* Create new engine instance; result returned in handle */ ...
1
vote
3answers
174 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
1answer
37 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
67 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 ...
0
votes
1answer
67 views

Best way to design a database interface [duplicate]

This is my situation I have a website, mobile client and desktop client. They can all pretty much do the same operations (website might be able to do more now but in the future they might have the ...
0
votes
0answers
22 views

Should an API specification include roles?

I'm considering options for specifying an API in a code library (e.g., XML or JSON) that can be consumed by various clients. In addition to the standard kinds of input/output specifications, I'm ...
2
votes
1answer
385 views

Merge two different API calls into One

I have two different apps in my django project. One is "comment" and an other one is "files". A comment might save some file attached to it. The current way of creating a comment with attachments is ...
3
votes
2answers
267 views

Web Services and code lists

Our team heavily discuss the issues how to handle code list in a web service definition. The design goal is to describe a provider API to query a system using various values. Some of them are catalogs ...
2
votes
2answers
109 views

Restful User/Password Authentication

I'm currently designing a REST-API with the following properties: Backend for a single page application (Later Apps) Integrated user database for each instance HTTPS/TLS only Authentication with ...
1
vote
0answers
40 views

REST API Authorisation of HTML5 hybrid/single page applications

I am looking for some guidance on application level authorisation to a REST API. I am building the API (in Laravel 5) to serve an Angular.js single page application (and probably a HTML5 hybrid mobile ...
1
vote
1answer
96 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: ...
1
vote
1answer
141 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 ...
0
votes
0answers
36 views

Qt / C++ internal API design for slightly similar web services

in my application I provide a Qt/C++ wrapper to certain web services based on the Danbooru software. Basically the API wraps a series of REST calls and produces / parses the JSON responses to display ...
3
votes
3answers
91 views

Designing CRUD part of an HTTP API

This question is in the context of web based applications. A web server exposing an HTTP api for clients (e.g. running in a browser but not necessarily). Usually the web server would be connected to ...
2
votes
2answers
143 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: ...
1
vote
0answers
49 views

Securing a private API used by an iOS App

I have an app that uses an API server and I do not want to have anything other than it to be able to use that API. I know this isn't totally possible, but I want to do what I can. I don't think my ...
1
vote
1answer
770 views

Do I need to return error: null in JSON response?

When designing a RESTful API that uses JSON to respond to requests, I usually return an object like this when an error happens: { "error": "Something bad happened", "error_code": "XXX" } Do I ...
2
votes
3answers
137 views

Best practice for a REST-ful API where objects would naturally have a “/” in their identifier

I am designing a REST api for a document management system. To make the API more natural, I thought about using the natural identifier for a file, which is it's path (usually having forward slashes ...
1
vote
2answers
63 views

API with limits vs site crawling

I started working on a website,for tracking and rating watched anime/manga/etc. and recommendations, and it should also have an API, for providing the info about series and other things. On similar ...
1
vote
0answers
56 views

How to design an interface for two similar but distinct objects

I'm designing an API for a JavaFX control to be submitted to the ControlsFX library. This control is called the ViewManager, and its purpose is to hold a collection of View instances, all of which ...
2
votes
2answers
170 views

REST API Structure to request multiple items

I have a REST API that looks something like the below where a person can belong to an organisation (but doesn't have to) and a person has many items. The items may also belong to the organisation ...
1
vote
1answer
37 views

Accessing internal API via Internal DMZ

I have an API that for firewall reasons can't sit on an internal DMZ and has to reside on the internal network. It was suggested that I build a 'shell' API that basically has all the same endpoints ...
1
vote
0answers
34 views

Django API design

I recently followed the Django API tutorial. http://www.django-rest-framework.org/tutorial/6-viewsets-and-routers/ When I initiate a POST request my intent is that after inserting the record into ...
227
votes
13answers
35k 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 -> ...
0
votes
0answers
35 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 ...
2
votes
3answers
123 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 ...
10
votes
5answers
8k views

How best do you represent a bi-directional sync in a REST api?

Assuming a system where there's a Web Application with a resource, and a reference to a remote application with another similar resource, how do you represent a bi-directional sync action which ...
24
votes
3answers
2k 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 ...
5
votes
3answers
125 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 ...
2
votes
0answers
60 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 ...
32
votes
7answers
11k views

How do I convince my boss to use REST over SOAP? [duplicate]

We need to create an API to our system. How do I convince my boss that REST is a better option than SOAP (or XML-RPC)? I say REST is... easier to implement and maintain not much new to learn -- ...
2
votes
4answers
176 views

Should static parameters in an API be part of each method?

I am currently creating a library that is a wrapper for an online API. The obvious end goal is to make it as easy for others to use as possible. As such I am trying to determine the best approach when ...
0
votes
1answer
61 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 ...
1
vote
1answer
103 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
136 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
26 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 ...
2
votes
5answers
106 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 ...
0
votes
0answers
37 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 ...
1
vote
1answer
111 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. ...
7
votes
4answers
1k views

Best Practice: Should error messages be handled by the API or by the App?

I am designing an application that interacts with a RESTful API. When returning error messages like Unable to sign up user Should the error message be generated by the app? or by the API? I am ...
3
votes
1answer
358 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 ...
0
votes
2answers
92 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
43 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
124 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
188 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
0answers
186 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 ...
2
votes
1answer
122 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: ...
2
votes
2answers
167 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 ...
5
votes
2answers
116 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 ...