User Tools

Site Tools


version_2:get_model

Requesting context models

For requesting a certain context model of a person, this interface can be used. It can be specified, if the complete model or a time-limited model is sent back. To filter the model, the variables category, source and type can be used, multiple filters are also possible (by sending an array of e.g. categories). There is also the possibility to just request a fraction of events. To do this, the variables max (limiting the number of events per request) and offset (where to start, can only be used together with max) can be used. The total number of events is always given.

Since such a context model can be huge, the maximum number of events per request is restricted to 1000. Please use the variables max and offset to request additional events.

Authentication required

Yes, please take a look at Authentication. To keep it simple, only the data parameter is mentioned on this page, but keep in mind that the other parameters are also necessary.

Response

JSON

Method

GET

Resource URL

Parameters

The sent JSON object data should contain the following parameters:

model

A model can either be COMPLETE (resulting in all the available context information of a user) or SPECIFIC (the context information of a certain time period).

start

An optional value, but required for the model SPECIFIC. This is a UNIX timestamp the beginning of the time period.

end

An optional value, but required for the model SPECIFIC. This is a UNIX timestamp the end of the time period.

category

An optional whitelist filter to return only those events of a certain category.

source

An optional whitelist filter to return only those events of a certain source.

type

An optional whitelist filter to return only those events of a certain type.

entities

An optional whitelist filter to return only those events with certain key-value pairs as entity. Be aware that keys and values are case-sensitive.

category_bl

A blacklist filter to return only those events which aren't of a certain category.

source_bl

An optional blacklist filter to return only those events which aren't of a certain source.

type_bl

A blacklist filter to return only those events which aren't of a certain type.

entities_bl

An optional blacklist filter to return only those events without certain key-value pairs as entity. Be aware that keys and values are case-sensitive.

max

This optional variable (together with offset) can be used for pagination. You can specify how many results (if available) should be returned per request. max is limited to 1000 events.

offset

If you specify the maximum of results to be returned, you can specify with the optional variable offset, where this fraction of resulting events should be in the whole set of events. If offset is not given, the newest events are returned.

Example 1

Request

data={
	"model":"SPECIFIC",
	"start":1367493643,
	"end":1367494024,
	"category":"ENVIRONMENT",
	"source":"MOBILE",
	"type":"POSITION",
	"max":7,
	"offset":5
}

Response

{
   "APIVersion":2,
   "result":1,
   "total_events":154,
   "returned_events":7,
   "events":[
      {
         "id":"430",
         "app":"de.thues.bigbrother",
         "source":"MOBILE",
         "action":"START",
         "type":"POSITION",
         "category":"ENVIRONMENT",
         "timestamp":"1367494024",
         "entities":[
            {
               "key":"lat",
               "value":"50.7777497"
            },
            {
               "key":"lng",
               "value":"6.0612095"
            }
         ]
      },
      {
         "id":"429",
         "app":"de.thues.bigbrother",
         "source":"MOBILE",
         "action":"START",
         "type":"POSITION",
         "category":"ENVIRONMENT",
         "timestamp":"1367493947",
         "entities":[
            {
               "key":"lat",
               "value":"50.7787374"
            },
            {
               "key":"lng",
               "value":"6.0590381"
            }
         ]
      },
      {
         "id":"428",
         "app":"de.thues.bigbrother",
         "source":"MOBILE",
         "action":"START",
         "type":"POSITION",
         "category":"ENVIRONMENT",
         "timestamp":"1367493883",
         "entities":[
            {
               "key":"lat",
               "value":"50.7786859"
            },
            {
               "key":"lng",
               "value":"6.0578903"
            }
         ]
      },
      {
         "id":"427",
         "app":"de.thues.bigbrother",
         "source":"MOBILE",
         "action":"START",
         "type":"POSITION",
         "category":"ENVIRONMENT",
         "timestamp":"1367493823",
         "entities":[
            {
               "key":"lat",
               "value":"50.7787717"
            },
            {
               "key":"lng",
               "value":"6.0571058"
            }
         ]
      },
      {
         "id":"426",
         "app":"de.thues.bigbrother",
         "source":"MOBILE",
         "action":"START",
         "type":"POSITION",
         "category":"ENVIRONMENT",
         "timestamp":"1367493763",
         "entities":[
            {
               "key":"lng",
               "value":"6.0560441"
            },
            {
               "key":"lat",
               "value":"50.7789188"
            }
         ]
      },
      {
         "id":"425",
         "app":"de.thues.bigbrother",
         "source":"MOBILE",
         "action":"START",
         "type":"POSITION",
         "category":"ENVIRONMENT",
         "timestamp":"1367493703",
         "entities":[
            {
               "key":"lat",
               "value":"50.7792587"
            },
            {
               "key":"lng",
               "value":"6.054866"
            }
         ]
      },
      {
         "id":"424",
         "app":"de.thues.bigbrother",
         "source":"MOBILE",
         "action":"START",
         "type":"POSITION",
         "category":"ENVIRONMENT",
         "timestamp":"1367493643",
         "entities":[
            {
               "key":"lat",
               "value":"50.7793209"
            },
            {
               "key":"lng",
               "value":"6.0544413"
            }
         ]
      }
   ]
}

