Skip to main content
All CollectionsIntegrations
How can I use the Loopy Loyalty API
How can I use the Loopy Loyalty API
Paul Tomes avatar
Written by Paul Tomes
Updated over 4 years ago

There is no officially documented Loopy Loyalty API.  However Loopy Loyalty account holders can access the same backend that the front-end application uses by looking at the Web Inspector and the API calls being made. 

For convenience and a list of available endpoints, we have documented these endpoints in a Google doc:

The base URL for the API is:

https://api.loopyloyalty.com/v1/

For creating new cards you need to use the endpoint.

This is a public endpoint and does not need any Authorization. Please see a sample request to issue a pass below.

Note that the payload is dynamic based on the campaign; the easiest to find out the payload is to look at the POST the regular Loopy Landing page makes with the Web Inspector, and use that:

Request:
curl 'https://api.loopyloyalty.com/v1/enrol/{CAMPAIGN_ID}' \
 -X POST \
 -H 'Content-Type: application/json;charset=UTF-8' \
 --data-binary '{"regularFields":{"First Name":"Nick","Last name":"Murray","Birthday":"1973-11-22T08:00:00.000Z"},"uniqueIds":{"email":"nick@anatta.com","phone":"+85297700226"}}'

Response:
{"pid":"HjgobIKOzVpIVQ","url":"https://loyalty.is/HjgobIKOzVpIVQ"}

Error Response:
{"error":"(EC002) Could not enrol customer. Looks like you’ve already signed up for this card using nick@anatta.com and +85297700226. Please contact My Company or use a different Email and Mobile Number."}

In above example, the pid is what needs to be used in the next call to get the card details: 

https://api.loopyloyalty.com/v1/card/{pid}

Getting the card details is an authorised endpoint, so the customer will need to add an Authorization header to make sure the request succeeds. The Authorization header needs to contain a valid JWT.

The easiest way to get a valid JWT is to hit up the login endpoint:

Request:
curl 'https://api.loopyloyalty.com/v1/account/login' \
 -X POST \
 -H 'Content-Type: application/json;charset=UTF-8' \
 --data-binary '{"username":"pkosterman", "password":"xxx"}'

Response:
{"email":"pkosterman@gmail.com","token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJidXNpbmVzcyI6IlRoZSBHb2JibGVycyIsImNyZWF0ZVRpbWUfghfghdAxOjUzOjU2LjUxNTA1NDI4WiIsImVtYWlsIjoicGtvc3Rlcm1hbkBnbWFpbC5jb20iLCJleHAiOjE1ODY1Mjg4MjIsImV4cGlyeURhdGUiOiIyMDE3LTEwLTEyVDAsdfgenegloiLCJpYXQiOjE1ODY0NjA0MjIsImloYXNoIjoiOWI5MjNlMjM1OTE1ZTU1M2NhNjc1MDU1Y2I2YzZmNjVhNDlkMjBhNTkyMzYyMTU5NjJiZjY4OWZkNGE5OTM1NiIsImxpbWl0IjozLCJwa0FkbWluIjpmYWxzZSwicGxhbiI6ImdvYmJsZXIiLCJzdGF0dXMiOiJhY3RpdmUiLCJ0cmlhbER1cmF0aW9uIjo0NSwidHJpYWxFeHAiOjAsInVpZCI6IjVZcFhpd3h1OEhEQk9Vc0tPSVFBYU8iLCJ1c2VybmFtZSI6InBrb3N0ZXJtYW4ifQ.54tJuJgURCyPZhHaZAee3xpdZF22hQMVLmft7qSz4aI"}

Error Response:
{"error":"Invalid username \u0026 password combination."}

The above token can then be used to make other authenticated calls. A token is valid for 24 hours.

Getting a card example:

Request:
curl -X GET  -H "Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJidXNpbmVzcyI6IlRoZSBHb2JibGVycyIsImNyZWF0ZVRpbWUfghfghdAxOjUzOjU2LjUxNTA1NDI4WiIsImVtYWlsIjoicGtvc3Rlcm1hbkBnbWFpbC5jb20iLCJleHAiOjE1ODY1Mjg4MjIsImV4cGlyeURhdGUiOiIyMDE3LTEwLTEyVDAsdfgenegloiLCJpYXQiOjE1ODY0NjA0MjIsImloYXNoIjoiOWI5MjNlMjM1OTE1ZTU1M2NhNjc1MDU1Y2I2YzZmNjVhNDlkMjBhNTkyMzYyMTU5NjJiZjY4OWZkNGE5OTM1NiIsImxpbWl0IjozLCJwa0FkbWluIjpmYWxzZSwicGxhbiI6ImdvYmJsZXIiLCJzdGF0dXMiOiJhY3RpdmUiLCJ0cmlhbER1cmF0aW9uIjo0NSwidHJpYWxFeHAiOjAsInVpZCI6IjVZcFhpd3h1OEhEQk9Vc0tPSVFBYU8iLCJ1c2VybmFtZSI6InBrb3N0ZXJtYW4ifQ.54tJuJgURCyPZhHaZAee3xpdZF22hQMVLmft7qSz4aI"  'https://api.loopyloyalty.com/card/HjgobIKOzVpIVQ?includeEvents=true'

