Follow

User Info API

User Info API

This REST API enables you to obtain information from the Kahuna system that has been collected from a specific user. Information available includes

Note: Kahuna allows a maximum of 1 user per request.

API Request

Request URI and Header

Request URI - HTTP POST

 

To target the production environment: https://tap-nexus.appspot.com/api/userinfo?env=p

To target the sandbox environment: https://tap-nexus.appspot.com/api/userinfo?env=s

 

Request Header

Content-Type: application/json

Authorization: The API uses Basic Authentication (BasicAuth), which requires credentials in the form of a username (Secret Key) and password (API Key).

The Secret Key and API Key for the namespace are:

Secret Key: Available in Settings
API Key: Available in Settings

KAHUNA_API_CHECKSUM: API checksum to validate the request

The value of the KAHUNA_API_CHECKSUM header is calculated as the MD5 hash of (the API Key reversed + the user credential value in this request)

Python example:

hashlib.md5(api_key[::-1] + credential_value).hexdigest()
Request Body

The request body is a JSON object that contains the credentials of a user (limit 1 per request).

 

In the request body, users are formatted as a dictionary of credentials that identify a user.

The following table describes the User Info object format.

Fields
target_user

Required. A dictionary of user credential key-value pairs.

  • Each key must be a Kahuna white-listed user credential type.
  • You can specify only one credential.
Example
{
   "target_user": 
      {"email": "george@example.com"}
}

API Response

The response to a User Info API request consists of an HTTP response code and a response body in JSON format.

HTTP Response Codes
Codes
200

The servers successfully parsed the request, and authentication and authorization also succeeded.

Note: This response code is returned even if all the update requests fail. For example, this response code is returned if parsing and authentication or authorization succeed but the servers are unable to find any of the specified users.

400 Parsing error. You specified invalid options or the JSON is written incorrectly. The response body provides error details.
401 Authentication error. Your credentials are written incorrectly or your credentials are not valid. The response body provides error details.
409 Authorization error. Your user name and password are authorized for Kahuna but you do not have permission to use the User Attributes API.
500 Kahuna internal server error.
Response Body

The response body is an object that contains one or more response object elements, depending on the HTTP response code:

  • HTTP response code 200—the object contains an element for the User object in the request body.
  • HTTP response codes 400, 401, 409, and 500—the array contains a single response object that provides additional information about the error.

Note: If the HTTP response code is not 200, the response object represents the status of the overall request instead of the status of the request for an individual user.

Response Object

The format of a response object is shown in the following table.

Fields
success

The status of the delete request for the user. If true, the request succeeded. No other fields are present in the response object. If false, the request failed. Other fields in the response object provide additional information about the failure.

error

If an error occurred, this field provides a human-readable error message.

error_code

If an error occurred, this field provides an HTTP error code. Error code 404 indicates that the servers cannot find the user given the supplied credentials. This code is not returned in the overall HTTP response code.

Example
{
   "target_user": 
      {"email": "george@example.com"},
}

If the user credential "email": "george@example.com" points to an existing user then the HTTP response code is 200 and the response body resembles the following JSON:

{
	"user":{
		"first_visit":"2018-05-06 00:00:00",
		"last_visit":"2018-05-07 00:00:00",
		"devices":[
			{
				"id":"620ba9e8-c789-483e-90b7-34d298e4d106",
				"last_seen":"2018-05-07 00:00:00"
			}
		],
		"events":[
			{
				"dev_id":"620ba9e8-c789-483e-90b7-34d298e4d106",
				"event":"k_user_login",
				"time":1525662222.3340001
			},
			{
				"dev_id":"620ba9e8-c789-483e-90b7-34d298e4d106",
				"properties":{
					"item_id":[
						"257"
					]
				},
				"event":"add_to_cart",
				"time":1525662191.046011
			}
		],
		"attributes":{
			"kahuna_email_domain":"example.com",
			"kahuna_lang":"en",
			"name":"George Doe",
			"kahuna_tz":"GMT+08:00",
		},
		"credentials":[
			{
				"email":"george@example.com"
			},
			{
				"user_id":"620ba9e8-c789-483e-1111-34c2988ad106"
			}
		],
		"id":1220970021
	},
	"success":true
}

If the user credential "email": "george@example.com" does not point to an existing user then the HTTP response code is 200 and the response body resembles the following JSON:

{
"error_code": 404,
"success": false,
"error": "User not found"
}
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments