Custom API
Introduction
We may not yet support your platform for getting data into Fanplayr 360, so we offer a powerful API to work directly with our system to add data.
You can use the Custom API to send data from a server, or a mobile app. The options a limitless.
The JavaScript API uses exactly the same calls under the hood.
Sending Messages
Once you have created a Custom Integration before starting, to get a WRITE_KEY and ENDPOINT which you can then use to send data to Fanplayr 360.
Calling the API is as simple as making an HTTPS
request with the following details:
URL:
https://<ENDPOINT>/v1/collect
Method:
POST
Headers
content-type: application/json
x-api-key: <WRITE_KEY>
Body: A JSON string containing an array of Messages.
Example Request
The API can only handle messages of ~250kb, so we calling the API with no more than 20 Messages in one call.
Message Structure
Each message you send to Fanplayr 360 needs to contain a basic set of data.
Basic Message
writeKey - The WRITE_KEY that is sent through in the
x-api-key
must also be supplied here.timestamp - The time the event happened in ISO-8601 format and UTC time zone ie "2023-01-23T15:34:48Z".
type - The type of the message.
userId - A unique identifier for this user. If the same
userId
is supplied in a different session the messages will be treated as if they were from the same user. This is separate from managing identify usingidentify
calls.sessionId - A unique identifier for a session. See Handling Sessions for more details.
pageId - A unique identifier for the current page / screen view. This is used to tie events together. See Tracking Page Views.
The basic message structure may or may not include context
, properties
, identities
and operations
depending on the type
being sent.
context - can be used in any message type
properties - should only be used in
track
orpage
typeidentities - should only be used in
identify
typeoperations - should only be used in
userDataOps
andconsent
type
Context
Context is used to track information about the page, or screen, the user is on, and their IP address for location, and userAgent to track browser or device type.
page
url - the URL of the page, if tracking on a website.
referrer - the URL of the referring page, if tracking on a website.
type - a string representing the page. Any value can be used here, but some values will add functionality - see JavaScript API / Track Pages. Can also be used to represent "screens" in a mobile app.
title - the page title of the website or app screen.
ipAddress - the IP address of the users device, or the server / device that this message was sent from. It is used to generate extra attributes such as
$country
.userAgent - the User Agent string from a browser, or defined for a device type such as a mobile phone. It is used to generate extra attributes such as
$device
.
Properties
Properties are any key / value pair, or Semantic Object, which you want to track along with the event. This should only be used with track
or page
type Messages.
The key
for a property can be any string value. It is a suggestion to not start the value with a "$" as this may override generated attributes. It may also be good practice to use either camel-case keys such as "myKeyName", and stay away from non-ASCII characters as some systems you export data to may otherwise have problems.
Although you can send in string
, number
or boolean
types all data is stored as strings in Fanplayr 360.
Identities
Identities are key / value pairs that let the system know how to identify and merge users and sessions. This should only be provided for the message type identify
.
Operations
Operations should only be used with the userDataOps
and consent
type messages. The properties supported are different for each.
userDataOps
consent
What next?
Read on to understand how to use each message type, along with examples.
Last updated