v1.0.0

QCR uses the socket.io library for managing background messaging/socket messaging but just about any websocket client can be used. https://socket.io

To connect to the socket server use the following URL:

ws://feed.quantumcricketleague.com:3010/socket.io/?EIO=3&transport=websocket&token=public

If using the socket.io library (available for many platforms) you do not need to maintain the socket connection with pings or prefix your messages, this is handled for you.

OUTBOUND REQUESTS

If using a vanilla websocket library you will need to ping the QCR server every 5 seconds in order to maintain the connection. Simply send (ping) the prefix string '2' and the server will pong with a string '3'. All other messages should be prefixed with the string '42'.

2

If using socket.io then you can ignore ping/pong and prefixes:

socket.emit("<message type>",<data object or array>})

key-match-data

A convenience function to return match state without subscribing to a match's live event feed. Useful more for retrieving historical match data as opposed to a polling method for fetching a current scrore.

'42["key-match-data"]'

inmatch

Subscribes you to a match feed. This applies to historical games as well as live ones. Because QCR sends you a key-match-data message immediately on subscribing a historical match can be reviewed at the end of the first innings and the end of the game. See the key-match-data message in the INBOUND MESSAGES section below. Historical matches will receive no further events, only live matches will receive activity events such as toss, runin, swap, score and end. The command string to send is:

'42["msg",{"action":"inmatch","id":"\<matchid\>"}]'

outmatch

Unsubscribes you from a match feed. The command string to send is:

'42["msg",{"action":"outmatch","id":"\<matchid\>"}]'

INBOUND MESSAGES

tm

A tm or Tournament Message is emitted whenever a match score changes. It simply contains the match status string. These are sent out on the stream regardless of whether you are subscribed to a match or not.

Object Properties Type Description
action string 'status-update'
matchid integer match id number
tourid integer tournament id number
status string html formatted match/score status

key-match-data

This message is automatically issued when you subscribe to a match feed but can also be requested directly even if not subscribed. The object returned is an array and can be empty if the match toss has not been issued yet:

Object Properties Type Description
array 1,2 or 3 elements depending on match status
- [0] data object toss message (see msg.action = toss below)
- [1] data object swap message (see msg.action = swap below)
- [2] data object end message (see msg.action = end below)

msg

Messages of type msg are only sent when subscribed to a match feed. The message actions and their properties are described below.

msg.action = queued

Indicates a game is about to start and includes the time value in seconds until the toss.

Object Properties Type Description
action string 'queued'
msgidx integer always 1
timetotoss integer seconds until toss message expected
data object empty object
- scoremsg object
matchid integer match id number
tourid integer tournament id number

msg.action = toss

The same object as the score message except the data object is populated.

Object Properties Type Description
action string 'toss'
msgidx integer match message sequence number
- data object
choice string 'bowl' or 'bat'
winner integer toss winning team ID
-- teamA object
id integer team ID
aux integer aux hex colour string i.e. '#ffff00
name string team name
colour string hex colour string i.e. '#ffff00
lineup string comma separated list of player names
-- teamB object
id integer team ID
aux integer aux hex colour string i.e. '#ffff00
name string team name
colour string hex colour string i.e. '#ffff00
lineup string comma separated list of player names

msg.action = swap

The last score message of the first innings. content as per score message.

msg.action = runin

A simple message to indicate the bowler is running in. You can use this and the score messages to control video clip playback and other display features for example.

msg.action = end

The same object as the score message except the data object is populated.

Object Properties Type Description
action string 'end'
msgidx integer match message sequence number
- data object
winner string banner i.e. 'Chennai won by 11 runs'
winnerid integer winning team ID
-- leaguetable array 3 objects(rows)
--- [0] - first row is headers (titles)
a string unused
b string 'Played'
c string 'Won'
d string 'Lost'
e string 'Points'
f string 'For'
g string 'Against'
h string 'Overs For'
i string 'Overs Against'
--- [1-2] - team A and team B stats
a integer team id
b integer matches played
c integer matches won
d integer matches lost
e integer points
f integer for
g integer against
h integer overs for
i integer overs against

