KazooCon 2014 - Introduction to Kazoo APIs!
-
Upload
james-solada -
Category
Technology
-
view
1.572 -
download
7
description
Transcript of KazooCon 2014 - Introduction to Kazoo APIs!
![Page 1: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/1.jpg)
PRESENTED BY:
INTRODUCTION TO KAZOO APIs
Sean & Ricky
![Page 2: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/2.jpg)
#kazoocon14
What is an API?
![Page 3: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/3.jpg)
#kazoocon14
ApplicationProgrammingInterface
![Page 4: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/4.jpg)
#kazoocon14
An API as a bolt.
![Page 5: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/5.jpg)
#kazoocon14
REST
Kazoo APIs are an example of a RESTFul web-service.
![Page 6: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/6.jpg)
#kazoocon14
HTTP/HTTPS
Kazoo APIs are provided over HTTP/HTTPS
![Page 7: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/7.jpg)
#kazoocon14
In most cases Kazoo APIs work just like a website!
![Page 8: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/8.jpg)
#kazoocon14
What do the HTTP requests do?
![Page 9: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/9.jpg)
#kazoocon14
Resources
Resources are just “Things”.
![Page 10: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/10.jpg)
#kazoocon14
Collections
Collections are just a group of resources of the same type.
![Page 11: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/11.jpg)
#kazoocon14
EntitiesEntities are a single instance of a resource.
![Page 12: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/12.jpg)
#kazoocon14
IDs
We use IDs to identify entities.
![Page 13: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/13.jpg)
#kazoocon14
But how do we tell the server what resources we want to
interact with?
![Page 14: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/14.jpg)
#kazoocon14
Uniform Resource Identifiers (URIs)
http://test.2600hz.com:8000/v1/accounts/C1234/users/U3456
![Page 15: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/15.jpg)
#kazoocon14
URI – Uniform Resource Identifier
http://test.2600hz.com:8000/v1/accounts/C1234/users/U3456
Base URL = http://test.2600hz.com:8000
![Page 16: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/16.jpg)
#kazoocon14
URI – Uniform Resource Identifier http://test.2600hz.com:8000/v1/accounts/C1234/users/U3456
Base URL = http://test.2600hz.com:8000
/v1/
![Page 17: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/17.jpg)
#kazoocon14
URI – Uniform Resource Identifier http://test.2600hz.com:8000/v1/accounts/C1234/users/U3456
Base URL = http://test.2600hz.com:8000
/v1/
/v1/accounts/
![Page 18: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/18.jpg)
#kazoocon14
URI – Uniform Resource Identifier http://test.2600hz.com:8000/v1/accounts/C1234/users/U3456
Base URL = http://test.2600hz.com:8000
/v1/
/v1/accounts/
/v1/accounts/C1234/
![Page 19: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/19.jpg)
#kazoocon14
URI – Uniform Resource Identifier http://test.2600hz.com:8000/v1/accounts/C1234/users/U3456
Base URL = http://test.2600hz.com:8000
/v1/
/v1/accounts/
/v1/accounts/C1234/
/v1/accounts/C1234/users/
![Page 20: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/20.jpg)
#kazoocon14
URI – Uniform Resource Identifier http://test.2600hz.com:8000/v1/accounts/C1234/users/U3456
Base URL = http://test.2600hz.com:8000
/v1/
/v1/accounts/
/v1/accounts/C1234/
/v1/accounts/C1234/users/
/v1/accounts/C1234/users/U3456/
![Page 21: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/21.jpg)
#kazoocon14
How do we tell the server what to do with the resource
we identified?
![Page 22: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/22.jpg)
#kazoocon14
HTTP Verbs or Methods
GET - /v1/accounts/C1234/users/
PUT - /v1/accounts/C1234/devices/ + data payload
POST /v1/accounts/C1234/users/U1112 + data payload
DELETE - /v1/accounts/C1234/users/U1112
![Page 23: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/23.jpg)
#kazoocon14
Verbs for interacting with collections
GET - /v1/accounts/C1234/users/
PUT - /v1/accounts/C1234/users/ + data payload
![Page 24: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/24.jpg)
#kazoocon14
Verbs for interacting with entities
GET - /v1/accounts/C1234/users/U1112
POST /v1/accounts/C1234/users/U1112 + data payload
DELETE /v1/accounts/C1234/users/U1112
![Page 25: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/25.jpg)
#kazoocon14
HTTP Response codes
2xx - successful request!200 - means the request was successful 201 - Entity was created
4xx - you messed up!401 - unauthorized (check your auth token)404 - entity or endpoint doesn't exist.
5xx - server messed up!500 - generic server error
![Page 26: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/26.jpg)
#kazoocon14
HTTP headers
Headers are used to set parameters used in processing the request.
Example: X-Auth-Token: <your auth token> Content-Type: application/json
![Page 27: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/27.jpg)
#kazoocon14
What is the payload?
![Page 28: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/28.jpg)
#kazoocon14
Payload
A payload is the representation of the resource we requested.
![Page 29: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/29.jpg)
#kazoocon14
Kazoo APIs mostly uses the JavaScript Object Notation (JSON) data format for most payloads
{ “key” : “value”}
![Page 30: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/30.jpg)
#kazoocon14
Key value pairs
“key” : “value”
![Page 31: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/31.jpg)
#kazoocon14
Key example:
“key” : “value”
![Page 32: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/32.jpg)
#kazoocon14
Value examples
“key” : “value”
![Page 33: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/33.jpg)
#kazoocon14
JSON Data Types:
“string_example” : “a string”,
“number_example” : 1,
“boolean_example” : true,
“null_example” : null,
“array_example” : [ “a string”, “a number” ],
“object_example” : { “some_key” : “some_value”, “other_key” : 1 }
![Page 34: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/34.jpg)
#kazoocon14
JSON BASE OBJECT
{ “key” : “value”}
![Page 35: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/35.jpg)
#kazoocon14
Complex nested JSON example:
{ “level_one_object” : { “level_two_object” : { “level3_key” : “level3_value”, “level3_array” : [ “level4_value” ] }, “level_two_array” : [ “level3_value” ] }}
![Page 36: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/36.jpg)
#kazoocon14
In the API, we always have a “data” object which contains the payload.
{ “data” : { “parameters_for_resource” : “some value” } “metadata_stuff” : …}
![Page 37: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/37.jpg)
#kazoocon14
Putting it all together.
![Page 38: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/38.jpg)
#kazoocon14
![Page 39: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/39.jpg)
#kazoocon14
![Page 40: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/40.jpg)
#kazoocon14
![Page 41: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/41.jpg)
#kazoocon14
![Page 42: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/42.jpg)
#kazoocon14
To recap.
![Page 43: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/43.jpg)
#kazoocon14
• The URI is a “noun” which Identifies a specific resource.
• The HTTP method is a “verb” which defines what type of action we want to take against the resource.
• The contents of the payload is a JSON object.
![Page 44: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/44.jpg)
#kazoocon14
Ok, let’s play with the Kazoo APIs!!!
![Page 45: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/45.jpg)
#kazoocon14
Tools for exploring Kazoo APIs
• Kazoo UI, Developer tools• Curl – Command Line Tool• Postman – Browser based.• SDKs (Software Development Kit)
![Page 46: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/46.jpg)
#kazoocon14
Tools for exploring Kazoo APIs
• Kazoo UI, Developer tools http://kazooui.kazoocon.com
• Curl – Command Line Tool• Postman – Browser based.• SDKs (Software Development Kit)
![Page 47: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/47.jpg)
#kazoocon14
Authentication TokensTemporary “Security tokens” used to authenticate clients.
credentials = an md5 hash of the string username:password echo -n “user:pass” | md5
PUT http://api.sandbox.2600hz.com:8000/v1/user_auth{ “data”: { “credentials” : “12345678”, “realm” : “your.realm.com” }} or { “data”: { “credentials” : “12345678”, “account_name” : “account_name”}}
PUT http://api.sandbox.2600hz.com:8000/v1/api_auth{ “data” : { “api_key” : “YOUR_API_KEY” }}
NOTE: you can get API key with GET -/v1/accounts/<Account_ID>/api_key
How to get one:
![Page 48: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/48.jpg)
#kazoocon14
Tools for exploring Kazoo APIs
• Kazoo UI, Developer tools• Curl – Command Line Tool• Postman – Browser based.• SDKs (Software Development Kit)
![Page 49: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/49.jpg)
#kazoocon14
Tools for exploring Kazoo APIs
• Kazoo UI, Developer tools• Curl – Command Line Tool• Postman – Browser based.• SDKs (Software Development Kit)
![Page 50: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/50.jpg)
#kazoocon14
Tools for exploring Kazoo APIs
• Kazoo UI, Developer tools• Curl – Command Line Tool• Postman – Browser based.• SDKs (Software Development Kit)
![Page 51: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/51.jpg)
#kazoocon14
CreateNewAdminAccount
![Page 52: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/52.jpg)
#kazoocon14
CreateNewAdminUser
![Page 53: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/53.jpg)
#kazoocon14
PHP SDK example sign-up form.
![Page 54: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/54.jpg)
#kazoocon14
Links
Github link for PHP SDK:https://github.com/2600hz/kazoo-php-sdk
Google Groups:https://groups.google.com/forum/#!forum/2600hz-devhttps://groups.google.com/forum/#!forum/2600hz-users
Sign-up page:http://userxxx.u.kazoocon.com/sign_up/gobblin/#ajax/signup.html
![Page 55: KazooCon 2014 - Introduction to Kazoo APIs!](https://reader030.fdocuments.net/reader030/viewer/2022012322/549c65cdb4795991318b475c/html5/thumbnails/55.jpg)
Thank You!
#kazoocon14