REST API
Use the REST API to add new participants, trigger loyalty actions, get campaign data, and get participant data from a secure environment.
Getting started
Step 1: Get your API key
Go to your LoyaltySurf Account page
Generate a new API key (if you don't already have one) or click on your existing API key to copy it to your clipboard
Do not use the RESTful API in browser applications. Exposing your secret API key within front end code exposes it to security risks. Anybody with a bit of programming knowledge could potentially hijack your API key and begin making requests on your behalf.
Step 2: Set up authentication
The LoyaltySurf REST API uses your API key to authenticate requests. Here's how to set up authentication:
Set a plain text header named
Authorizationwith the contents beingBearer <YOUR_API_ACCESS_KEY>where<YOUR_API_ACCESS_KEY>is your API key.
Example Authenticated Request
curl -X "GET" "https://api.loyaltysurf.io/v1/campaign/4pdlhb" -H "Authorization: Bearer TWZ4X4NXESMX03MT66HHS6Z9Z91E"OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.loyaltysurf.io/v1/campaign/4pdlhb")
.get()
.addHeader("Authorization", "Bearer TWZ4X4NXESMX03MT66HHS6Z9Z91E")
.build();
Response response = client.newCall(request).execute();const request = require("request");
const options = {
method: 'GET',
url: 'https://api.loyaltysurf.io/v1/campaign/4pdlhb',
headers: {
Authorization: 'Bearer TWZ4X4NXESMX03MT66HHS6Z9Z91E'
}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});import requests
url = "https://api.loyaltysurf.io/v1/campaign/4pdlhb"
headers = {
'Authorization': "Bearer TWZ4X4NXESMX03MT66HHS6Z9Z91E"
}
response = requests.request("GET", url, headers=headers)
print(response.text)<?php
$request = new HttpRequest();
$request->setUrl('https://api.loyaltysurf.io/v1/campaign/4pdlhb');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
'Authorization' => 'Bearer TWZ4X4NXESMX03MT66HHS6Z9Z91E'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.loyaltysurf.io/v1/campaign/4pdlhb"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer TWZ4X4NXESMX03MT66HHS6Z9Z91E")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}Base URL
All endpoints for the LoyaltySurf REST API start with the same base URL:
https://api.loyaltysurf.io/v1Next steps
Last updated
Was this helpful?