How many HTTP status codes should your API use?

There are a lot of HTTP status codes. At the time of this writing, Wikipedia lists 75 different status codes, most of which you’ve probably never encountered. Many of us have heard of the tongue-in-cheek “418 I’m a teapot,” but very few are familiar with these:

  • 205 Reset Content
  • 300 Multiple Choices
  • 419 Authentication Timeout
  • 450 Blocked by Windows Parental Controls

Most API providers stick to a rather small set of status codes, which they list in their documentation. Facebook’s Graph API takes this to the extreme;

Read more

JSON in URLs

HTTP-based APIs often encode arguments as URL path and query parameters. For example, a call to the Dropbox API’s filename search endpoint might look like:

While URL encoding seems fine for simple examples, using JSON might have some advantages.

URL paths are complicated

In the example above, the first “+” is a literal plus sign because it’s in the URL. The second “+” represents a space because it’s in the URL query component. It’s easy to confuse the two since the encoding rules are mostly the same and sometimes the library functions are name something ambiguous like “urlencode”.

Read more

Limitations of the GET method in HTTP

We spend a lot of time thinking about web API design, and we learn a lot from other APIs and discussion with their authors. In the hopes that it helps others, we want to share some thoughts of our own. In this post, we’ll discuss the limitations of the HTTP GET method and what we decided to do about it in our own API.

As a rule, HTTP GET requests should not modify server state. This rule is useful because it lets intermediaries infer something about the request just by looking at the HTTP method.

For example,

Read more

Swift apps with Dropbox

Update: The Sync and Datastore SDK has been deprecated. Learn more here.

Swift is a new programming language for iOS and OS X with a modern syntax. Swift is fast and powerful and it’s easy to see why Swift is gaining popularity amongst developers.

We’re happy to say that you can use any of the Dropbox SDKs for iOS/OS X in your Swift app. Let’s take a look at using the iOS Sync SDK in Swift.

Importing the Dropbox framework

To get started, you’ll need to follow the iOS Sync SDK installation instructions.

Read more

Debug your Dropbox app with app error logs

EDIT [2015-04-20]: App error logs are disabled for now as we retool the infrastructure behind it. We hope to bring them back in the future!

Imagine a world where you can respond to bugs before your users even have a chance to report them. A world where debugging is simple, customers are satisfied, and sleeping soundly at night is possible.

Is this world even possible?

Yes.

The new app error logs enable you to view API errors that your app encounters, allowing you to debug issues as they arise.

Read more

Using the new local datastores feature

Update: The Sync and Datastore SDK has been deprecated. Learn more here.

The Datastore API 3.0 release includes a new preview feature called “local datastores.” Since we first released the Datastore API, developers have asked us how to deal with users who don’t have a Dropbox account. With local datastores, the same code can work regardless of whether the user has logged in with Dropbox. If a user hasn’t logged in with Dropbox, all data will just be stored locally. Once a user has logged in with a Dropbox account, data will be stored in the cloud and synced cross-device.

Read more