{"message":"Welcome to RESTlock Holmes!","tagline":"Learn APIs by solving mysteries with code!","howToPlay":["1. Get a mystery: GET /mystery","2. Read the clue and use external APIs to find the answer","3. Submit your answer: POST /submit","4. If correct, get the next clue. If stuck, get a hint!","5. Solve all clues to complete the mystery","Check out the documentation for more details (at /openapi)"],"fetchApiTutorial":{"title":"Using the Fetch API","description":"Here's how to solve mysteries using JavaScript's fetch API","steps":[{"description":"Step 1: Get a mystery to solve","code":["// Get a random mystery ","const response = await fetch('http://localhost:3000/mystery');","const mystery = await response.json(); "," ","console.log(mystery.title); ","console.log(mystery.firstClue.text); ","// Save mysteryId and clueId - you'll need them! "]},{"description":"Step 2: Use external APIs to find the answer","code":["// Example: Using PokeAPI to find information ","const pokeResponse = await fetch('https://pokeapi.co/api/v2/pokemon/pikachu');","const pokeData = await pokeResponse.json(); "," ","// Process the data to find your answer ","const answer = pokeData.game_indices.length.toString(); ","console.log('My answer:', answer); "]},{"description":"Step 3: Submit your answer","code":["// Submit your answer ","const submitResponse = await fetch('http://localhost:3000/submit', {"," method: 'POST', "," headers: { 'Content-Type': 'application/json' }, "," body: JSON.stringify({ "," mysteryId: mystery.mysteryId, "," clueId: mystery.firstClue.id, "," answer: answer "," }) ","}); "," ","const result = await submitResponse.json(); ","console.log(result.message); "," ","if (result.correct && result.nextClue) { "," console.log('Next clue:', result.nextClue.text); ","} else if (result.mysterySolved) { "," console.log('Mystery solved!', result.conclusion); ","} "]},{"description":"Optional: Get a hint if you're stuck","code":["// Get the first hint (no index parameter) ","const hintResponse = await fetch( "," `http://localhost:3000/hint?mysteryId=${mystery.mysteryId}&clueId=${mystery.firstClue.id}` ","); ","const hintData = await hintResponse.json(); ","console.log('Hint:', hintData.hint); "," ","// Get a specific hint by index (e.g., second hint) ","const hint2Response = await fetch( "," `http://localhost:3000/hint?mysteryId=${mystery.mysteryId}&clueId=${mystery.firstClue.id}&index=1`","); ","const hint2Data = await hint2Response.json(); ","console.log('Hint 2:', hint2Data.hint); "]}],"fullExample":{"description":"Complete example: Solving a mystery","code":["async function solveMystery() { "," // 1. Get mystery "," const mystery = await fetch('http://localhost:3000/mystery') "," .then(r => r.json()); "," "," console.log('Mystery:', mystery.title); "," console.log('Clue:', mystery.firstClue.text); "," "," // 2. Use the clue's apiHint to figure out which external API to use"," console.log('API Hint:', mystery.firstClue.apiHint); "," "," // 3. Query external API (example with Dog API) "," const dogData = await fetch('https://dog.ceo/api/breeds/list/all') "," .then(r => r.json()); "," "," // 4. Process data to find answer "," const answer = dogData.message.hound.length.toString(); "," "," // 5. Submit answer "," const result = await fetch('http://localhost:3000/submit', { "," method: 'POST', "," headers: { 'Content-Type': 'application/json' }, "," body: JSON.stringify({ "," mysteryId: mystery.mysteryId, "," clueId: mystery.firstClue.id, "," answer: answer "," }) "," }).then(r => r.json()); "," "," console.log(result.message); "," return result; ","} "," ","solveMystery(); "]}},"tips":["Read the clue carefully - it tells you exactly what to find","Use the apiHint to know which external API to query","Process the API response to extract the specific data you need","Answers are case-insensitive strings","Each clue has multiple hints - use GET /hint to get hints sequentially","Hints are indexed starting at 0. Omit the index to get the first hint","When you run out of hints, the API will return 'No more hints.'","Check the /openapi docs for full API reference"]}
.png)
