cURL Examples
Command-line examples for every AudioSpliter API endpoint.
Set Your API Key
export API_KEY="as_live_abc123"
export BASE_URL="https://api.audiospliter.com/api/v1"
Splits
Create a Split Job
curl -X POST "$BASE_URL/splits" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"sourceUrl": "https://example.com/audio.mp3",
"splitMode": "duration",
"segmentDuration": 600,
"outputFormat": "mp3",
"webhookUrl": "https://your-app.com/webhooks"
}'
List Jobs
curl "$BASE_URL/splits?status=completed&limit=10" \
-H "X-API-Key: $API_KEY"
Get Job
curl "$BASE_URL/splits/job_abc123" \
-H "X-API-Key: $API_KEY"
Delete Job
curl -X DELETE "$BASE_URL/splits/job_abc123" \
-H "X-API-Key: $API_KEY"
API Keys
Create Key
export JWT="your_jwt_token"
curl -X POST "$BASE_URL/api-keys" \
-H "Authorization: Bearer $JWT" \
-H "Content-Type: application/json" \
-d '{
"name": "Production",
"scopes": ["splits:read", "splits:write"]
}'
List Keys
curl "$BASE_URL/api-keys" \
-H "Authorization: Bearer $JWT"
Rotate Key
curl -X POST "$BASE_URL/api-keys/key_abc123/rotate" \
-H "Authorization: Bearer $JWT"
Revoke Key
curl -X DELETE "$BASE_URL/api-keys/key_abc123" \
-H "Authorization: Bearer $JWT"
Billing
Get Billing Info
curl "$BASE_URL/billing" \
-H "Authorization: Bearer $JWT"
Get Usage
curl "$BASE_URL/billing/usage?period=current" \
-H "Authorization: Bearer $JWT"
Subscribe
curl -X POST "$BASE_URL/billing/subscribe" \
-H "Authorization: Bearer $JWT" \
-H "Content-Type: application/json" \
-d '{"planId": "plan_pro"}'
Scripting: Split and Download
#!/bin/bash
set -e
API_KEY="as_live_abc123"
BASE_URL="https://api.audiospliter.com/api/v1"
# Create job
JOB_ID=$(curl -s -X POST "$BASE_URL/splits" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"sourceUrl": "https://example.com/audio.mp3",
"splitMode": "duration",
"segmentDuration": 600
}' | jq -r '.id')
echo "Job created: $JOB_ID"
# Poll until complete
while true; do
STATUS=$(curl -s "$BASE_URL/splits/$JOB_ID" \
-H "X-API-Key: $API_KEY" | jq -r '.status')
echo "Status: $STATUS"
[ "$STATUS" = "completed" ] && break
[ "$STATUS" = "failed" ] && echo "Job failed!" && exit 1
sleep 5
done
# Download segments
curl -s "$BASE_URL/splits/$JOB_ID" \
-H "X-API-Key: $API_KEY" | \
jq -r '.segments[].downloadUrl' | \
while read -r url; do
wget -q "$url" -P ./segments/
done
echo "Done!"