Write better code faster with rest data contracts api strat

Post on 14-Jun-2015

405 views 1 download

Tags:

description

A suggestion to teams who build APIs to use tools like API Blueprint or RAML to use REST Data Contracts as part of their development process to build REST APIs more efficiently.

Transcript of Write better code faster with rest data contracts api strat

Track: Developers

#CNX14

Write Better Code Faster with REST Data Contracts

Kris Chant

Sr. Technical Product Manager – API

Salesforce ExactTarget Marketing Cloud

@sprshrp

Track: Developers

#CNX14

Visualize your API Development Process.

Track: Developers

#CNX14

A Proposed REST API Development Process

Track: Developers

#CNX14

An Actual REST API Development Process

Track: Developers

#CNX14

REST API Development Process with Data Contracts

Track: Developers

#CNX14

What is a REST Data Contract?

How will we write better

code faster?

How can I implement

them?

Goals – Presentation Overview

1 2 3

Track: Developers

#CNX14

What is a REST API Data Contract?

• Not rocket science• Wireframe for API• Defines facts:

• URI• Request• Response

Track: Developers

#CNX14

Simple Example

## Notes Collection [/notes]

### List all Notes [GET]

+ Response 200 (application/json)

[{

"id": 1, "title": "Jogging in park"

}, {

"id": 2, "title": "Pick-up posters from post-office"

}]

+ Response 401 (application/json)

{

“message” : “You’re not authorized.”

}

Track: Developers

#CNX14

Advanced Example

## Note [/notes/{id}]A single Note object with all its details+ Parameters + id (required, number, `1`) ... Numeric `id` of the Note to perform action with. Has example value.

### Retrieve a Note [GET]+ Response 200 (application/json) + Header X-My-Header: The Value + Body { "id": 2, "title": "Pick-up posters from post-office" }

### Remove a Note [DELETE]+ Response 204

Track: Developers

#CNX14

Write Better Code…

• Ask better questions, earlier• Greater understanding

Track: Developers

#CNX14

Faster.

• It’s a Contract.• Eliminate Blockers• Tandem Development

Track: Developers

#CNX14

How can I use them?

• Pre-requisite to development• Schedule time• API Design Tools

• API Blueprint - Apiary• RAML – MuleSoft

Track: Developers

#CNX14

Example of our Workflow

Track: Developers

#CNX14

Thank you!

Let’s continue the discussion on Twitter: @sprshrp