Challenge - 5 Problems
Link Relations Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate1:30remaining
What is the output of this REST API response with link relations?
Given the following JSON response from a REST API, what is the value of the "next" link relation URL?
Rest API
{
"data": ["item1", "item2"],
"links": {
"self": "https://api.example.com/items?page=1",
"next": "https://api.example.com/items?page=2",
"prev": null
}
}Attempts:
2 left
💡 Hint
Look for the "next" key inside the "links" object.
✗ Incorrect
The "next" link relation provides the URL for the next page of items, which is "https://api.example.com/items?page=2".
🧠 Conceptual
intermediate1:30remaining
What is the purpose of link relations in REST API responses?
Why do REST APIs include link relations like "self", "next", and "prev" in their responses?
Attempts:
2 left
💡 Hint
Think about how clients can use these links to move between pages or related data.
✗ Incorrect
Link relations help clients discover related resources or actions by providing URLs with semantic names like "next" or "self".
🔧 Debug
advanced2:00remaining
Why does this REST API response cause a client error when following the "next" link?
Consider this JSON response snippet:
{
"links": {
"self": "https://api.example.com/items?page=1",
"next": "htp://api.example.com/items?page=2"
}
}
Why will a client fail to fetch the "next" page?
Attempts:
2 left
💡 Hint
Check the URL scheme spelling carefully.
✗ Incorrect
The "next" link URL uses "htp" which is not a valid scheme, causing clients to fail when trying to fetch it.
📝 Syntax
advanced2:00remaining
Which option correctly represents a HAL-style link relation in JSON?
HAL (Hypertext Application Language) uses a specific JSON format for links. Which of the following is the correct HAL link representation for a "self" link?
Attempts:
2 left
💡 Hint
HAL requires the "href" key inside the link object.
✗ Incorrect
HAL defines links inside an "_links" object with each link as an object containing an "href" property.
🚀 Application
expert2:00remaining
How many link relations are present in this paginated API response?
Given this JSON response:
{
"data": ["a", "b"],
"links": {
"self": "https://api.example.com/data?page=3",
"first": "https://api.example.com/data?page=1",
"prev": "https://api.example.com/data?page=2",
"next": "https://api.example.com/data?page=4",
"last": "https://api.example.com/data?page=10"
}
}
How many distinct link relations are included in the "links" object?
Attempts:
2 left
💡 Hint
Count all keys inside the "links" object.
✗ Incorrect
The "links" object contains "self", "first", "prev", "next", and "last" — a total of 5 link relations.