![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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/1.jpg)
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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/2.jpg)
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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/3.jpg)
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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/4.jpg)
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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/5.jpg)
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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/6.jpg)
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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/7.jpg)
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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/8.jpg)
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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/9.jpg)
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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/10.jpg)
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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/11.jpg)
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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/12.jpg)
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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/13.jpg)
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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/14.jpg)
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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/15.jpg)
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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/16.jpg)
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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/17.jpg)
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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/18.jpg)
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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/19.jpg)
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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/20.jpg)
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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/21.jpg)
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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/22.jpg)
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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/23.jpg)
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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/24.jpg)
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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/25.jpg)
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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/26.jpg)
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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/27.jpg)
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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/28.jpg)
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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/29.jpg)
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:](https://reader034.vdocuments.us/reader034/viewer/2022042223/5ec98a71b83f5f77ec2d4747/html5/thumbnails/30.jpg)
Resources