Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a...

30
Preliminary Draft

Transcript of Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a...

Page 1: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

Preliminary Draft

Page 2: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

Building an APIThat people will actually use

Page 3: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

In this session we will:● Define "API"● Discuss API best practices● Expose a Drupal installation via an API● Support API developers by providing:

○ Documentation○ SDKs○ Example implementations

● Learn to plan for the future

Page 4: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

What is an API?● Application Programming Interface● Expose your data to the world● Expose your application via two-way

communication● Enable developers to extend your

application

Page 5: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

Why expose an API?● Extend the reach of your and data● Expand implementations of your application● Crowdsource feature development● Reach a wider audience

Page 6: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

What is a *good* API?● Logically represent your application and data● Support multiple request formats● Provide multiple response formats● Support developers● Plan for the future

Page 7: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

Path patterns● Define objects granularly● Use plural nouns● Use query parameters for filtering● Avoid using verbs; use HTTP methods● Bonus: shallow/depth

Page 8: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

Dos and Don'tsDon't● /api/v1/nodes/[node_id]

○ nodes don't define objects● /api/v1/video/[video_id]

○ non-plural nouns● /api/v1/videos/funny

○ filters in path● /api/v1/videos/create

○ verbs in path● /api/v1/videos/[video_id]/

comments○ ideally, avoid traversing

more than two levels

Do● /api/v1/articles/[article_id]

○ content types define objects● /api/v1/videos/[video_id]

○ plural denotes a container● /api/v1/videos?category=funny

○ query strings are better● POST /api/v1/videos

○ use HTTP methods● /api/v1/comments?content=

video&id=[video_id]○ query strings offer many

benefits

Page 9: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

Servicesdrupal.org/project/services

Page 10: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

ServicesThe Services module exposes elements of your Drupal installation via an API.

● Built-in request formats:○ bencode, json, jsonp, php, rss, xml

● Built-in response formats:○ json, xml, form-data, etc.

Page 11: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

Data exposure methods● Baked-in methods

○ CRUD operations, Relationships, and Actions

Page 12: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

Screenshot of baked-in Services operations

Page 13: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

Data exposure methods● Baked-in methods

○ CRUD operations, Relationships, and Actions

● Content API○ drupal.org/project/contentapi

Page 14: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

Screenshot of Content API options

Page 15: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

Data exposure methods● Baked-in methods

○ CRUD operations, Relationships, and Actions

● Content API○ drupal.org/project/contentapi

● Custom methods○ hook_services_resource()

Page 16: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

Example hook_services_resource() implementation

Page 17: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

Authentication● Drupal session● OAuth● Custom authentication methods

Page 18: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

Introducing:Services Documentationdrupal.org/project/services_documenation

Page 19: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

Support developers1. Documentation2. Examples3. SDKs

Page 20: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

Documentation● Automatically generate documentation for

resources, operations, and arguments● Provide request and response examples● Version Control!● Fully themable!!!

Page 21: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

Example of a documentation implementation

Page 22: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

SDKsOffer SDKs that developers can implement to use your API:● Facilitate rapid application development● Provide a language-agnostic service● Empower a community to grow organically

Page 23: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

Example of an SDK implementation

Page 24: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

ExamplesProvide examples of applications that harness your API with or without an SDK.● Widgets● Interfaces● jQuery plugins● Mobile apps

Page 25: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

Example of an example implementation

Page 26: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

Planning aheadFuture-proofing your API

Page 27: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

Versioning● Only release "major versions"● Avoid deprecation which breaks third-party

applications

Page 28: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

Mitigating growth● API platform providers

(Mashape, Mashery, 3scale, Apigee, Mulesoft)○ Authentication○ Response caching○ Analytics○ Integrate multiple APIs behind a facade

Page 29: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

Thanks for listening!Now go build something awesome

Page 30: Preliminary Draft · In this session we will: Define "API" Discuss API best practices Expose a Drupal installation via an API Support API developers by providing:

Resources