WebSockets
You can get WebSockets access with any active API key. We don't charge for WebSockets.
We offer WebSockets for various types:
- score
- time
- graph
- incident
- statistics
- innings
- point-by-points
- live-count
Get all updates by type using websockets
const ws = new WebSocket('wss://{sport}.sportdevs.com/live/{type}?token={API-KEY}', ['updates'])
ws.addEventListener('message', ev => console.log(ev.data))
Get all updates by type using server sent events
const es = new EventSource('https://{sport}.sportdevs.com/live/{type}?token={API-KEY}')
es.addEventListener('message', ev => console.log(ev.data))
Get changes for a specific event ID and type using websockets
const ws = new WebSocket('wss://{sport}.sportdevs.com/live/{type}/1?token={API-KEY}', ['updates'])
ws.addEventListener('message', ev => console.log(ev.data))
Get changes for a specific event ID and type using server sent events
const es = new EventSource('https://{sport}.sportdevs.com/live/{type}/1?token={API-KEY}')
es.addEventListener('message', ev => console.log(ev.data))
For more ingo about WebSockets visit this: https://developer.mozilla.org/en-US/docs/Web/API/EventSource