Example 2

Request

data={
   "model":"SPECIFIC",
   "start":1370584254,
   "end":1370602739,
   "entities":[
      {
         "key":"app",
         "value":"Gmail"
      },
      {
         "key":"package",
         "value":"com.google.android.talk"
      }
   ]
}

Response

{
   "APIVersion":2,
   "result":1,
   "total_events":9,
   "returned_events":9,
   "events":[
      {
         "id":"12502",
         "app":"de.thues.bigbrother",
         "source":"MOBILE",
         "action":"END",
         "type":"APPSTART",
         "category":"ACTIVITY",
         "timestamp":"1370602739",
         "session":"5o5irl4x2a",
         "entities":[
            {
               "key":"app",
               "value":"Hangouts"
            },
            {
               "key":"package",
               "value":"com.google.android.talk"
            }
         ]
      },
      {
         "id":"12500",
         "app":"de.thues.bigbrother",
         "source":"MOBILE",
         "action":"START",
         "type":"APPSTART",
         "category":"ACTIVITY",
         "timestamp":"1370602729",
         "session":"5o5irl4x2a",
         "entities":[
            {
               "key":"app",
               "value":"Hangouts"
            },
            {
               "key":"package",
               "value":"com.google.android.talk"
            }
         ]
      },
      {
         "id":"12491",
         "app":"de.thues.bigbrother",
         "source":"MOBILE",
         "action":"END",
         "type":"APPSTART",
         "category":"ACTIVITY",
         "timestamp":"1370594044",
         "session":"u1vascy8ks",
         "entities":[
            {
               "key":"app",
               "value":"Hangouts"
            },
            {
               "key":"package",
               "value":"com.google.android.talk"
            }
         ]
      },
      {
         "id":"12489",
         "app":"de.thues.bigbrother",
         "source":"MOBILE",
         "action":"START",
         "type":"APPSTART",
         "category":"ACTIVITY",
         "timestamp":"1370594014",
         "session":"u1vascy8ks",
         "entities":[
            {
               "key":"app",
               "value":"Hangouts"
            },
            {
               "key":"package",
               "value":"com.google.android.talk"
            }
         ]
      },
      {
         "id":"12487",
         "app":"de.thues.bigbrother",
         "source":"MOBILE",
         "action":"END",
         "type":"APPSTART",
         "category":"ACTIVITY",
         "timestamp":"1370592874",
         "session":"kxbqpa9rku",
         "entities":[
            {
               "key":"app",
               "value":"Hangouts"
            },
            {
               "key":"package",
               "value":"com.google.android.talk"
            }
         ]
      },
      {
         "id":"12486",
         "app":"de.thues.bigbrother",
         "source":"MOBILE",
         "action":"START",
         "type":"APPSTART",
         "category":"ACTIVITY",
         "timestamp":"1370592814",
         "session":"kxbqpa9rku",
         "entities":[
            {
               "key":"app",
               "value":"Hangouts"
            },
            {
               "key":"package",
               "value":"com.google.android.talk"
            }
         ]
      },
      {
         "id":"12420",
         "app":"de.thues.bigbrother",
         "source":"MOBILE",
         "action":"END",
         "type":"APPSTART",
         "category":"ACTIVITY",
         "timestamp":"1370587684",
         "session":"cyo1gkph6i",
         "entities":[
            {
               "key":"app",
               "value":"Gmail"
            },
            {
               "key":"package",
               "value":"com.google.android.gm"
            }
         ]
      },
      {
         "id":"12419",
         "app":"de.thues.bigbrother",
         "source":"MOBILE",
         "action":"START",
         "type":"APPSTART",
         "category":"ACTIVITY",
         "timestamp":"1370587664",
         "session":"cyo1gkph6i",
         "entities":[
            {
               "key":"app",
               "value":"Gmail"
            },
            {
               "key":"package",
               "value":"com.google.android.gm"
            }
         ]
      },
      {
         "id":"12380",
         "app":"de.thues.bigbrother",
         "source":"MOBILE",
         "action":"END",
         "type":"APPSTART",
         "category":"ACTIVITY",
         "timestamp":"1370584254",
         "session":"gqt7alo7kb",
         "entities":[
            {
               "key":"app",
               "value":"Hangouts"
            },
            {
               "key":"package",
               "value":"com.google.android.talk"
            }
         ]
      }
   ]
}

In case of an error, a different response is sent. Please take a look at Error Responses.

version_2/get_model.txt · Last modified: 01.05.2016 21:57 (external edit)