0
0
Rest APIprogramming~20 mins

Why REST APIs exist - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
REST API Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Purpose of REST APIs
Why do REST APIs exist in software development?
ATo store large amounts of data locally on a user's device
BTo compile source code into machine code
CTo create graphical user interfaces for desktop applications
DTo allow different software systems to communicate over the internet using a standard set of rules
Attempts:
2 left
💡 Hint
Think about how apps and websites talk to each other over the internet.
Predict Output
intermediate
2:00remaining
Output of a REST API call simulation
What is the output of this simulated REST API call in Python?
Rest API
def get_user():
    return {'id': 1, 'name': 'Alice'}

response = get_user()
print(response['name'])
AAlice
B1
C{'id': 1, 'name': 'Alice'}
DKeyError
Attempts:
2 left
💡 Hint
Look at what key is accessed in the dictionary.
🔧 Debug
advanced
2:00remaining
Identify the error in REST API response handling
What error will this code produce when handling a REST API response?
Rest API
response = {'status': 404, 'message': 'Not Found'}
print(response['data'])
AValueError
BTypeError
CKeyError
DNo error, prints None
Attempts:
2 left
💡 Hint
Check if the key 'data' exists in the dictionary.
📝 Syntax
advanced
2:00remaining
Syntax error in REST API request code
Which option contains a syntax error in this Python REST API request snippet?
Rest API
import requests
response = requests.get('https://api.example.com/data')
print(response.json())
A
import requests
response = requests.get('https://api.example.com/data')
print(response.json())
B
import requests
response = requests.get('https://api.example.com/data'
print(response.json())
C
import requests
response = requests.get('https://api.example.com/data')
print(response.json)
D
))(nosj.esnopser(tnirp
)'atad/moc.elpmaxe.ipa//:sptth'(teg.stseuqer = esnopser
stseuqer tropmi
Attempts:
2 left
💡 Hint
Look for missing or extra parentheses.
🚀 Application
expert
2:00remaining
Number of items in REST API JSON response
Given this JSON response from a REST API, how many user objects does it contain?
Rest API
response = {
  "users": [
    {"id": 1, "name": "Alice"},
    {"id": 2, "name": "Bob"},
    {"id": 3, "name": "Charlie"}
  ]
}

count = len(response['users'])
print(count)
A3
B1
C2
D0
Attempts:
2 left
💡 Hint
Count the number of dictionaries inside the 'users' list.