Deprecated
. You should probably look into using the Content
API instead, which also offer real-time
delivery of content.
The push API allows real-time access to feeds defined on the tt.se web site. The API is available using either WebSockets (Socket.IO) or HTTP long poll.
The WebSocket API is built on socket.io. The client emits
messages with a JSON payload containing an array of request parameters
and a callback which will be called when a response is received. In
addition, updates to subscribed feeds are pushed from server to client
with the subject update
.
The main entry point is https://app.tt.se/punkt/ap/socket.io
. Clients will be
redirected to a login page unless they send a valid session cookie.
var socket = io.connect('https://app.tt.se', {
path: '/punkt/ap/socket.io',
query: { ak: '<YOUR KEY HERE>' }
})
socket.on('connect', () => {
socket.emit('getfeedmeta', [{name: '<FEED NAME HERE>'}], console.log)
socket.on('update', console.log)
})
Returns structure that describes what is part of the feed.
name
- name of feed like "mypush"
.Returns feed for given name.
Request
name
- name of feed. "mypush"
.from
- uri to start from, all newer entries from this will be
returned.Response
hits
- array of hitbegin
- boolean set to true if the returned hits are from the beginning.Returns older feed items
Request
name
- name of feed. "mypush"
.from
- uri to start fromamount
- amount of articles to getResponse
hits
- array of hitSubscribes to updates to the given feed name. This command must be reissued every 30 seconds to keep getting updates. We do this to ensure that the client is driving whether we are keeping cached entries for a user. If subscribe stops, the cache can be allowed to expire.
name
- name of feed. "mypush"
uri
- the uri of the item to fetchAll operations that are part of the WebSocket API also have corresponding HTTP endpoints:
https://app.tt.se/punkt/v1/getfeedmeta
https://app.tt.se/punkt/v1/getfeed
https://app.tt.se/punkt/v1/getold
https://app.tt.se/punkt/v1/subscribe
https://app.tt.se/punkt/v1/getitem
Request parameters remain the same, and are passed as regular query
parameters. In addition, you must also provide a
valid API Key through the ak
parameter. The response body
contains a JSON payload with the same contents as with the
WebSocket API.
Example:
curl "https://app.tt.se/punkt/v1/getfeedmeta?name=mypush&ak=<YOUR KEY HERE>"
In addition to the above endpoints, the HTTP Long Poll API provides an endpoint for receiving updates to subscribed feeds:
https://app.tt.se/punkt/v1/update
New feed items are pushed from server to client as they arrive.
To subscribe to feed and receive continuous updates as new items arrive.
# every 30 secs do this
https://app.tt.se/punkt/v1/subscribe?name=<YOUR FEED NAME>&ak=<YOUR KEY HERE>
# this call "hangs" until there is content available
https://app.tt.se/punkt/v1/update?name=<YOUR FEED NAME>&ak=<YOUR KEY HERE>