Challenge - 5 Problems
API Scripting Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
What is the output of this curl command?
You run this command to get JSON data from a public API:
What will be the output?
curl -s https://api.agify.io?name=michael | jq '.age'What will be the output?
Bash Scripting
curl -s https://api.agify.io?name=michael | jq '.age'Attempts:
2 left
💡 Hint
jq extracts specific fields from JSON output.
✗ Incorrect
The command fetches JSON data about the name 'michael' and jq extracts the 'age' field, which is a number.
📝 Syntax
intermediate1:30remaining
Which curl command correctly sends JSON data via POST?
You want to send JSON data '{"name":"Alice"}' to an API endpoint using curl. Which command is correct?
Attempts:
2 left
💡 Hint
APIs expect the Content-Type header to match the data format.
✗ Incorrect
To send JSON data, you must set the Content-Type header to application/json and use POST method.
🔧 Debug
advanced2:00remaining
Why does this bash script fail to parse JSON correctly?
This script tries to get the 'token' field from an API response:
But token is empty. Why?
response=$(curl -s https://example.com/api/login)
token=$(echo "$response" | jq '.token')But token is empty. Why?
Bash Scripting
response=$(curl -s https://example.com/api/login) token=$(echo "$response" | jq '.token')
Attempts:
2 left
💡 Hint
Think about how bash handles variables with spaces or newlines.
✗ Incorrect
Without quotes, $response loses its JSON structure when passed to echo, causing jq to fail.
🚀 Application
advanced2:30remaining
How to extract all user IDs from a paginated API using bash?
An API returns user data in pages. Each page has a 'users' array and a 'next_page' URL or null if last page.
Write a bash approach to collect all user IDs from all pages.
Write a bash approach to collect all user IDs from all pages.
Attempts:
2 left
💡 Hint
Pagination requires multiple requests following the next page links.
✗ Incorrect
You must loop through pages, extract IDs, and continue until no next page is given.
🧠 Conceptual
expert2:00remaining
What is the main risk of using curl with user input in a bash script?
You write a bash script that takes a URL from user input and runs:
What is the biggest security risk here?
curl "$user_url"What is the biggest security risk here?
Attempts:
2 left
💡 Hint
Think about how bash interprets variables and special characters.
✗ Incorrect
If user input is not sanitized, it can inject commands or options that run unintended code.