WebSocket Authentication
WebSocket connections require API key authentication for secure access to real-time news streams.Authentication Method
WebSocket authentication uses your API key provided during the connection handshake.API Key Setup
-
Get Your API Key
- Login to Byul API Dashboard
- Your API key is displayed on the dashboard
- API keys start with
byul_v2_
-
Connection Authentication
Authentication Flow
- Connection Request: Client connects with API key in auth options
- Server Validation: Server validates API key and plan permissions
- Authentication Success: Server emits
auth:success
event with user details - Ready for Subscriptions: Client can now subscribe to news streams
Authentication Success Event
Error Handling
Authentication Errors
INVALID_API_KEY
- API key is invalid or malformedPLAN_REQUIRED
- WebSocket access requires Pro/Enterprise planRATE_LIMITED
- Too many authentication attemptsCONNECTION_LIMIT
- Maximum connections exceeded for plan
Security Best Practices
Environment Variables
Never hardcode API keys in your source code. Use environment variables:Production Configuration
- Node.js
- React
- Python
API Key Protection
Backend Only: Keep API keys on your backend servers. Never expose them to client-side JavaScript in production. Key Rotation: Regularly rotate your API keys for enhanced security. Access Control: Restrict API key access to authorized team members only.Connection Examples
Basic Authentication
With Reconnection
Python Authentication
Troubleshooting
Authentication Issues
Invalid API Key Format- Verify API key format from dashboard
- Check for extra whitespace or characters
- Upgrade your plan
- Verify plan status in dashboard
- Check network connectivity
- Verify firewall settings allow WebSocket connections
- Try connecting from a different network