REST API Integration
Overview
This document provides a comprehensive guide for integrating with Metica's REST API. It covers prerequisites, endpoints, request headers, authentication, payload structure, and advanced usage examples for event ingestion, personalised offers, smart configurations, and useful event data.
Prerequisites
Before initiating API requests, the Metica onboarding team will provide the following:
API Key: Used to authenticate requests.
Application ID: Used to identify the target application.
These credentials will be referred to as API_KEY
and APP_ID
throughout this document.
API Conventions
Base Endpoint
All API requests should be directed to the following base endpoint:
https://api-gateway.prod-eu.metica.com
Request Headers
Metica's API uses JSON for both request and response payloads. Additionally, some GET
endpoints may use parameters formatted as application/x-www-form-urlencoded
query strings in the URL.
Authentication
Metica's API uses API keys for authentication and authorisation. Include your API key in the X-API-KEY
header for all API requests.
Example Using curl
curl
HTTP Status Codes
Metica's API utilises standard HTTP status codes to indicate the outcome of an operation.
In cases of client errors (e.g., 400
), responses may include a payload describing the invalid part of the request to assist in troubleshooting.
Event Ingestion
The event ingestion endpoint is the primary method for submitting user in-app behaviour data to Metica.
Endpoint
/ingest/v1/events
Request Headers
Request Payload
The payload should include a list of events, with each event containing key-value pairs representing individual user actions.
Example Payload
Example Request Using curl
curl
Response Codes
Mandatory Event Attributes
Personalized Offers
The personalised offers endpoint enables you to fetch offers tailored to specific users.
Endpoint
/offers/v1/apps/<APP_ID>
Request Parameters
Example Request Using curl
curl
Response Example
Smart Config
Description
The Smart Config endpoint allows you to fetch dynamic and personalised configurations.
The set of configuration keys can be restricted through the
keys
parameter.If no keys are provided, the entire configuration will be returned.
In a similar manner to the Personalised Offers endpoint, the request payload can include user attributes that influence the choice of configurations.
Endpoint
/config/v1/apps/<APP_ID>
Request Headers
Request Parameters
Example Request Using curl
curl
Response Example
Useful Event Data
Offer Events
Install Event
The Install
event should be dispatched when the application is installed. Attributes can include acquisitionSource
, device
, and OS
.
Login Event
The Login
event should be dispatched for each user session. Attributes can include device
, OS
, and appVersion
.
Player State Updates
Overwrite Current State
Partial State Update
Last updated