Public JSON API

This Document describes the workflow of using public FlypSite data for your own application. All data is stored in JSON format, and can be retrieved as described below.

Preparation in the FlypSite backend

Retrieving messages that are older than the ones in the initial.json (for e.g. Paging) is described below.


The Flow

Workflow



Buckets/Paging

Please note:

The URL for buckets has the following structure:

/rio/s/{stream}/{buckFold}/{buckNum}.json?{commitcode}

The URL can be calculated as follows:


	var pos = envelope-index of the oldest received message (Integer) 
	var buckInt = Math.floor(pos/64);
	
	{buckNum} = String.format("%06x", buckInt);  // results to 000000, 000001, etc.
	{buckFold}  = String.format("%06x", Math.floor(buckInt/256) * 256); // results to 000000, 000100, etc.
	{stream}    = the filename of the stream (out1, out2, content, etc.)
	{commitcode} = the last commitcode you received

If you then want to move back in time, you can retrieve the next bucket by decreasing var buckInt by one (buckInt - 1).



The Files

first.json

This file should be called first of all to trigger the user session, sync local app timestamp to servertime, and retrieve some more info.

{
    "revision": 58,         // the revision of the current data
    "hex": "003a",          // the revision of the current data converted to hex
    "commit": "02a1fd95-8e53-401b-8719-bd4a078609ee",           
                            // uuid of the current commit (uuid)
    "time": 1417426463,     // server time at request (timestamp)
    "user": "06727afb-c9f0-4c23-ab8a-1f583fa39231", 
                            // user ID of current requester (uuid)
    "eventid": 513          // event ID (int)
}

initial.json

Should be called after first.json was loaded and processed, contains all initial envelopes of the event.

Structure (Where to find the main parts of a message):

{
    updates: [
        { ... envelope ... },
        { ... envelope ... },
        { 
          message: {
            text: "xxx",
            headline: "yyy",
            service: "zzz",
            user: { 
              name: "aaa",
              handle: "@aaa",
              icon: "http://..."
            },
            media: { 
              type: "ttt",
              service: "sss",
              url: "http://...",
              image: {
                url: "http://"
              } 

            }
          }
        }
    ]
}

File contents:

{
  "eventid": 513,           // the ID of the event (int)
  "revision": 58,           // current revision (int) 
  "commit": "0edb2c33-eabe-435d-81a2-e7cdb5f580c3", 
                            // current commit (uuid)
  "frames": [],             // array of frames, if any (array)
  "more": false,            // do we have more messages? (boolean)
  "updates": [              // all envelopes live here (array)
    {                       // this is an envelope with text only, posted on twitter (object)
      "id": "6993592",      // the envelope ID, envelopes contain the messages (int)
      "stream": "out1",     // the key of the stream this envelope belongs to (string)
      "index": 46,          // the index-position of this envelope (int)
      "aired": false,       // special TV playout: has this envelope been on air? (boolean)
      "marked": false,      // is this message marked in the backend? (boolean)
      "message": {          // the message (object)
        "type": "message",  // the type of message (string)
        "time": "Mon, 01 Dec 2014 10:05:19 +0100", 
                            // the time when message was created (timestamp)
        "user": {           // user information (hash)
          "service": "twitter",     // which service provided the user (string)
          "name": "hmmonteiro",     // user name (string)
          "handle": "@hmmonteiro",  // user handle, if given (string)
          "icon": "http://pbs.twimg.com/profile_images/487282873129385984/w-VXMnz4.png", 
                                    // URL of user-icon, if given (url)
          "link": "http://twitter.com/hmmonteiro", 
                                    // link to user, if given (url)
          "hash": 1071498533,
          "id": 1579707             // ID of user (int)
        },
        "text": "Join @hack_summit A virtual conference for programmers. Impressive list of speakers. #hacksummit #conference #dev", 
                                // text of message (string)
        "headline": "",         // headline of message (string)
        "info": "",             // info line (string)
        "size": "base", // size of layout (string)
        "layout": "message",    // type of layout (string)
        "style": "plain",       // style of layout (string)
        "service": "twitter",   // the service that provided the message (string)
        "srvid": "539344479267078144", 
                                // service-internal message id
        "srvinfo": "#hacksummit", 
                                // collector match
        "srvlink": "https://twitter.com/hmmonteiro/status/539344479267078144", 
                                // full link to original message
        "id": 5203638           // the ID of the message (int)
    },
    {                           // this is an envelope with media:
      "id": "6965536",          // the envelope ID, envelopes contain the messages (int)
      "stream": "chat",         // the key of the stream this envelope belongs to (string)
      "index": 1,               // the index-position of this envelope (int)
      "aired": false,           // special TV playout: has this envelope been on air? (boolean)
      "marked": false,          // is thie message marked in the backend? (boolean)
      "message": {              // the message (hash)
        "type": "message",      // the type of message (string)
        "time": "Fri, 28 Nov 2014 15:58:13 +0100", 
                                // time the message was created (timestamp)
        "user": {               // user information (object)
          "service": "flyphq",      // which service provided the message (string)
          "name": "Jakub Kolacz",   // user name (string)
          "handle": "",             // user handle (string)
          "icon": "http://www.gravatar.com/avatar/923c691779b1646953a7c8ccd194b903?d=retro", 
                                    // url of user icon (url)
          "link": "",               // link to user (url)
          "hash": 1606971581,       // internal use
          "id": 1575797             // id of user (int)
        },
        "text": "",             // text of message (string)
        "headline": "",         // headline of message (string)
        "info": "",             // info line (string)
        "size": "base",         // size of layout (string)
        "layout": "video",      // type of layout (string)
        "style": "plain",       // style of layout (string)
        "media": {              // media of message, if any (hash)
          "type": "video",      // type of media (string)
          "service": "youtube", // service of media (string)
          "key": "sVErCepAaxw", // key of media (string)
          "image": {            // (preview-) image of media (object)
            "url": "https://i.ytimg.com/vi/sVErCepAaxw/hqdefault.jpg", 
                                    // url of image (url)
            "width": 0,             // width of image (int)
            "height": 0,            // height of image (int)
            "center": {             // location of the desired centerpoint of image (object)
              "x": 0,               // x-position of centerpoint (int)
              "y": 0                // y-position of centerpoint (int)
            },
            "zoom": false       // shall we zoom the image for display? (boolean)
          },
          "url": "http://www.youtube.com/v/sVErCepAaxw?autohide=1&version=3", 
                                // the url of the media (url)
          "source": "https://www.youtube.com/watch?v=sVErCepAaxw", 
          "poster": "https://i.ytimg.com/vi/sVErCepAaxw/hqdefault.jpg", 
                                // posterframe of media, if any (url)
          "id": 1683431         // the ID of the media (int)
        },
        "service": "flyphq",    // the service of the message (string)
        "srvinfo": "new",       // internal only
        "id": 5183717           // the ID of the message (int)
      }
    }
  ]
}

carrier.json

Minimal file to fetch current revision

{ 
    "revision": 68,         // current revision (int)
    "commit": "430006e5-c780-45b9-962f-f74d97842628", 
                            // current commit (uuid)
    "eventid": 513          // event ID (int)
}

hex.json (eg. 001f.json)

Construct the file name by converting the revision into a four-digit hex value.

Contents of the file: see initial.json.