Query string parameters:
clientId
(string
, required) — Client ID for remembering last event you requested (see below);secret
(string
, required) — authentication token;channel
(string
, required) — the channel to receive events from;after
(integer
) — only return events whose ID is greater thanafter
;limit
(integer
) — return at mostlimit
events (default to 100).
Will retrieve all recent events for the given channel. In case no new events are available, the request will wait for data until a timeout occurs.
If you do not specify after
, clientId
will be used to populate it:
-
When you explicitly specify
after
: - server saves it underclientId:channel
; - so the server knows which message ID this particular client received from that channel before current request. -
When
after
is not set: - server will pulll it fromclientId:channel
.
This allows to not store last receieved event ID on the client-side, and you can omit after
for the first request to the channel
when client process starts.
[
{ "id": 12,
"timestamp": 1429084002258,
"from": "turngame/v1",
"type": "MOVE",
"data": [1, 2, 3]
},
{ "id": 19,
"timestamp": 1429084002258,
"from": "invitations/v1",
"type": "INVITE",
"data": {"things": 5}
}
]
If secret is invalid.
Body must be a JSON string containing an object which includes the following:
clientId
(string
, required) — Client ID;channel
(string
, required) — the channel to post event to;secret
(string
, required) — authentication token;from
(string
, required) — identifiessender
;type
(string
, required) — identifiesevent
's type;data
(object
, optional) — non-falsyobject
with any custom data you'd like to attach to event.
{ "clientId": "turngame:worker-01",
"channel": "turngame-events",
"secret": "0xDEADBEEF",
"from": "turngame/v1",
"type": "MOVE",
"data": {
"anything": "you'd like",
"flag": true
}
}
Response is an "event header" object contatinig server-assigned Event ID (unique per channel) and JS timestamp.
{ "id": 12,
"timestamp": 1429084002258 }
If secret is invalid.
Query string parameters:
channel
(string
, required) — the channel to receive events from;limit
(integer
, optional) — return at mostlimit
events (default to 100).
Will retrieve all latest events for a given channel
As a user of this service, it's then possible to run backward since we know that event id are auto incremented by channel.
[
{ "id": 12,
"timestamp": 1429084002258,
"from": "turngame/v1",
"type": "MOVE",
"data": [1, 2, 3]
},
{ "id": 19,
"timestamp": 1429084002258,
"from": "invitations/v1",
"type": "INVITE",
"data": {"things": 5}
}
]
If secret is invalid.
Body must be a JSON string containing an object which includes the following:
id
(string
, required) — Id of the index;channel
(string
, required) — the channel to create an index for;secret
(string
, required) — authentication token;field
(string
, required) — identifiesevent
's field to group by;
{
"id": "blocked-users-by-username",
"channel": "users/v1/blocked-users",
"field": "data.username",
"secret": "1"
}
Response is a string indicating that the request is successful
OK
If secret is invalid.
Rest string parameters:
index_id
(string
, required) — the id of the index to retreive events from;value
(string
, required) — return the list of events from index based on this value.
Will retrieve the list of events for a specific index
Some users of the module need to access filtered data. So let the user define indices, so they can retrieve data grouped by a field of their choice.
{
"id": "blocked-users-by-username",
"field": "data.username",
"value": "testuser",
"rows": [
{ "id": 12,
"timestamp": 1429084002258,
"from": "turngame/v1",
"type": "MOVE",
"data": [1, 2, 3]
},
{ "id": 19,
"timestamp": 1429084002258,
"from": "invitations/v1",
"type": "INVITE",
"data": {"things": 5}
}
]
}
If secret is invalid.
The value of "secret" should be equal to the API_SECRET
environment variable.