# Basic Usage ## Python Example ```python import requests # Initialize client API_KEY = "your_api_key_here" BASE_URL = "https://api.example.com/v1" headers = { "Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json" } # List resources response = requests.get( f"{BASE_URL}/resources", headers=headers ) if response.status_code == 200: resources = response.json()["data"] for resource in resources: print(f"Resource: {resource['name']}") else: print(f"Error: {response.status_code}") ``` ## JavaScript/Node.js Example ```javascript const API_KEY = "your_api_key_here"; const BASE_URL = "https://api.example.com/v1"; async function listResources() { const response = await fetch(`${BASE_URL}/resources`, { method: "GET", headers: { "Authorization": `Bearer ${API_KEY}`, "Content-Type": "application/json" } }); if (response.ok) { const data = await response.json(); data.data.forEach(resource => { console.log(`Resource: ${resource.name}`); }); } else { console.error(`Error: ${response.status}`); } } listResources(); ``` ## cURL Example ```bash curl -X GET "https://api.example.com/v1/resources" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" ``` ## Creating a Resource ### Python ```python import requests data = { "name": "My Resource", "type": "document" } response = requests.post( f"{BASE_URL}/resources", json=data, headers=headers ) if response.status_code == 201: new_resource = response.json()["data"] print(f"Created: {new_resource['id']}") ``` ### JavaScript ```javascript async function createResource(name, type) { const response = await fetch(`${BASE_URL}/resources`, { method: "POST", headers: { "Authorization": `Bearer ${API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ name, type }) }); const data = await response.json(); return data.data.id; } ```