0
0
Rest APIprogramming~10 mins

Why documentation drives adoption in Rest API - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set the API base URL.

Rest API
api_base_url = "[1]"
Drag options to blanks, or click blank then click option'
Ahttps://api.example.com
Bapi.example.com
Chttp//api.example.com
Dexample.com/api
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the protocol (https://) causes connection errors.
2fill in blank
medium

Complete the code to add a header for JSON content type.

Rest API
headers = {"Content-Type": "[1]"}
Drag options to blanks, or click blank then click option'
Atext/plain
Btext/html
Capplication/xml
Dapplication/json
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'text/html' or 'application/xml' instead of 'application/json'.
3fill in blank
hard

Fix the error in the code to correctly send a GET request using the requests library.

Rest API
response = requests.[1](api_base_url, headers=headers)
Drag options to blanks, or click blank then click option'
Aget
Bput
Cpost
Ddelete
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'post' or 'put' instead of 'get' for fetching data.
4fill in blank
hard

Complete the code to parse JSON response and extract the 'data' field.

Rest API
json_response = response.[1]()
data = json_response"data"
Drag options to blanks, or click blank then click option'
Ajson
Bget
C[
D.
Attempts:
3 left
💡 Hint
Common Mistakes
Using dot notation instead of brackets to access dictionary keys.
5fill in blank
hard

Fill both blanks to create a dictionary comprehension filtering items with value > 10.

Rest API
filtered = {k: v for k, v in data.items() if v [1] 10 and [2](k, str)}
Drag options to blanks, or click blank then click option'
A:
B>
Cisinstance
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' instead of ':' in dictionary comprehension.
Using '==' instead of '>' for comparison.
Using dot notation instead of isinstance for type checking.