About Me
• Lorna Jane Mitchell
• http://lornajane.net
• API and Web Development Consultant
• Author, speaker
Slide 3
Slide 3 text
Why APIs?
APIs provide:
• Re-usable business logic
• Scalability
• 3rd party access
• Maintainability
Slide 4
Slide 4 text
3 Stages of API Development
There are various stages of building an API
1. Publish an API
2. Consume your own API
3. Modular/Multiple APIs
Slide 5
Slide 5 text
Web
Slide 6
Slide 6 text
Service
Slide 7
Slide 7 text
Design
Slide 8
Slide 8 text
Web
Slide 9
Slide 9 text
HTTP
Slide 10
Slide 10 text
Request and Response
Slide 11
Slide 11 text
Statelessness
Slide 12
Slide 12 text
Status Codes
Slide 13
Slide 13 text
Status Codes: Headline News
Common codes:
200 OK
304 Not Modified
302 Found
301 Moved
401 Not Authorised
403 Forbidden
404 Not Found
500 Internal Server Error
Slide 14
Slide 14 text
Headers
Slide 15
Slide 15 text
HTTP Headers
Headers are the metadata about the content we send/receive
Useful headers:
• Accept and Content-Type: used for content format negotiation
Slide 16
Slide 16 text
Content Negotiation
Slide 17
Slide 17 text
HTTP Headers
Headers are the metadata about the content we send/receive
Useful headers:
• Accept and Content-Type: used for content format negotiation
• User-Agent: to identify what made the request
Slide 18
Slide 18 text
HTTP Headers
Headers are the metadata about the content we send/receive
Useful headers:
• Accept and Content-Type: used for content format negotiation
• User-Agent: to identify what made the request
• Set-Cookie and Cookie: working with cookie data
Slide 19
Slide 19 text
HTTP Headers
Headers are the metadata about the content we send/receive
Useful headers:
• Accept and Content-Type: used for content format negotiation
• User-Agent: to identify what made the request
• Set-Cookie and Cookie: working with cookie data
• Authorization: controlling access
Slide 20
Slide 20 text
Verbs
Slide 21
Slide 21 text
HTTP Verbs
• More than GET and POST
• PUT and DELETE to update and delete in a RESTful service
• HEAD, OPTIONS and others also specified
In REST, we use:
GET Read
POST Create
PUT Update
DELETE Delete
Slide 22
Slide 22 text
Service
Slide 23
Slide 23 text
Target Audience
Slide 24
Slide 24 text
RPC Services
Slide 25
Slide 25 text
RPC: Remote Procedure Call
• Single endpoint
• Function name
• Parameters
• Return value
• SOAP is a kind of RPC
Slide 26
Slide 26 text
Soap
Slide 27
Slide 27 text
Data Formats
Slide 28
Slide 28 text
REST
Slide 29
Slide 29 text
RESTful Services
• REpresentational State Transfer
• URLs are unique resource identifiers
• HTTP verbs indicate which operation should happen
• We have full CRUD operations on a series of resources