Challenge - 5 Problems
REST API Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Purpose of REST APIs
Why do REST APIs exist in software development?
Attempts:
2 left
💡 Hint
Think about how apps and websites talk to each other over the internet.
✗ Incorrect
REST APIs exist to enable different software systems to communicate with each other over the internet using a common set of rules. This makes it easier to build and connect applications.
❓ Predict Output
intermediate2: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'])
Attempts:
2 left
💡 Hint
Look at what key is accessed in the dictionary.
✗ Incorrect
The function returns a dictionary with keys 'id' and 'name'. The code prints the value for the key 'name', which is 'Alice'.
🔧 Debug
advanced2: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'])Attempts:
2 left
💡 Hint
Check if the key 'data' exists in the dictionary.
✗ Incorrect
The dictionary does not have a key named 'data', so trying to access it causes a KeyError.
📝 Syntax
advanced2: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())
Attempts:
2 left
💡 Hint
Look for missing or extra parentheses.
✗ Incorrect
Option B is missing a closing parenthesis on the get() call, causing a SyntaxError.
🚀 Application
expert2: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)Attempts:
2 left
💡 Hint
Count the number of dictionaries inside the 'users' list.
✗ Incorrect
The 'users' key holds a list of 3 user dictionaries, so the count is 3.