In addition to the HTTP API, this platform provides an API for bidirectional communication using SockJS. SockJS is a protocol (intended primarily for Javascript) that allows a variety of mechanisms (such as WebSockets) for maintaining a long-lived connection with a server.
This API accepts SockJS connections at the following URL:
https://stream.wingcash.com/bd/sockjs
See the sample bidirectional app
and its source code. It connects to the bidirectional API, sends some “ping” messages, receives responses, and lets the connection sit. Because the example does not subscribe to any feeds, the service will close the connection automatically after 1 minute. If software using the bidirectional API successfully subscribes to a feed, the service leaves the connection open.
Once a bidirectional connection is open, the service is ready to receive JSON-encoded request objects. Every request must have a path
attribute and most require an access_token
. Responses are also encoded in JSON.
When the service sends an error message through a bidirectional channel, it sends an object with error_code
and error
attributes. The error
may be translated by locale. A common error_code
is the string 403
(or 401
), which indicates a permission was denied or an access token is no longer valid.
/ping
When you send a ping, the service responds immediately with a “pong” message.
Request Attributes
path
/ping
Response Attributes
pong
1
.request_message
/wallet/receive-feed
This request subscribes the connection to the feed of cash received by the authenticated profile. The service provides a list of recent posts, then optionally sends a message every time the authenticated profile receives cash.
This API call requires the receive_cash
permission. Unlike most API calls, this API call accepts access tokens that have passed “soft” expiration.
Request Attributes
path
/wallet/receive-feed
access_token
limit
subscribe
false
.before_timestamp
Note
It doesn’t make sense to use subscribe
and before_timestamp
together in a single request.
Response Attributes
The service sends multiple responses. Each response has these attributes:
request_message
posts
ended
limit
parameter. If there are more posts the client could retrieve, this attribute is false
.requested
false
when the message originated from a cash transfer event./wallet/receive-transfers
This request subscribes the connection to a feed of all transfers involving the authenticated profile. Use this to provide live updates of the user’s wallet summary and transfer list.
This API call requires the view_history
permission.
Request Attributes
path
/wallet/receive-transfers
access_token
Subscription Response Attributes
subscribed
Notification Response Attributes
transfer
steps_html
attribute.)