Tag api

APIs should have test error endpoints

Most of the time, when you start coding against an API, either with or without an API client, you end up producing enough errors that your error-checking is fairly robust. However, sometimes most or even everything “just works.” Which produces a conundrum:

You now have no idea how robust your error handling is (or is not).

As an example, that – ahem – may or may not have just inspired this blog post:

Say you are polling something to check for an update, every 60 seconds or so. If it fails, you want to know that and decide whether or not you should keep polling the endpoint. Everything works great. Until you get a 500 which you haven’t handled correctly (or there was a bug in your logging call or… something, ahem). Now you have an exception in your own code which breaks out of your loop independently of your API error handling. So your polling has stopped and you’ve cutoff your own ability to see what went wrong on the other end.

What I propose, is that we as API providers should include error test endpoints. Something like:

/tests/errors/500
/tests/errors/503
etc

(note: 404 is obviously easy)

In theory RESTful APIs would all return errors in the same way with HTTP error codes and the like, but the practical reality is that this just isn’t the case. Some even return 200s with JSON strings that include errors. Even if they we’re all perfect, you still might want to wrap them in behaviors (like sending an email notification) depending on the message contents, which really leaves you in a predicament if the errors are hard to intentionally produce. You can even make a compelling argument that API client development should start with these endpoints.

I’ve opened an Issue to add these endpoints for YourTrove’s API and I will follow this up with a blog post on the Trove blog when those endpoints are deployed.

Idea Giveaway: How to Kill the Kindle in 4 Easy Steps, No New eReader Required

I was pretty busy today, but I was able to glance long enough at my #ces column in Tweetdeck to see lots of noise about eReaders (for the record, it’s my blog and I can refuse to use the hyphen, cause I hate hyphenated tech stuff). It struck me that all these devices are a high volume of missing-the-vote-itis (that gets hyphens, keeping up?).

The Kindle seemed like the greatest thing ever when I first got mine: “I can finally read Neal Stephenson on the subway without getting neck and should cramps!!!” However, despite being a fantastic device at its launch – especially compared to, ya know, paper – the Kindle actually lacks quite a bit. So here’s my 4 easy steps to killing the Kindle (or making it a lot better, if Amazon is paying attention):

1. Make it social

This seems spectacularly obvious, and there have been a bunch of attempts to link books and social networking, but nothing has really taken off. Consider this: Why can’t you post a review of the book you just finished on your Kindle to the reviews on Amazon from your Kindle? And that’s just to start:

Why can’t you push an update that you just finished a book to Twitter and/or Facebook, from your Kindle?

Why can’t you click “Recommend this book to [your friend] ” from your Kindle?

These examples are just the beginning.

2 Drop the device

Is the Kindle hardware or software? Think about it. What really makes the Kindle work? It’s the ebook format and the wireless delivery. If you use the Kindle iPhone app you’ve probably realized this. Consumers, particularly geeks and early adopters, already have oodles of devices and there is massive craving for the iSlate or other tablets. And more importantly, all you need is the software and a device: a smartphone, a tablet even a plain old laptop or PC. You could probably launch with the following versions:

  • Windows XP/Vista/7/Mobile
  • OS X
  • iPhone
  • Android

3. Make it an open API

Guess what? If you’re selling a socially-networked, multi-device bookstore, you aren’t selling software; you’re selling books, electronically. You want that service to be exposed to as many places as possible and you want the community contributing innovation to your service. You want people integrating the next new hot web service with your service before you’ve even thought of what to do. You want it on new devices before your own employees have even heard of those devices.

And oh, by the way, wouldn’t it be cool if you were on your favorite author’s blog and they just announced their newest book was released in a post, and in that post there was a widget and all you had to do was click to buy the new book and have show up on your device of choice?

4. Give the authors a better deal

The Kindle’s pricing structure eats into the author’s share pretty harshly. Charles Stross has written about this pretty extensively and certainly knows more about the topic than I do. In addition, Amazon doesn’t do much to incentivize authors to encourage their readers to buy ebooks. In fact, the pricing structure discourages it. This is just plain silly.

Now put all these things together and what have you got?

  • You’ve got a web (HTTP technically) based store sold through heterogeneous client software
  • Your expenses are rights to the ebooks and format licensing, bandwidth and the software to run the store and handle transactions.
  • What expenses have you eliminated? For one thing, you don’t need a warehouse, either for the books or devices, which incidentally means you don’t have shipping costs.
  • And oh, by the way, unlike the Kindle, you aren’t paying for the customer’s bandwidth because they are using their own devices. You’re only paying for delivering the books, which are small, especially in comparison to other electronic products like music, movies or games.
  • You’ve provided your customers with a way to build on top of your services and integrate with future, unknown third parties.

And what have consumers got? They have ebooks that they can read on whatever device they feel like, they can share their experience with what they’ve read on whatever social network they feel like. Their favorite authors will be encouraged to interact with them in this format. And they don’t have yet another device and charger to keep track of.

Now, cue someone pointing me to where I didn’t Google enough and this already exists, cause I would really like it. Or funding it :)