Understanding REST APIs in 5 Simple Steps

52 vues

Publié le

Lightning talk. 10 minute content

Publié dans : Technologie
0 commentaire
0 j’aime
Statistiques
Remarques
  • Soyez le premier à commenter

  • Soyez le premier à aimer ceci

Aucun téléchargement
Vues
Nombre de vues
52
Sur SlideShare
0
Issues des intégrations
0
Intégrations
0
Actions
Partages
0
Téléchargements
2
Commentaires
0
J’aime
0
Intégrations 0
Aucune incorporation

Aucune remarque pour cette diapositive
  • I’m here to give you the 5 steps to take with you to understand REST APIs and start building stuff on your own. Before you can work with APIs, one has to understand APIs.
  • So when I say REST, I don’t mean this…
  • An API stands for Application Programming Interface

    It’s a way for two pieces of software to talk to each other.

  • Okay, so what is an API and why are they important?
  • Why are API’s so important? Most companies today have several different software’s they need to use,
    including sales, accounting, CRM, a project management system, etc.
    Having all their software work together is more important for financial reasons and to make work processes easier

    They can also create their own tool to enhance their software, making their customers happier.
  • APIs started out as 1 API in 2000, the Ebay API. Since 2011, it has doubled exponentially.

    From 2015 to 2016, it has doubled in growth from 15,000 to 30,00.
  • An API is best thought of as a contract provided by one piece of computer software to another.
  • REST describes a way of interacting with a HTTP server.
  • A REST API defines a set of functions which developers can perform requests and receive responses via HTTP protocol such as GET and POST.
  • REST is best explained as a way to talk to other machines through the server with an HTTP Protocol.

    It uses Verbs and nouns that I will show you later.

    So basically it’s a way of http talking to other machines with things and actions for each thing.
  • When you view a web page, it sends a request to the web server, and sends a response back.

    So you are making a request and getting a response.
  • When you send your HTTP request, you are sending a GET request.

    You get your response as an HTTP response code, where 200 means good, and everything came back okay.
  • This is exactly what is happening between your app and their app between an API
  • When you are getting data using an API, you make your request.

    In this flow chart, you see that your app is asking to make a list of Spark rooms, then the Spark server prepares the data and sends the list of spark rooms back.

    And you can have it parsed in any parsing format you want, such as JSON.

    Cisco Spark is a collaborative tool similar to Slack.
  • So your Application would be the API consumer, the request is GET /rooms and the Cisco Spark API is the API Provider.

    Then the return result is a HTTP 200 OK.
  • This is a list of different HTTP routing methods you can use to make a request. Each of these “GET, POST, PUT, DELETE” are Verbs. Each Verb can make an action with a noun.

    GET --- Can get a list of items, or get an individual item id
    POST --- Creates an item
    PUT --- Updates an item
    DELETE – Delete’s an item
  • A great API will have great documentation.

    If people cannot figure out how to use your API, then you will not have as many users as you were hoping for. The most popular API’s out there have very well written documentation.

    You could have the best API in the world, but if developers cannot figure out how to use it, they will find something else.
  • As an example, I’m going to use Cisco Spark’s API Reference.

    So for each section in the API Reference, which are the Nouns, you can do 5 Verbs

    For People, you can create a person, get person details, update a person, delete a person, and get my own details.

    For Messages, you can List rooms, Create a Room, Get Room Details, Update a Room, and Delete a Room
  • How do you know what kind of parameters you can use for each section of the API Reference?

    What can I do when I’m working with the section “MESSAGES”?

    This is the list of parameters you can use for the messages
  • Okay, so what is an API?
  • There are a lot of different ways you can debug or test your APIs.

    The one I use the most is POSTMAN, the GUI HTTP Client to test API Calls.
  • Postman is a free tool to forge API Requests and examine responses. You can install it on a Mac as an app or install the Chrome plugin Postman.

    For Mozilla or Safari, you can install a plugin called RESTClient
  • Using the Github API, you add the resource URL in the box next to where you select your method, which is the verb to use.

    Then you hit SEND and will receive a response http code.

    The HTML page contents are placed in the Body
  • So hopefully you are ready to start programming with APIs!
  • Questions?
  • Understanding REST APIs in 5 Simple Steps

    1. 1. ParisJS Meetup December 3rd, 2016 Follow me on Twitter and/or tweet at me. @tessamero By Tessa Mero Understanding REST APIs in 5 Simple Steps
    2. 2. REST != $this
    3. 3. “It’s a way for two pieces of software to talk to each other” Application Programming Interface
    4. 4. STEP 1: Understanding the Purpose of APIs
    5. 5. Why are APIs so Important?
    6. 6. API Growth from 2000 to 2016 0 5000 10000 15000 20000 25000 30000 35000 2000 2005 2007 2009 2011 2013 2015 2016 API's API's Source: 2016 data from nordicapis.com. 2005-2015 data from rubenverborgh.github.io and 2000-2004 data from blog.cutter.com
    7. 7. An API is like … An API (Application Programming Interface) is best thought of as a contract provided by one piece of computer software to another.
    8. 8. APIs help developers create apps that benefit the end user. Yelp asks for Map Data Google Maps returns map data via API Users sees list of restaurants close to them
    9. 9. STEP 2: Learn what REST is
    10. 10. A REST API defines a set of functions which developers can perform requests and receive responses via HTTP protocol such as GET and POST.
    11. 11. REST is best explained as a way to talk to other machines through the server with an HTTP Protocol Using Verbs (actions) and Nouns (items)
    12. 12. STEP 3: Know What Request and Responses are
    13. 13. View a Web Page 13Presentation ID
    14. 14. View a Web Page 14Presentation ID Request GET /index.htm HTTP/1.1 Response HTTP 200 OK <html>
    15. 15. REST APIs use Request and Response too
    16. 16. Get Data using an API (Spark) 16Presentation ID
    17. 17. Get Data using an API – Response! 17Presentation ID Request GET /rooms Response HTTP 200 OK {json data} API Consumer API Provider
    18. 18. List of Verbs!
    19. 19. STEP 4: Documentation is Your Dictionary
    20. 20. API Reference for Rooms (Verbs and Nouns)
    21. 21. Request Parameters for “MESSAGES”
    22. 22. STEP 5: Learn How to Use Debug/Test Tools for APIs
    23. 23. Tools to Debug/Test http://tiny.cc/60tools • Webhook Debugging (RequestBin formerly requestbin.org…) • Webhook Utilities (Torpio…) • Local Tunneling (ngrok...) • API Monitoring (Runscope...) • Response Mocking (mocky.io...) • JSON Utilities (JSONFormat...) • OAUTH Utilities (oauth.io...) • API Directories (APIS.io, ProgrammableWeb...) • API Testing (Runscope Radar...) • Load Testing (loader.io...) • GUI HTTP Clients (POSTMAN...)
    24. 24. POSTMAN!!!!!
    25. 25. method url request headers status code response headers content-type response body query parameters
    26. 26. Add JSON to the Body in POSTMAN
    27. 27. Summary: 1. You Understand the Purpose 2. You Know what REST is 3. Request & Response – Makes sense 4. Documentation – Live by it. 5. Debugging&Test Tools – Prevent headaches
    28. 28. OUI!!!!!!!!
    29. 29. Thank You @tessamero tessamero@gmail.com http://www.slideshare.net/Tessa99

    ×