Aptrinsic Data Loader

Updated 3 weeks ago by Angelo Matheou

Utility script to update Aptrinsic user and account data using the Aptrinsic REST API. Requires active Aptrinsic subscription and an Aptrinsic API key (see below for details). An input file containing either user or account data in CSV format is used to update and optionally insert the corresponding records into Aptrinsic. If any errors are encountered during the process, they are logged to the screen and the process continues.

Install

Mac/OSX

Download script to your local computer using this link: aptrinsic_loader

Depends on python (>= v2.7) being installed locally and being present in the path. Most Macs already have Python installed.

There is an install script that will perform the remaining steps on OSX/Mac, download here: install.sh

Run install script:

bash ./install.sh

Windows

Download script to your local computer using this link: aptrinsic_loader

Python (>= 2.7.9) should be installed, see here if it is not: https://www.python.org/downloads/windows/

Install the "requests" library using pip

python -m pip install requests

Usage:

aptrinsic_loader [--insertMissing] [--verbose] [--dryRun] config.json USER|ACCOUNT input.csv

  • Data type (second argument) should either be USER or ACCOUNT
  • If insertMissing is specfied, will insert missing records. Default behavior is to update records that areaptrinsic_loader found
  • If verbose is specified, each operation is logged to stdout
  • If dryRun is specified, no data is changed, inputs are parsed
Mac Example:
./aptrinsic_loader --updateOnly config.json USER users.csv
Windows Example:
aptrinsic_loader --updateOnly config.json USER users.csv

CSV File Example:

id,title,telephone,city,state,latitude,longitude,strtmp1,acceptDate
fred@acme.com,Prez,867-5309,"Hanalei","HI",123,321,cork,1541460825754
mr.speed@example.com,PFC,555-1234,"Beaufort","NC",456,654,ferrule,1541460825754

CSV details:

* Date values are specified as milliseconds since the Unix epoch

* String values can optionally be surrounded with double quotes to escape commas

Config File Example:

{
"apiKey": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"productKey": "AP-XXXXXXXXXXXX-2",
"fieldMapping": {
"USER": {
"identifyId": "id",
"title": "title",
"phone": "telephone",
"location.city": "city",
"location.stateCode": "state",
"location.coordinates.latitude": "latitude",
"location.coordinates.longitude": "longitude",
"customAttributes.strtmp1": "strtmp1",
"customAttributes.acceptDate": "acceptDate"
},
"ACCOUNT": {
"id": "id",
"name": "account_name"
}
}
}

Field Mapping Details:

  • apiKey: From the Aptrinsic Settings/REST API/New API Key screen
  • productKey: From the Aptrinsic Settings/Products screen
  • fieldMapping:
  • Specifies which Aptrinsic fields will be used as targets for the data in the input file.
  • The first field name (the key of the fieldMapping map) is the aptrinsic name, the second (the value) is the name in the CSV input file.
  • The unique identifier field is required for both users (identifyId) and account (id)
  • To specify nested fields, use periods as separators (see location and customAttributes examples above)


How did we do?