title: Lost Invention Mission
The Lost Invention Mission is an interactive guide that helps users understand how to utilize the API for retrieving information about lost inventions. This document provides step-by-step instructions and code samples in both TypeScript and Python.
Make sure you have the following before you start:
- Your API key
- The base API URL
To interact with the API, you need to set your API key and base URL. You can do this in the code samples provided below.
Define a section in the left panel by wrapping content with the step
tag. Each step must have a unique id
.
Use chunk annotations to control which lines are highlighted in the right panel when a step becomes active in a code walkthrough.
sdk.ts
export async function fetchInventions(apiKey: string, baseUrl: string) {
const response = await fetch(`${baseUrl}/inventions`, {
headers: {
'Authorization': `Bearer ${apiKey}`
}
});
return response.json();
}
usage.ts
import { fetchInventions } from './sdk';
const apiKey = 'YOUR_API_KEY';
const baseUrl = 'YOUR_BASE_API_URL';
fetchInventions(apiKey, baseUrl).then(data => {
console.log(data);
});
sdk.py
import requests
def fetch_inventions(api_key, base_url):
response = requests.get(f"{base_url}/inventions", headers={
'Authorization': f'Bearer {api_key}'
})
return response.json()
usage.py
from sdk import fetch_inventions
api_key = 'YOUR_API_KEY'
base_url = 'YOUR_BASE_API_URL'
data = fetch_inventions(api_key, base_url)
print(data)
- Refer to the README files in the
_filesets/typescript
and_filesets/python
directories for installation instructions and additional details on running the scripts.