46
RAML – APIs By Design Uri Sarid CTO, MuleSoft #RAML @usarid @MuleSoft

RAML - APIs By Design

Embed Size (px)

DESCRIPTION

My talk (first given at HTML5 Dev Conference October 2013) about API design and RAML. See http://raml.org for more info.

Citation preview

Page 1: RAML - APIs By Design

RAML – APIs By Design

Uri Sarid

CTO, MuleSoft

#RAML

@usarid

@MuleSoft

Page 2: RAML - APIs By Design

APIs:The Cat's Meow

Page 3: RAML - APIs By Design

build on someone else's work… who's?

Ultimate Buzz for Creatively-lazy Developers

2005 2006 2007 2008 2009 2010 2011 2012 20130

2000

4000

6000

8000

10000

12000

14000

Source:

open APIs

Page 4: RAML - APIs By Design

yes, even Service-Oriented Architecture!

Modularity, Encapsulation, Specialization

eCommerceproductsshopping cartcheckoutbillingshipping

socialgraphposting

geolocationcity dataweatherattractionsbusinesses

collaborationdocumentsnotifications forums

analytics traffic logsNLPsales

marketingdemographicsSFAsocial

Page 5: RAML - APIs By Design

The API Economy Is Big and It's Now

1,000,000s

>13,000 Open APIs

Enterprise APIs

Page 6: RAML - APIs By Design

APIs and me

Page 7: RAML - APIs By Design

My Experience:

utility back-office software

consumer portal

Page 8: RAML - APIs By Design

• tells consumer devs what they'll get

The API Contract Is Critical

• tells implementer devs what to deliver

• ensures they'll meet in the end

• enables parallel development

Page 9: RAML - APIs By Design

My Experience: Barnes & Noble /

Don't expose dirty laundry

users

products

ordersinvoices

the layer cake of APIs

Page 10: RAML - APIs By Design

At MuleSoft

connectivity

Page 11: RAML - APIs By Design

Packaged apps Custom apps Databases

The Traditional Enterprise

The traditional enterprisesits comfortably behind the firewall

Page 12: RAML - APIs By Design

Welcome to the New Enterprise

SaaS

Packaged apps Custom apps Databases

SocialCloud platforms

Customers / Partners / Suppliers Mobility and Devices

The New Enterprise

Page 13: RAML - APIs By Design

Connect backend

SaaS

Packaged apps Custom apps Databases

SocialCloud platforms

Customers / Partners / Suppliers Mobility and Devices

The New Enterprise

Page 14: RAML - APIs By Design

Backend to SaaS

SaaS

Packaged apps Custom apps Databases

SocialCloud platforms

Customers / Partners / Suppliers Mobility and Devices

The New Enterprise

Page 15: RAML - APIs By Design

Everything needs to connect

SaaS

Packaged apps Custom apps Databases

SocialCloud platforms

Customers / Partners / Suppliers Mobility and Devices

The New Enterprise

Page 16: RAML - APIs By Design

The Anypoint Platform:integration on-premises and cloud

SaaS

Packaged apps Custom apps Big Databases / Big Files

SocialCloud platforms

Customers / Partners / Suppliers

Mobility and Devices

Anypoint Platform

BusinessInsight

EnterpriseMgmt

Mule Studio

Anypoint DataMapper

DataSense

Anypoint Connectors

Page 17: RAML - APIs By Design

The Anypoint Platform:integration on-premises and cloud

SaaS

Packaged apps Custom apps Big Databases / Big Files

SocialCloud platforms

Customers / Partners / Suppliers

Mobility and Devices

Anypoint Platform

BusinessInsight

EnterpriseMgmt

Mule Studio

Anypoint DataMapper

DataSense

Anypoint Connectors

100,000s

100s1,000s

1,000,000s

1,000,000,000s

Page 18: RAML - APIs By Design

The Anypoint Platform for APIs

SaaS

Packaged apps Custom apps Big Databases / Big Files

SocialCloud platforms

Customers / Partners / Suppliers

Mobility and Devices

