API Authentication
ExplainThis uses API keys to authenticate requests. You'll need to include your API key in all requests to access the API endpoints.
Getting Your API Key
- 1
Sign in to your ExplainThis account at dashboard.explainthis.ai
- 2
Navigate to the API section in your dashboard settings
- 3
Click "Generate API Key" to create a new key
Using Your API Key
Include your API key in the request headers using the X-API-Key header:
cURL Example
curl -X POST https://api.explainthis.ai/v1/explain \
-H "X-API-Key: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{"code": "function hello() { return 'world' }"}'JavaScript/TypeScript
const response = await fetch('https://api.explainthis.ai/v1/explain', {
method: 'POST',
headers: {
'X-API-Key': 'your_api_key_here',
'Content-Type': 'application/json',
},
body: JSON.stringify({
code: 'function hello() { return "world" }',
}),
});Python
import requests
response = requests.post(
'https://api.explainthis.ai/v1/explain',
headers={
'X-API-Key': 'your_api_key_here',
'Content-Type': 'application/json',
},
json={
'code': 'function hello() { return "world" }',
},
)Environment Variables
For security, we recommend storing your API key in environment variables:
.env
EXPLAINTHIS_API_KEY=your_api_key_hereSecurity Warning
Never commit your API key to version control or share it publicly. If your key is compromised, regenerate it immediately from your dashboard.
API Key Best Practices
- Keep your API key secure and never share it
- Use environment variables to store your key
- Rotate your keys periodically
- Use different keys for development and production
- Monitor your API key usage in the dashboard