The Object Network: Linking up our APIs
The idea of the Object Network is almost ridiculously simple:
Instead of writing a whole new, dedicated HTTP API to your site, publish your data using common JSON object formats, and link your data up, both within your own sites and to other sites. Become part of a global Object Network!
In other words: let's link up all our APIs!
Of course: there is a Google discussion group you should join!
Or to follow the latest on the Object Network in your feed reader, subscribe to this current blog series: Introducing the Object Network.
Object Network objects are simple, open, linked, JSON data structure formats representing common stuff in pre-defined formats: people, contacts, events, places, dates, photos, news, messages, feeds, lists, galleries, reviews, maps, calendars, media metadata, etc. They are linked together and linked into the Web.
The contact JSON objects are based on vCard, events on iCalendar, news on Atom, publication info based on Dublin Core, etc. We'll plunder as much existing work as possible, including the Semantic Web, Microdata and Microformats.
But unlike some of these existing formats, our objects all link up: an event object will link to the contact objects of the venue and the list of attendees. A review could point to the event it is about, or to the contact of a restaurant.
If the common formats defined on this site don't cover your needs, then we can either immediately extend the common format when it's obviously a good idea, or you can just use your own extension anyway. The rules of this game, though, are that you publish those extensions for discussion and refinement.
As each of these types are implemented in real code, exercised and refined, they will have their own spec pages linked to from here.
Meanwhile, here's an example of an event pointing to the contact card for its location, on another domain:
GET /events/uid-f330a3-4011e.json HTTP/1.1
Host: mobiconfs.com
If-None-Match: "32"
:
HTTP/1.1 200 OK
Cache-Control: max-age=1800
ETag: "33"
Content-Type: application/json
{ "is": "event",
"title": "Over the Air 2011",
"content": "Top Mobile Meetup at Bletchley Park",
"start": "Fri, 30 Sep 2011 09:00:00 GMT",
"end": "Sat, 1 Oct 2011 23:00:00 GMT",
"location": "http://bletchleypark.org/address.json",
"attendees": [ "/staff/uid-55d3.json", "uid-06-7d5d" ]
}
:
:
GET /address.json HTTP/1.1
Host: bletchleypark.org
If-None-Match: "22"
:
HTTP/1.1 200 OK
Cache-Control: max-age=86400
ETag: "23"
Content-Type: application/json
{ "is": "contact",
"fullName": "Bletchley Park",
"address": {
"extended": [ "The Mansion", "Bletchley Park" ],
"street": "Sherwood Drive",
"locality": [ "Bletchley", "Milton Keynes" ],
"region": "Buckinghamshire",
"postalCode": "MK3 6EB",
"country": "UK"
},
"phone": { "work": [ "01908 640404", "01908 272684" ] },
"email": "info@bletchleypark.org.uk",
"webView": "http://www.bletchleypark.org/"
}
See the blog series for full explanations.
You benefit from all the mashability and cacheability of the Web, at a fine-grained object level.
Mashability: as well as avoiding incompatible APIs, the Object Network also breaks down the corresponding application boundaries: it allows a seamless experience of jumping from one object to another, and from one content source to another, even between completely different sites. Applications can more easily share data directly; you don't replicate data, you just point to it.
Publishing into the Object Network is very simple, especially since most of the design work will already have been done, but as more people use Object Network types, each object published into it becomes more and more valuable, out of proportion to its cost.
Also, the Object Network can help you deliver the clean, stable, reusable code that comes from using clean, stable, reusable data, both on the client side and server side.
When you publish, you'll be publishing to clients and client code that already existed before you came along. Those client libraries will already understand how to fetch and cache data, and how to render it as nested widgets, etc. You should be able to pick up Object Network adaptors for common back-end data sources and APIs, to ease the path to publication.
You could start your next project with its Object Network interface, then, as well as using it for your own mobile apps, use it for assembling the pages of your websites, both server-side and client-side. And if you're using a JSON database, the Object Network types can provide the basis for the schemas that you need.
Cacheability: each object will have its own lifecycle and rate of update, thus its own cache lifetime or TTL, set in its "max-age" header and notified through "ETag". This can be used to drive efficient polling and update detection. You can load and cache related objects either lazily or eagerly, and refresh them on user action, or other events.
Or Microdata, or Microformats in XHTML? Why not use the Semantic Web or Linked Data?
Firstly, we're in the space of non-rendered data, here, the kind of data you'd be getting from an API. Tunnelling data through XHTML is rather a clumsy way to do that when you're not rendering for a user. You should, of course, generate Microformats, etc., in your HTML - it's an easy mapping from Object Network objects.
As for the Semantic Web or Linked Data, the Object Network is based on the incomparably successful and pragmatic Web architecture - on REST. The Object Network uses familiar, tangible JSON object structures, not the more abstract, floating RDF triples. Objects only have real, tangible, dereferencable URLs, not those difficult URIs! Inter-object links are expected, and always go directly from JSON object to JSON object. Object Network objects are expected to update, and to follow HTTP conventions around cacheing and update detection.
It should be pretty easy, though, to map from RDF or RDFa data, from Microdata or Microformats, into Object Network JSON, for interesting static data. Like I said, we'll be plundering the Semantic Web ontologies and vocabularies for our types.
An article about the Object Network on InfoQ.
An article about the Object Network on ProgrammableWeb.
There is a Google discussion group.
A blog series Introducing the Object Network, on my blog.
Comment on JSON Linking, on Mnot's blog.
Comment on API problems and solutions, on Subbu's blog.
Comment on API aggregators, on InfoQ.
Website for FOREST, the underlying architecture of the Object Network.
Chapter on FOREST.
Contact me and/or subscribe to my blog.
[BB12]