Accelerate the Value of Data

Search Relation Events with Cursor

The Search Relation Events with Cursor function returns the records matching the specified criteria with a strictly defined order.

This function works like a cursor in relational databases. When using this function, some character sequences are returned to the API user as a part of the response and all the subsequent requests with this cursor, then returns the next portion of data in the defined order. Note that no data is repeated in the entire dataset that is returned.

This API endpoint does not check for long-term storage, hence, it will not return any data older than 4 months.

Request:

POST {TenantURL}/relations/_events/_scan
Table 1. Parameters
Parameter RequiredDetailsExample
Headers Authorization YesInformation about authentication access token in the format of "Bearer <accessToken>" (see details in Authentication API ).
Query filter NoEnables events filtering by a condition. Format for the filter query parameter is, filter=({Condition Type}[AND/OR {Condition Type}]*)

To know more about the conditions, see Relations Filtering.

Note: Consider the following points:
  • Following are the fields and its values that are available for search:
    • timestamp
    • relation_type
    • relation_uri
    • eventType
  • The eventType field can have the following values:
    • RELATIONSHIP_CREATED
    • RELATIONSHIP_CHANGED
    • RELATIONSHIP_REMOVED
Consider the following examples:
  • Filter by relation_uri: filter=(equals(relation_uri, 'relations/005ZBhp')
  • Filter by relationType: filter=(equals(relation_type, 'HasAddress')
  • Filter by event timestamp: filter=(gt(timestamp, 1373288685810) and lt(timestamp,1373288903390))
QuerytypesNoIndicates a comma-separated list of event types using which events must be filtered.types=CREATED,UPDATED
QueryoffsetNoPositive Integer value to identify starting what element in a result set must be returned in a response.offset=100
QuerymaxNoIndicates the maximum number of events to be retrieved.max=200
Request bodyCursor definition Yes for all requests except the first one.Indicates the JSON object that defines the cursor value and must have one JSON attribute cursor with the sub-JSON structure having one string attribute value.
{   
   "cursor" : {
       "value" : "cXVlcnlBbmRGZXRjaDsxOzE0NDI3OmpzdTdBNGNnUWU2YlBqc1JQbTlNbnc7MDs="
   }
}

Response:

Indicates a JSON object with the cursor specification and the response part.

Request

POST {TenantURL}/relations/_events/_scan?filter=(gt(timestamp, 1373288685810) and lt(timestamp,1373288903390))

Response

GET {TenantURL}/relations/_events/_scan?filter=(gt(timestamp, 1373288685810) and lt(timestamp,1373288903390))
Headers: Authorization: Bearer 204938ca-2cf7-44b0-b11a-1b4c59984512
{
  "cursor": {
    "value": "c2NhbjswOzE7dG90YWxfaGl0czo1MDs="
  },
  "objects": [
    {
      "type": "CREATED",
      "relation_type": "HasAddress",
      "startEntityUri": "entities/01X59nt",
      "endEntityUri": "entities/01X5E49",
      "startEntityCrosswalks": [
        {
          "uri": "relations/01WhavR/crosswalks/4TuT",
          "type": "configuration/sources/Veeva",
          "sourceTable": "Account",
          "value": "001K000000gNpCQIA0",
          "createDate": "2013-08-21T09:41:13.842+04:00",
          "updateDate": "2013-08-21T09:41:13.842+04:00"
        },
        {
          "uri": "relations/01WhavR/crosswalks/4Tyb",
          "type": "configuration/sources/Veeva",
          "sourceTable": "Account",
          "value": "001K000000gON8nIAG",
          "createDate": "2013-08-21T09:41:13.842+04:00",
          "updateDate": "2013-08-21T09:41:13.842+04:00"
        }
      ],
      "timestamp": 1377063574083,
      "relation_uri": "relations/01WhavR"
    },
    {
      "type": "CREATED",
      "relation_type": "HasAddress",
      "startEntityUri": "entities/01X59nt",
      "endEntityUri": "entities/01X5IKP",
      "startEntityCrosswalks": [
        {
          "uri": "relations/01WhfBh/crosswalks/4U2j",
          "type": "configuration/sources/Veeva",
          "sourceTable": "Account",
          "value": "001K000000gNpCQIA0",
          "createDate": "2013-08-21T09:41:13.842+04:00",
          "updateDate": "2013-08-21T09:41:13.842+04:00"
        },
        {
          "uri": "relations/01WhfBh/crosswalks/4U6r",
          "type": "configuration/sources/Veeva",
          "sourceTable": "Account",
          "value": "001K000000gON8nIAG",
          "createDate": "2013-08-21T09:41:13.842+04:00",
          "updateDate": "2013-08-21T09:41:13.842+04:00"
        }
      ],
      "timestamp": 1377063575034,
      "relation_uri": "relations/01WhfBh"
    }
  ]
}

Consequent Request - get next data part

POST {TenantURL}/relations/_events/_scan
Headers: Authorization: Bearer 204938ca-2cf7-44b0-b11a-1b4c59984512
{
  "cursor": {
    "value": "c2NhbjswOzE7dG90YWxfaGl0czo1MDs="
  }
}

Response

POST {TenantURL}/relations/_events/_scan
Headers: Authorization: Bearer 204938ca-2cf7-44b0-b11a-1b4c59984512
{
  "cursor": {
    "value": "c2NhbjswOzE7dG90YWxfaGl0czo1MDs="
  },
  "objects": [
    {
      "type": "CREATED",
      "relation_type": "HasAddress",
      "startEntityUri": "entities/01X59nt",
      "endEntityUri": "entities/01X5E49",
      "startEntityCrosswalks": [
        {
          "uri": "relations/01WhavR/crosswalks/4TuT",
          "type": "configuration/sources/Veeva",
          "sourceTable": "Account",
          "value": "001K000000gNpCQIA0",
          "createDate": "2013-08-21T09:41:13.842+04:00",
          "updateDate": "2013-08-21T09:41:13.842+04:00"
        },
        {
          "uri": "relations/01WhavR/crosswalks/4Tyb",
          "type": "configuration/sources/Veeva",
          "sourceTable": "Account",
          "value": "001K000000gON8nIAG",
          "createDate": "2013-08-21T09:41:13.842+04:00",
          "updateDate": "2013-08-21T09:41:13.842+04:00"
        }
      ],
      "timestamp": 1377063574083,
      "relation_uri": "relations/01WhavR"
    },
    {
      "type": "CREATED",
      "relation_type": "HasAddress",
      "startEntityUri": "entities/01X59nt",
      "endEntityUri": "entities/01X5IKP",
      "startEntityCrosswalks": [
        {
          "uri": "relations/01WhfBh/crosswalks/4U2j",
          "type": "configuration/sources/Veeva",
          "sourceTable": "Account",
          "value": "001K000000gNpCQIA0",
          "createDate": "2013-08-21T09:41:13.842+04:00",
          "updateDate": "2013-08-21T09:41:13.842+04:00"
        },
        {
          "uri": "relations/01WhfBh/crosswalks/4U6r",
          "type": "configuration/sources/Veeva",
          "sourceTable": "Account",
          "value": "001K000000gON8nIAG",
          "createDate": "2013-08-21T09:41:13.842+04:00",
          "updateDate": "2013-08-21T09:41:13.842+04:00"
        }
      ],
      "timestamp": 1377063575034,
      "relation_uri": "relations/01WhfBh"
    }
  ]
}