Slide 1
Creating APIâs -
The Doâs and Donâts
of API Design
Simon Free
@simonfree
no notes exist for this slide
Slide 2
What to expect
The Basics
The different styles of APIâs
Design and development workflow
How to plan
How to document
Security
oAuth
Everything in action
Summary
no notes exist for this slide
Slide 3
What is an API
Used in the software world for years
An interface for other developers to interact with your code
implemented to determine vocabulary and calling conventions between consumer and implementer
Great for sharing content and functionality
no notes exist for this slide
Slide 4
Why are APIâs good?
An interface for other developers to interact with your code
No need for people to reinvent the wheel
Using other services speeds up development
no notes exist for this slide
Slide 5
Why create one?
Great for sharing content and functionality
Centralizes functionality (great for big business)
Allow other technologies to easily interact with your code
Allows you to focus on the core product, not the implementation
no notes exist for this slide
Slide 6
Different types of APIâs
RESTful
Representational State Transfer
Base URI for all requests
Different mime types
Different http methods give different results
RPC
Remote Procedural Call
Standardized
think of directly accessing a cfc
no notes exist for this slide
Slide 7
RESTful APIâs Explained
Multiple urls that have different meanings (easy to read)
http://api.simonfree.com/presentations/
http://api.simonfree.com/presentation/12.xml
http://api.simonfree.com/presentation/12/
POST and GET have different results
Multiple return formats available (optional but preferred)
no notes exist for this slide
Slide 8
no notes exist for this slide
Slide 9
no notes exist for this slide
Slide 10
What is your goal?
Easy for developers to learn
Easy for developers to use
Difficult to be misused
Easy to maintain code that implements it
Powerful enough to fulfill requirements
Easy to extend
Appropriate to the audience
no notes exist for this slide
Slide 11
Planning
Talk to your users
Make use cases
LISTEN to your users
Create a 1 page spec
Write sudo code that would use the API
Update the spec
Rinse and repeat
Have other developers look at the spec
no notes exist for this slide
Slide 12
Setting Expectations
You will not be able to please everyone
Displease everyone equally
Expect to make mistakes
They will be flushed out in a few years
Expect the product to evolve
no notes exist for this slide
Slide 13
Know your potential issues
Poor planning can cause poor usability
An API reflects your product
Mistakes can not easily be fixed
You can add but you canât remove
Must be accessible by all languages
Potentially opening up a HUGE security hole
no notes exist for this slide
Slide 14
SDR
Selective Data Retrieval
Your own database communication language
Allows for efficient data transfer
Requires additional documentation
Can be a security risk
Used by Facebook (fql)
no notes exist for this slide
Slide 15
Security
APIâs can be dangerous
Planning of security is critical
API security can tie into your existing security model
Errors should never be displayed/returned
no notes exist for this slide
Slide 16
no notes exist for this slide
Slide 17
oAuth
âAn open protocol to allow secure API authorization in a simple and standard method from desktop and web applications.â
Simply, user credentials are never directly supplied, they are directed to the client site that authorizes them and returns a token
Good: Standardized and Secure
Bad: Confusing and mind melting
no notes exist for this slide
Slide 18
no notes exist for this slide
Slide 19
no notes exist for this slide
Slide 20
oAuth - Terms
Tokens:
Consumer
Request
Access
Secrets
Nonce
no notes exist for this slide
Slide 21
Documentation
Description
Parameters
Required
Name
Type
Description
Example Call
Example Response
Error Code
no notes exist for this slide
Slide 22
Documentation - Examples
Facebook (Good)
http://wiki.developers.facebook.com/index.php/API
Flickr (Good)
http://www.flickr.com/services/api/
Basecamp (Bad)
http://developer.37signals.com/basecamp/
no notes exist for this slide
Slide 23
no notes exist for this slide
Slide 24
Execution
Create documentation for a simple API
Create a simple RESTful API
Create a site that uses the API
no notes exist for this slide
Slide 25
Future Developments
Keep an API accessible for at least 1 year (Ideally 2) after it has been depreciated
Keep depreciated functions active for 1-2 releases depending on frequency of releases
Gather user feedback
Keep an eye on developments in other technologies
Watch what other API developers are doing
no notes exist for this slide
Slide 26
no notes exist for this slide
Slide 27
no notes exist for this slide
Slide 28
no notes exist for this slide
Slide 29
no notes exist for this slide
Slide 30
no notes exist for this slide
Slide 31
no notes exist for this slide
Slide 32
no notes exist for this slide
Slide 33
no notes exist for this slide
Slide 34
no notes exist for this slide
Slide 35
Resources
http://hueniverse.com/oauth/
http://www.infoq.com/presentations/effective-api-design
(Article coming out soon)
no notes exist for this slide
Slide 36
Thatâs All!
Questions / Comments?
Simon@simonfree.com
Slides will be available at:
http://www.simonfree.com/presentations/
Follow me on Twitter:
http://www.twitter.com/simonfree
no notes exist for this slide