Anypoint Platform

BusinessInsight

EnterpriseMgmt

Studio

APIkit

Anypoint DataMapper

DataSense

API Gateway

API Manager

Design/Dev Portal

Anypoint Connectors

Page 19: RAML - APIs By Design

An Opinionated Approach to API Success

Page 20: RAML - APIs By Design

DELIGHT YOUR USERS!

The Key to API Success?

how?

• design for them• iterate quickly• model cleanly and consistently• engage

Page 21: RAML - APIs By Design

Codify

Req

’s

Design API

Val

idat

e

Publish

CaptureFeedback

UI UX

API APX

Design For Your Users

Page 22: RAML - APIs By Design

where consumers touch you

your front door, your lobby, your façade

how you want to be seen; your brand

versioned more carefully than code

better interfaces better code

an organizing principle; alignment forcing function

the ultimate testing surface

Focus on the Interface: The Contract

Page 23: RAML - APIs By Design

1. Describe APIs simply and clearly

2. Design APIs easily and soundly

3. Engage users in compelling ways

What kind of interface do we want?

NOT documentation

NOT annotations in implementation

Page 24: RAML - APIs By Design

• nouns: resources, described by URI paths• verbs: HTTP methods• metadata: HTTP headers• responses: HTTP status codes• representations: appropriate media types in the body• use hypermedia – not necessarily, not yet

Practically-RESTful APIs

a few words

about

REST…

Page 25: RAML - APIs By Design

What Do People Do Today?

Page 26: RAML - APIs By Design

WADL

Page 27: RAML - APIs By Design

Reverb Swagger

Page 28: RAML - APIs By Design

Mashery IOdocs

Page 29: RAML - APIs By Design

Google Discovery Docs

Page 30: RAML - APIs By Design

Apiary Blueprint

Page 31: RAML - APIs By Design

Verdict:

manifest structure

capture patterns

humanly writeable

let's try harder…

Page 32: RAML - APIs By Design

Start From Scratch?Really???

Page 33: RAML - APIs By Design

• well-known superset of JSON• optimized for human readability• great for hierarchies• cruft-free• broad tooling base• extensible-ish• broad tooling base

No Need to Start From Scratch!

YAML

Page 34: RAML - APIs By Design

Introducing: RAML

A new open spec

for RESTful APIs

that's as clean

and as structured

as REST itself

RESTful API Modeling Language

the RAML Workgroup:raml.org

Page 35: RAML - APIs By Design

/users: get: description: Get a collection of users post: description: Create a new user in the collection/users/{userId}: get: description: Get a single user put: description: Update a single user delete: description: Delete a single user

RAML: How Clean? How Structured?

Take what you would have typed yourself…

Page 36: RAML - APIs By Design

RAML: How Clean? How Structured?

Page 37: RAML - APIs By Design

RAML: How Clean? How Structured?

Page 38: RAML - APIs By Design

RAML: How Clean? How Structured?

resource typeschema

trait

Page 39: RAML - APIs By Design

Covers Full HTTP

optional version in baseUri

template URIs

query parameters

headers (on request and response)

response per status code

example (and schema) per media type

Page 40: RAML - APIs By Design

Patterns: Resource Types

externalizable

inheritance

pull in traits

parametrize

Page 41: RAML - APIs By Design

Patterns: Method-level traits

mix-ins

Page 42: RAML - APIs By Design

Patterns: body schemas

or just use good ol' form data:

XML schema

JSON schema

examples

Page 43: RAML - APIs By Design

RAML for Real-Time APX Design

DEMO

Page 44: RAML - APIs By Design

raml.org

Page 45: RAML - APIs By Design

open-source tooling; host it too (e.g. on APIhub) growing library of API specs in RAML (e.g. on APIhub) converters client generators server frameworks (e.g. MuleSoft APIkit; node.js) testing frameworks mocking services (e.g. on APIhub) <insert your ideas here>

evolve RAML spec (RAML workgroup)

What's next?

Page 46: RAML - APIs By Design

One More Thing…

NOTEBOOK DEMO