Updates and Deletes API - LiquidAnalytics/ld-api-examples GitHub Wiki

Updates

Use this API to get a list of records that have been modified since last time the API was called.

POST /ls/api/items/updates

Post parameters:

Parameter Description
itemType Item type as per LD schema
processedAfter Timestamp . 0 to retrieve all data from the beginning.
lastId Item h_id. Null (not specified) to retrieve all data from the beginning.
max Maximum number of results to return

The output of the API has the following structure:

{
	"items": [ 
    ...
       ],
	"maxProcessedAt": maximumTimestampOfReturnedItems,
        "lastId": lastItemIdOfReturnedITems
}

The API should be called repeatedly until items.length()<max to retrive all items updated since specific time. The next call should be made with the value from last maxProcessedAt and lastId, rather than caller’s clock to ensure accuracy.

For example, initial call to retrieve all "Account" items:

headers = {'content-type':'application/json', 'Authorization':'Bearer ' + accessToken}
resp = requests.post(options.hostUrl + '/ls/api/items/updates', headers=headers, data={
       "itemType":"Account",
       "max":10}
      )

The result will look like this:

{
    "items" : [
 ... account items ...
    ],
    "maxProcessedAt":1393650000000,
    "lastId":"ae12ef678716238767eeef887"
}

To retrieve the next batch:

headers = {'content-type':'application/json', 'Authorization':'Bearer ' + accessToken}
resp = requests.post(options.hostUrl + '/ls/api/items/updates', headers=headers, data={
       "itemType":"Account",
       "processedAfter": 1393650000000,
       "lastId":"ae12ef678716238767eeef887",
       "max":10}
      )

If no items have been updated, the response will have an empty "items" element.

For an example of a Python script that retrieves accounts updated since March 1st,2014 in batches of 10 see here