Chapter 2 of 6 · Cisco CCNA 200-901 DEVASC

Understanding and Using APIs

REST requests, status codes, authentication, webhooks and the requests library.

  • 7topics
  • 32 minfast track
  • 3diagrams and exhibits
  • 20%of the exam

Topics in this chapter

Take them in order, or jump to the one you need.

  1. 1Constructing a REST API RequestLearn the parts of a REST API request, how HTTP methods map to create, read, update and delete, and how to build a request from…4 min
  2. 2HTTP Responses and Status CodesLearn the three parts of an HTTP response, the five status code classes and the common REST codes such as 200, 201, 204, 400…4 min
  3. 3Troubleshooting API Calls from the ResponseWork out why a REST API call failed by reading the status code, comparing the request with the documentation and checking method…5 min
  4. 4Webhooks and API ConstraintsLearn how webhooks push events to your code, and the limits you meet when consuming APIs such as rate limits, pagination…Diagram5 min
  5. 5API Authentication MechanismsLearn how basic authentication, custom token headers, bearer tokens and API keys work, how to send them from Python, and how to…Diagram5 min
  6. 6API Styles: REST, RPC, Synchronous and AsynchronousCompare REST and RPC API styles and the difference between synchronous and asynchronous calls, with the REST constraints and an…Diagram5 min
  7. 7Calling a REST API with the Requests LibraryWrite a Python script that calls a REST API with the requests library, using get, post, headers, params, json, timeouts, status…4 min

About this chapter

What this chapter covers

This chapter teaches you how programs talk to services over HTTP, which is the skill behind almost every automation task.

You learn to build a REST request from documentation, read the response, fix a failing call and write a Python script that does it all with the requests library.

It also covers the wider ideas around APIs: webhooks, the limits you meet when consuming an API, authentication, and the main API styles.

How the topics fit together

Every API call follows the same path from a request, through authentication, to a response that you must read and sometimes troubleshoot.

Requestmethod, URL, headers, bodycarriesCredentialbasic, token or API keyanswered byResponsestatus, headers, bodyhandled inPython scriptrequests library

The first page shows the parts of a request. The second shows how to read the status line, headers and body of the response. The third combines both to troubleshoot, because a failed call needs you to compare the request with the documentation.

Authentication sits between them. Without the right credential, the best request still returns 401 or 403.

The remaining pages widen the picture. Webhooks reverse the direction so that the server calls you, and API constraints such as rate limits and pagination shape how you write loops.

API styles explain why some calls wait for a result and others return a task ID. The final page pulls everything into a working script.

Note

Later chapters reuse these skills. The Cisco platform APIs in the next chapter all rely on requests, headers, tokens and status codes.

How to use these pages

Each topic page has the same shape, so you can skim for what you need.

  • What it is: the idea in plain words.
  • How it works: the mechanism, with diagrams and short code examples.
  • What to remember for the exam: the facts to memorise.
  • Common mistakes: the classic traps.
  • Check yourself: three questions to test your understanding.

Try the examples against a free public test API or a DevNet sandbox. Seeing a real 401, 404 or 429 teaches more than reading about one. Keep a table of status codes in your head, because many questions give you a code and ask for the cause.

Ready for more practice?

The full Cisco CCNA 200-901 DEVASC question bank has 808 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Cisco. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.