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
0answers
31 views

Where can I find an API that can understand the meaning of queries? [on hold]

Freebase is neat. It has all I need but unfortunately it's shutting down. I'd like to use an API that can understand the primary types of the queries that I'm sending not only by processing its ...
0
votes
2answers
69 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
35 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
110 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
87 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
44 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
71 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
66 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
34 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
49 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
91 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
147 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
204 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 ...
2
votes
1answer
94 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
50 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
59 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
20 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
42 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
46 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
562 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
132 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
49 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
51 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
84 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
63 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
943 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
154 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
131 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
188 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
45 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
39 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
139 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
146 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
42 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
40 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
455 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
217 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 ...
1
vote
0answers
218 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
92 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
70 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
5answers
562 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 ...
1
vote
0answers
26 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
130 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
134 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 ...
1
vote
0answers
74 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: ...
24
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
203 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
166 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} | |_ ...
5
votes
1answer
490 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
100 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 ...