Complete cURL examples for testing and integrating Byul REST API
Pro Tip: cURL examples work on all platforms (Linux, macOS, Windows) and are perfect for testing API endpoints before implementing in your application.
# Get latest news firstLATEST_ID=$(curl -s -X GET "https://api.byul.ai/api/v2/news?limit=1" \ -H "X-API-Key: byul_api_key" | jq -r '.items[0]._id')# Later, get news since that IDcurl -X GET "https://api.byul.ai/api/v2/news?sinceId=$LATEST_ID" \ -H "X-API-Key: byul_api_key"
# Test API in CI pipeline#!/bin/bashset -eecho "Testing Byul API connectivity..."response=$(curl -s -w "HTTPSTATUS:%{http_code}" \ -X GET "https://api.byul.ai/api/v2/news?limit=1" \ -H "X-API-Key: $BYUL_API_KEY")http_code=$(echo $response | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')if [ $http_code -eq 200 ]; then echo "✓ API connection successful"else echo "✗ API connection failed with code: $http_code" exit 1fi
# Simple parallel requestsfor i in {1..5}; do curl -s -X GET "https://api.byul.ai/api/v2/news?limit=10" \ -H "X-API-Key: byul_api_key" &donewaitecho "All requests completed"
# Export your API keyexport BYUL_API_KEY="byul_api_key"# Use in requestscurl -X GET "https://api.byul.ai/api/v2/news?minImportance=8" \ -H "X-API-Key: $BYUL_API_KEY"# Or from filecurl -X GET "https://api.byul.ai/api/v2/news?limit=10" \ -H "X-API-Key: $(cat ~/.byul_api_key)"
Security Best Practice: Never hardcode API keys in scripts. Always use environment variables or secure files with proper permissions.