API modeling

Slides

API Academy

http://APIAcademy.co

JSON-LD

JSON for linked documents


{
    "@context": {
        "displayName": "https://schema.org/name",
        "profileImage": {
            "@id": "https://schema.org/image",
            "@type": "@id"
        },
        "friends":  {
            "@container": "@set"
        }
    },
    "displayName": "John Doe",
    "friends": [
        {
            "@id":  "https://my.api/gamer/123456"
        }
    ]
}

@context info can be delivered separately.

JSON-LD Simplified

JSON for linked documents


{
    "@context": {
        "displayName": "https://schema.org/name",
        "profileImage": {
            "@id": "https://schema.org/image",
            "@type": "@id"
        },
        "friends":  {
            "@container": "@set"
        }
    },
    "displayName": "John Doe",
    "friends": "https://my.api/gamer/1337/friends"
}

JSON-LD Extended (HYDRA)

?

HAL: Hypertext Application Language

State

key/value pairs describing current state of resource

Links

Links to actions/extra info

At least self

Embedded resources

Curies

Link URL transformations, e.g. for documentation of resources

Collection + JSON

https://amundsen.com/media-types/collection/

Collection, Links, Templates, Queries

Geared towards representing collections.


{
    "version": "1.0",
    "href": "http://...",
    "collection": {
        "items": [
            {
                "data": {},
                "links": {}
            }
        ]
    }
}

W3C linked data platform

Spec around 12 pages.

  • Use URIs as names for things
  • Use HTTP URLs so that they can be looked up
  • Provide useful info at the URL
  • Include links to other URIs

LDP resources (LDPR)

HTTP and RDF to read and write linked data.

Resources can be created, modified, deleted and read using standard HTTP verbs (POST, PUT/PATCH, DELETE, GET).

Cover RDF sources as well as binary resources. Binary resources have RDF resource with metadata.

Clients use Optimistic Collision Detecion on update (etags).

LDP containers (LDPC)

An LDPR to which you POST to create new things, GET to find existing things.

Three flavors: Basic, Direct, Indirect.

LDP paging

Redirects to first page of collection if too-small limit is requested.

Clients

Tabulator by Tim Berners-Lee.

OSLC

Open Services for Lifecycle Collaboration

http://open-services.net

Based on LDP.

Resources

"API Craft" Google group

{"API": "101"} by Kin Lane, API Evangelist

RESTful Web Services Cookbook by Subbu Allamaraju

APIgee ebooks

Open Source Cloud meetup

Misc

"Data is the new bacon"