API Key Authentication
API Key authentication is the standard method for all partner integrations.
Overview
- Header:
ls-api-key - Format:
ls_proj_v1_<random_string> - Scope: All operations within your project
- Expiration: Never (managed by Lunar Stream admin)
Receiving Your API Key
Your API Key and Project ID will be provided by Lunar Stream admin. You will receive:
API Key: ls_proj_v1_ydi3lLihcIW0Z9ZAkGz2BjV6caLYqzK41TQAGblW-4E
Project ID: ce4b77e3-3ed0-47ee-a307-ade5f3fbef91Important
Store your API Key securely. Contact Lunar Stream admin if you need to regenerate it.
Using API Key
Include the API Key in the ls-api-key header:
bash
curl -X GET "https://api.lunarstream.kozow.com/api/v1/livestream?projectId=YOUR_PROJECT_ID" \
-H "ls-api-key: ls_proj_v1_ydi3lLihcIW0Z9ZAkGz2BjV6caLYqzK41TQAGblW-4E" \
-H "Content-Type: application/json"javascript
const axios = require('axios');
const client = axios.create({
baseURL: 'https://api.lunarstream.kozow.com/api/v1',
headers: {
'ls-api-key': process.env.LUNAR_STREAM_API_KEY,
'Content-Type': 'application/json'
}
});
const response = await client.get('/livestream', {
params: { projectId: process.env.LUNAR_STREAM_PROJECT_ID }
});python
import requests
import os
headers = {
'ls-api-key': os.environ['LUNAR_STREAM_API_KEY'],
'Content-Type': 'application/json'
}
response = requests.get(
'https://api.lunarstream.kozow.com/api/v1/livestream',
headers=headers,
params={'projectId': os.environ['LUNAR_STREAM_PROJECT_ID']}
)API Key Permissions
With your API Key, you can perform these operations:
| Operation | Endpoint | Method |
|---|---|---|
| List media servers | /media-servers/available | GET |
| Create livestream | /livestream | POST |
| Get livestream | /livestream/:id | GET |
| List livestreams | /livestream | GET |
| Update livestream | /livestream/:id | PATCH |
| Delete livestream | /livestream/:id | DELETE |
| Generate push token | /livestream/generate-push-token | POST |
Environment Configuration
Store your credentials in environment variables:
bash
# .env file
LUNAR_STREAM_API_URL=https://api.lunarstream.kozow.com/api/v1
LUNAR_STREAM_API_KEY=ls_proj_v1_ydi3lLihcIW0Z9ZAkGz2BjV6caLYqzK41TQAGblW-4E
LUNAR_STREAM_PROJECT_ID=ce4b77e3-3ed0-47ee-a307-ade5f3fbef91Error Responses
| Status | Error | Description |
|---|---|---|
| 401 | UNAUTHORIZED | Missing or invalid API Key |
| 403 | FORBIDDEN | API Key doesn't have access to resource |
json
{
"statusCode": 401,
"message": "Invalid API Key",
"error": "Unauthorized"
}Security Best Practices
- Store securely - Use environment variables or secret managers
- Never commit - Add
.envto.gitignore - Server-side only - Never expose in client-side code
- Monitor usage - Check for unusual API activity
- Report issues - Contact admin immediately if key is compromised