Response:
{"card":{"id":"HjgobIKOzVpIVQ","uid":"5YpXiwxu8HDBOUsKOIQAaO","campaignId":"6mBGLQcJTqVXU43tzptyxh","passStatus":"removed","stripImage":{"width":1125,"height":432,"padding":40,"totalStamps":10,"stampImage":"bagel","unstampImage":"bagel","backgroundColor":"#401A6B","backgroundOpacity":1,"stampColor":"#FFFFFF","stampOpacity":1,"unstampColor":"#FFFFFF","unstampOpacity":0.25,"placeholders":true,"placeholderColor":"#6B1D5E","placeholderOpacity":1,"placeholderBorderColor":"#177BE3","placeholderBorderOpacity":1,"rewardsPlaceholders":true,"rewardBorderColor":"#EBFF10","rewardBorderOpacity":1,"rewardBackgroundColor":"#808548","rewardBackgroundOpacity":1,"rewardPositions":0,"stampedStatus":1,"imageType":"svg"},"totalStampsEarned":1,"totalRewardsEarned":0,"totalRewardsRedeemed":0,"lastStampEarnedDate":"2019-04-03T10:10:57Z","customerDetails":{"Nme":"Ryan"},"object":"card","createYear":2018,"createMonth":5,"createDay":7,"createTime":"2018-05-07T04:33:54Z","updateTime":"2019-04-03T10:10:57Z","chainTx":"5f1aced14faf5c2ff0b17075113976ce435541438f6fb03becd30e0ac205280f","dataConsentOptIn":true},"events":[{"id":190601,"uuid":"bf4d866a-3afe-4afa-9be5-79e62b1b91f4","card_id":"HjgobIKOzVpIVQ","username":"pkosterman","type":0,"quantity":1,"location_name":"","reward_name":"","s_lat":null,"s_lon":null,"ip":"172.20.83.90","ua":"Mozilla/5.0 (iPhone; CPU iPhone OS 11_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.0 Mobile/15E148 Safari/604.1","referrer":"https://app.loopyloyalty.com/landing-page/6mBGLQcJTqVXU43tzptyxh","created":"2018-05-07T04:33:55Z"},{"id":190602,"uuid":"af5cc28f-05c5-4204-a58e-1fc686181d1c","card_id":"HjgobIKOzVpIVQ","username":"pkosterman","type":5,"quantity":0,"location_name":"","reward_name":"","s_lat":null,"s_lon":null,"ip":"","ua":"iOS Wallet Daemon","referrer":"","created":"2018-05-07T04:34:03Z"},{"id":200741,"uuid":"c05e6cb4-6780-4623-b96d-9ef5a2f945a4","card_id":"HjgobIKOzVpIVQ","username":"pkosterman","type":5,"quantity":0,"location_name":"","reward_name":"","s_lat":null,"s_lon":null,"ip":"","ua":"iOS Wallet Daemon","referrer":"","created":"2018-05-12T03:32:22Z"},{"id":835348,"uuid":"ac8cc1ac-5466-4b4e-9062-4b156a1e43cc","card_id":"HjgobIKOzVpIVQ","username":"pkosterman","type":5,"quantity":0,"location_name":"","reward_name":"","s_lat":null,"s_lon":null,"ip":"","ua":"iOS Wallet Daemon","referrer":"","created":"2019-01-31T13:34:34Z"},{"id":1062698,"uuid":"61aff1ca-e665-4ece-861d-7d5e7eb7dc02","card_id":"HjgobIKOzVpIVQ","username":"pkosterman","type":1,"quantity":1,"location_name":"","reward_name":"","s_lat":null,"s_lon":null,"ip":"172.20.83.90","ua":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0.3 Safari/605.1.15","referrer":"https://app.loopyloyalty.com/","created":"2019-04-03T10:10:58Z"},{"id":1763449,"uuid":"18ff4e8c-ad74-437a-81c4-2f748ea912f7","card_id":"HjgobIKOzVpIVQ","username":"pkosterman","type":5,"quantity":0,"location_name":"","reward_name":"","s_lat":null,"s_lon":null,"ip":"","ua":"iOS Wallet Daemon","referrer":"","created":"2019-09-20T07:45:40Z"},{"id":2413925,"uuid":"b6a71b6e-b088-43c4-9b53-b9b6ce7f3a08","card_id":"HjgobIKOzVpIVQ","username":"pkosterman","type":6,"quantity":0,"location_name":"","reward_name":"","s_lat":null,"s_lon":null,"ip":"","ua":"iOS Wallet Daemon","referrer":"","created":"2020-01-10T03:26:48Z"}]}

Error Response:
{"error":"User is not authorized for this operation."}
OR
{"error":"(EC039) Token is invalid."}


Did this answer your question?