msg.action = score

Generated when the score is updated. This message contains many sub-objects containing complete game state information you can use to drive the video clips and generate charts etc.

Object Properties Type Description
action string 'score'
msgidx integer match message sequence number
- data object empty unless toss message
- scoremsg object
matchid integer
tournamentid integer
inn1 string
inn2 string
inn1overs integer
- nextball
next float this over, next ball ie 11.2
notes string unused
batsman string name
bowler string name
batsmanID integer
bowlerID integer
- lastball
last float this over, this ball ie 11.1
notes string outcome as string i.e. '2 runs'
batsman string name
bowler string name
ballcode integer indicator for which action clip to play
batsmanID integer
bowlerID integer
- headline
-- batting
team string
runs integer
wickets integer
overs string
teamID string
-- batter1
name string
runs integer
balls integer
batterID string
-- batter2
name string
runs integer
balls integer
batter2ID string
- batting obj array 14 objects(rows)
-- [0] - first row is headers (titles)
a string unused
b string batting team name i.e. 'Mumbai'
c string 'MOD'
d string 'R'
e string 'B'
f string '4'
g string '6'
h string 'D'
i integer batting team ID '5'
-- [1-11] - batsman data
a integer batting order number
b string batter name
c string how out
d integer runs
e integer balls
f integer fours
g integer sixes
h integer dots
i integer batter ID
-- [12] - 13th row is extras
a string unused
b string 'Extras'
c string summary '(3wd, 1nb, 1lb, )'
d integer sum of extras
e string unused
f string unused
g string unused
h string unused
i string unused
-- [13] - 14th row is totals
a string unused
b string 'Total'
c string '(For n wkts)'
d integer total runs
e integer total balls
f integer total fours
g integer total sixes
h integer total dots
i float total overs
- bowling obj array 12 objects(rows)
-- [0] - first row is headers (titles)
a string unused
b string bowling team name i.e. 'Hyderabad'
c string 'Ov'
d string 'Wd'
e string 'NB'
f string 'R'
g string 'Wkt'
h string '(Details)'
i integer team ID
-- [1-11] - bowler data
a integer bowler number
b string bowler name
c string how out
d integer runs
e integer balls
f integer fours
g integer sixes
h string breakdown i.e. (1x 4s, 0x 6s, 5x dots)
i integer bowler ID
- charts obj array 21 objects(rows)
-- [0] - first row is headers (titles)
a string unused
b string team A name i.e. 'Mumbai'
c string 'Wickets'
d string 'Total'
e string 'RunRate'
f string team B name i.e. 'Hyderabad'
c string 'Wickets'
d string 'Total'
e string 'RunRate'
-- [1-20] - stats
a integer over number
b integer team A over runs
c integer team A wickets
d integer team A runs
e float team A run rate
f integer team B over runs
g integer team B wickets
h integer team B runs
i float team B run rate
- partnerships obj array 11 objects(rows)
-- [0] - first row is headers (titles)
a string unused
b string 'A'
c string 'B'
d string 'A Runs'
e string 'B Runs'
-- [1-10] - stats
a integer partnership number
b string player A name
c string player B name
d integer player A runs
e integer player B runs
- scoregrid obj array 20 objects(rows)
-- [0-19] - stats
a integer over number
b string bowler name
c integer ball 1 outcome code
d integer ball 2 outcome code
e integer ball 3 outcome code
f integer ball 4 outcome code
g integer ball 5 outcome code
h integer ball 6 outcome code
i integer ball 7 outcome code
j integer ball 8 outcome code
k integer ball 9 outcome code
l integer ball 10 outcome code
m integer runs
n integer total
o integer wickets
- predictions obj array 21 objects(rows) for chart generation
-- [0] - first row is headers (titles)
a string 'Over'
b string 'Lookup'
c string 'Innings Runs'
d string 'Match'
-- [1-20] - stats
a integer over number
b integer lookup
c integer innings runs
d float match
- markets obj array 10 objects(rows)
-- [0-9]
a string market name
b float line
c integer % over
d integer % under