API Driven App Design

An exploration of theory and compromise.

Hi

I'm Christian. Among many other things, I build internets.

Currently at breakingnews.com/NBCNews,
formerly of the Django homeland.

xian@mintchaos.com@mintchaos

API

Application Programming Interface



API

HTTP RESTful endpoints and structured data

API

Data

Abstracted.

Consistent.

Stupid.

Structured data.

API Driven

Do you have an website that has an API?



API Driven

Do you have an API that powers a website?

API Driven

Do you have an API that powers a website and an iPhone app and a iPad app and a Kindle app and an Android app and a Samsung TV app and etc. ad infinitum?

API Driven

Dogfooding.

Can your API support everything about your application? It's not just about the website; Apps all the way down.

Data

  • Abstracted.
  • Stupid.
  • Consistent.
  • Structured data.


Everything is a compromise.



Data

Compromise.

You can't (easily) load anything lazily.
Relationships or methods. HATEOAS.

Public. Complexity costs are more upfront.
If you put it in, you can't take it out.

Private data?

Templating.

Decisions I've made

Let's talk about them

  • Impure dogfooding.
  • Public views return HTML + json to bootstrap.
  • All writes through the API.



Decisions I've made

Templating.

Wanted to use something light and dumb. A mustache-alike. They're all too dumb. Python AND JS. Ended up using Plate.js

More compromise:

  • Limited template Context.
  • Tags/filters need to be written and tested twice.

Unsolved mysteries

Complicated views

Our popular page:

  • A list of media.
  • Hot topics. With associated items.
  • Hot items.

Unsolved mysteries

Complicated views

Compromise:

  • Single endpoint.
  • A bunch of API calls.
  • Magical multi-endpoint.
  • Something else?

Resources: