Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.
Coding 102
REST API Basics using Spark
David STAUDT, Developer Evangelist, dstaudt@cisco.com
Stève SFARTZ, API Evangelist,...
• REST API Basics
• A tour of Cisco Spark API
• Interactive Documentation Hands-on
• Postman Hands-on
• Javascript example...
REST API Basics
Coding 101 Prerequisites – DEVNET1001
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public
What is so great about REST?
same concept, many Cisc...
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public
Terminology of a REST API query
GET /../repos?page=1...
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public
http://getpostman.com
• Want to code along? Install ...
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public
method
url
request
headers
status code
response head...
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public
JSON syntax
• square brackets for lists
• curly brac...
Cisco Spark for Developers
A tour of Cisco Spark APIs
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public
Cisco Spark
Secure & Open
Complete & Simple
Spark fo...
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public
‘Your App’
now with
Cisco Collab!
Spark APIs
Extend ...
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public
Cisco Spark API v1 (July 2016)
/People /Rooms /Membe...
Hands on
list your Spark Rooms
with the Interactive Documentation
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public
Developer Portal Interactive API
documentation
Clien...
16
17
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public
Hands-on Instructions
• Go to « List Rooms » documen...
Hands on
add a Message to a Room
with Postman
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public
Demo : list Rooms from Postman
DEVNET-2002
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco PublicDEVNET-2002
Hands on
Import the Postman collection
bi...
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public
Hands on
• Get your Cisco Spark Token from developer...
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public
Hands on
• Pick a Room identifier « RoomId »
Add a M...
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public
Hands on
• Forge a POST request to create a message
...
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public
POSTED !!!
• 200 OK
• Check Message Id & attachments...
Cisco Spark for Developers
Spark API calls in Javascript
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public
How to request from Javascript
• A benefit of REST i...
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public
How to request from NodeJS
1. Generate a nodejs skel...
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public
How to request from NodeJS
• Official « ciscospark »...
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public
Continue Your Education in the DevNet Zone
• Take a ...
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public
Continue Your Education in the DevNet Zone
• Take th...
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public
Continue Your Education
• Demos in the Cisco campus
...
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public
Complete Your Online Session Evaluation
Don’t forget...
Thank you
@CiscoSparkDev
@CiscoDevNet
Coding 102 REST API Basics Using Spark
Coding 102 REST API Basics Using Spark
Próxima SlideShare
Cargando en…5
×

Coding 102 REST API Basics Using Spark

1.101 visualizaciones

Publicado el

From Cisco Live 2016 Las Vegas, David Staudt and Steve Sfartz.

Publicado en: Tecnología
  • Sé el primero en comentar

  • Sé el primero en recomendar esto

Coding 102 REST API Basics Using Spark

  1. 1. Coding 102 REST API Basics using Spark David STAUDT, Developer Evangelist, dstaudt@cisco.com Stève SFARTZ, API Evangelist, stsfartz@cisco.com DEVNET-2002
  2. 2. • REST API Basics • A tour of Cisco Spark API • Interactive Documentation Hands-on • Postman Hands-on • Javascript examples • Pre-requisites • You know how to forge API requests with Postman (or a similar REST client) • If not, attend DEVNET-1001: Coding 101- Introduction to REST APIs Agenda
  3. 3. REST API Basics Coding 101 Prerequisites – DEVNET1001
  4. 4. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public What is so great about REST? same concept, many Cisco APIs Easy to Build Web apps Mobile apps M2M, Bots… REST API DEVNET-2002 5
  5. 5. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public Terminology of a REST API query GET /../repos?page=1 HTTP/1.1 accept: application/json HTTP 200 OK browser api.github.com:443 method path protocol status code https://api.github.com/users/CiscoDevNet/repos?page=1&per_page=2 headers URL: response body HTTP request HTTP response api endpoint JSON payload parameters DEVNET-2002 6
  6. 6. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public http://getpostman.com • Want to code along? Install POSTMAN now • Free tool to forge API requests, examine responses DEVNET-2002 7
  7. 7. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public method url request headers status code response headers content-type response body query parameters DEVNET-2002 8
  8. 8. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public JSON syntax • square brackets for lists • curly braces for objects • name/value pairs for properties, separated by commas • pick an online editor • http://codebeautify.org/jsonviewer http://www.jsoneditoronline.org DEVNET-2002 9
  9. 9. Cisco Spark for Developers A tour of Cisco Spark APIs
  10. 10. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public Cisco Spark Secure & Open Complete & Simple Spark for Developers User Integrations, APIs/SDKs, etc. Spark Hybrid Services Cloud + Prem Partner Services Interconnect Message Meeting Call DEVNET-2002 11
  11. 11. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public ‘Your App’ now with Cisco Collab! Spark APIs Extend Cisco Collaboration Cloud GET POST DELETE PUT /Rooms /Memberships /Messages /Teams /People DEVNET-2002 12DEVNET-2002 12 /Webhooks
  12. 12. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public Cisco Spark API v1 (July 2016) /People /Rooms /Membership /Messages /Teams /Webhooks List People List Rooms List Memberships List Messages List Teams List Webhooks Create a Room Create a Membership Create a Message Create a Team Create a Webhook Get Person Details Get Room details Get Membership details Get Message details Get Team details Get Webhook details Update a Room Update a Membership Update a Team Update a Webhook Delete a Room Delete a Membership Delete a Message Delete a Team Delete a Webhook GET POST DELETE PUT DELETE DELETE DELETE PUT PUT POST POST POST GET GET GET GET GET GET GET GETGET DEVNET-2002 13 DELETE PUT POST GET GET
  13. 13. Hands on list your Spark Rooms with the Interactive Documentation
  14. 14. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public Developer Portal Interactive API documentation Client SDKs developer.ciscospark.com 24/7 Dev Support DEVNET-2002 15
  15. 15. 16
  16. 16. 17
  17. 17. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public Hands-on Instructions • Go to « List Rooms » documentation on the Developer Portal https://developer.ciscospark.com/resource-rooms.html • Login: and Turn « Test Mode » on: • Run the query: 18
  18. 18. Hands on add a Message to a Room with Postman
  19. 19. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public Demo : list Rooms from Postman DEVNET-2002
  20. 20. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco PublicDEVNET-2002 Hands on Import the Postman collection bit.ly/DEVNET2002
  21. 21. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public Hands on • Get your Cisco Spark Token from developer.ciscospark.com • Fill in the Authentication Header • Authorization : Bearer YOUR_SPARK_TOKEN • List some Rooms you are a member of Add a Message to a Room with Postman 22
  22. 22. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public Hands on • Pick a Room identifier « RoomId » Add a Message to a Room with Postman 23DEVNET-2002
  23. 23. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public Hands on • Forge a POST request to create a message • API documentation : https://developer.ciscospark.com/endpoint-messages-post.html Add a Message to a Room with Postman DEVNET-2002 24
  24. 24. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public POSTED !!! • 200 OK • Check Message Id & attachments DEVNET-2002 25
  25. 25. Cisco Spark for Developers Spark API calls in Javascript
  26. 26. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public How to request from Javascript • A benefit of REST is that you can invoke Spark from any language • Hand code with your favorite HTTP client library • Or generate code from Postman • OAuth 2 to inject user API token Do It Yourself … with Postman code assistants DEVNET-2002 27
  27. 27. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public How to request from NodeJS 1. Generate a nodejs skeleton from Postman, 2. Run from the command line Do It Yourself … with Postman code assistants DEVNET-2002 28
  28. 28. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public How to request from NodeJS • Official « ciscospark » SDK • Community SDKs • nmarus Sparky, • drkchiloll/csco-spark • … … or choose with a ready-to-use SDK https://github.com/nmarus/sparky https://www.npmjs.com/package/ciscospark DEVNET-2002 29
  29. 29. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public Continue Your Education in the DevNet Zone • Take a Spark Learning Lab 1. Create Rooms, Adding Participants and Posting Messages 2. Learn to create a Webhook that will subscribe to new messages in a room 3. Register a new Spark app, and authenticate from a browser based app https://developer.ciscospark.com/samples-tutorials.html • Attend other Spark API sessions or take an instructor-driven Workshop • DEVNET-2020: [Workshop] Working with Spark APIs • DEVNET-2021: Spark API Authentication - Bots and Oauth • DEVNET-2025: [Workshop] Build a Multi-Function iPaaS Application Using Python • DEVNET-3002: [Workshop] Tour the DevNet Quiz App (Spark & Tropo Integration) • BRKDEV-2004: Cloud Integration Platform Use-Cases and Coding Walk-Through DEVNET-2002 30
  30. 30. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public Continue Your Education in the DevNet Zone • Take the DevNet « Coding Track » • DEVNET-1001: Coding 101, Introduction to REST APIs • DEVNET-1060: Intro to API Authentication Types (Oauth, token HTTP Basic) • DEVNET-1080: Introduction to Git • DEVNET-2002: Coding 102, REST API Basics using Spark • DEVNET-2003: Coding 102, REST API Basics using APIC-EM • DEVNET-2006: Coding 103, Deep Dive on JSON & more Python • Meet the Experts at the Demo Pods • Become a DevNet Community member www.developer.cisco.com DEVNET-2002 31
  31. 31. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public Continue Your Education • Demos in the Cisco campus • Walk-in Self-Paced Labs • Lunch & Learn • Meet the Engineer 1:1 meetings • Related sessions DEVNET-2002 32
  32. 32. © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public Complete Your Online Session Evaluation Don’t forget: Cisco Live sessions will be available for viewing on-demand after the event at CiscoLive.com/Online • Give us your feedback to be entered into a Daily Survey Drawing. A daily winner will receive a $750 Amazon gift card. • Complete your session surveys through the Cisco Live mobile app or from the Session Catalog on CiscoLive.com/us. DEVNET-2002 33
  33. 33. Thank you @CiscoSparkDev @CiscoDevNet

×