API Documentation
This is the documentation for the available API endpoints, which are built around the REST architecture. All the API endpoints will return a JSON response with the standard HTTP response codes and need a Bearer Authentication via an API Key.
Authentication
All the API endpoints require an API key sent by the Bearer Authentication method.
curl --request GET \
--url 'https://widget.sg/api/{endpoint}' \
--header 'Authorization: Bearer {api_key}' \
--url 'https://widget.sg/api/{endpoint}' \
--header 'Authorization: Bearer {api_key}' \
User
GET https://widget.sg/api/user
curl --request GET \
--url 'https://widget.sg/api/user' \
--header 'Authorization: Bearer {api_key}' \
--url 'https://widget.sg/api/user' \
--header 'Authorization: Bearer {api_key}' \
{ "data": { "id":"1", "type":"users", "email":"example@example.com", "billing":{ "type":"personal", "name":"John Doe", "address":"Lorem Ipsum", "city":"Dolor Sit", "county":"Amet", "zip":"5000", "country":"", "phone":"", "tax_id":"" }, "is_enabled":true, "plan_id":"custom", "plan_expiration_date":"2025-12-12 00:00:00", "plan_settings":{ ... }, "plan_trial_done":false, "language":"english", "timezone":"UTC", "country":null, "date":"2020-01-01 00:00:00", "last_activity":"2020-01-01 00:00:00", "total_logins":10 } }
Campaigns
GET https://widget.sg/api/campaigns/
curl --request GET \
--url 'https://widget.sg/api/campaigns/' \
--header 'Authorization: Bearer {api_key}' \
--url 'https://widget.sg/api/campaigns/' \
--header 'Authorization: Bearer {api_key}' \
Parameters | Details | Description |
---|---|---|
page | Optional | The page number that you want results from. Defaults to 1 . |
results_per_page | Optional | How many results you want per page. Allowed values are: 10 , 25 , 50 , 100 , 250 . Defaults to 25 . |
{ "data": [ { "id": 1, "pixel_key": "1234567890abcdef", "name": "Example", "domain": "example.com", "include_subdomains": true, "branding": { "name": "", "url": "" }, "is_enabled": true, "last_datetime": null, "datetime": "2019-05-22 23:40:17" } ], "meta": { "page": 1, "results_per_page": 25, "total": 1, "total_pages": 1 }, "links": { "first": "https://widget.sg/api/campaigns?&page=1", "last": "https://widget.sg/api/campaigns?&page=1", "next": null, "prev": null, "self": "https://widget.sg/api/campaigns?&page=1" } }
GET https://widget.sg/api/campaigns/{campaign_id}
curl --request GET \
--url 'https://widget.sg/api/campaigns/{campaign_id}' \
--header 'Authorization: Bearer {api_key}' \
--url 'https://widget.sg/api/campaigns/{campaign_id}' \
--header 'Authorization: Bearer {api_key}' \
{ "data": { "id": 1, "pixel_key": "1234567890abcdef", "name": "Example", "domain": "example.com", "include_subdomains": true, "branding": { "name": "", "url": "" }, "is_enabled": true, "last_datetime": null, "datetime": "2019-05-22 23:40:17" } }
Notifications
GET https://widget.sg/api/notifications/
curl --request GET \
--url 'https://widget.sg/api/notifications/' \
--header 'Authorization: Bearer {api_key}' \
--url 'https://widget.sg/api/notifications/' \
--header 'Authorization: Bearer {api_key}' \
Parameters | Details | Description |
---|---|---|
page | Optional | The page number that you want results from. Defaults to 1 . |
results_per_page | Optional | How many results you want per page. Allowed values are: 10 , 25 , 50 , 100 , 250 . Defaults to 25 . |
{ "data": [ { "id": 1, "campaign_id": 1, "notification_key": "d4752d29a557a9fdc67b0a9a27cbe3b1", "name": "Email Collector", "type": "EMAIL_COLLECTOR", "settings": { ... }, "is_enabled": false, "last_datetime": null, "datetime": "2019-05-29 22:30:29" } ], "meta": { "page": 1, "results_per_page": 25, "total": 1, "total_pages": 1 }, "links": { "first": "https://widget.sg/api/notifications?&page=1", "last": "https://widget.sg/api/notifications?&page=1", "next": null, "prev": null, "self": "https://widget.sg/api/notifications?&page=1" } }
GET https://widget.sg/api/notifications/{notification_id}
curl --request GET \
--url 'https://widget.sg/api/notifications/{notification_id}' \
--header 'Authorization: Bearer {api_key}' \
--url 'https://widget.sg/api/notifications/{notification_id}' \
--header 'Authorization: Bearer {api_key}' \
{ "data": { "id": 1, "campaign_id": 1, "notification_key": "d4752d29a557a9fdc67b0a9a27cbe3b1", "name": "Email Collector", "type": "EMAIL_COLLECTOR", "settings": { ... }, "is_enabled": false, "last_datetime": null, "datetime": "2019-05-29 22:30:29" } }
Payments
GET https://widget.sg/api/payments/
curl --request GET \
--url 'https://widget.sg/api/payments/' \
--header 'Authorization: Bearer {api_key}' \
--url 'https://widget.sg/api/payments/' \
--header 'Authorization: Bearer {api_key}' \
Parameters | Details | Description |
---|---|---|
page | Optional | The page number that you want results from. Defaults to 1 . |
results_per_page | Optional | How many results you want per page. Allowed values are: 10 , 25 , 50 , 100 , 250 . Defaults to 25 . |
{ "data": [ { "id": 1, "plan_id": 1, "processor": "stripe", "type": "one_time", "frequency": "monthly", "email": "example@example.com", "name": null, "total_amount": "4.99", "currency": "USD", "status": true, "date": "2021-03-25 15:08:58" }, ], "meta": { "page": 1, "results_per_page": 25, "total": 1, "total_pages": 1 }, "links": { "first": "https://widget.sg/api/payments?&page=1", "last": "https://widget.sg/api/payments?&page=1", "next": null, "prev": null, "self": "https://widget.sg/api/payments?&page=1" } }
GET https://widget.sg/api/payments/{payment_id}
curl --request GET \
--url 'https://widget.sg/api/payments/{payment_id}' \
--header 'Authorization: Bearer {api_key}' \
--url 'https://widget.sg/api/payments/{payment_id}' \
--header 'Authorization: Bearer {api_key}' \
{ "data": { "id": 1, "plan_id": 1, "processor": "stripe", "type": "one_time", "frequency": "monthly", "email": "example@example.com", "name": null, "total_amount": "4.99", "currency": "USD", "status": true, "date": "2021-03-25 15:08:58" } }
Logs
GET https://widget.sg/api/logs/
curl --request GET \
--url 'https://widget.sg/api/logs/' \
--header 'Authorization: Bearer {api_key}' \
--url 'https://widget.sg/api/logs/' \
--header 'Authorization: Bearer {api_key}' \
Parameters | Details | Description |
---|---|---|
page | Optional | The page number that you want results from. Defaults to 1 . |
results_per_page | Optional | How many results you want per page. Allowed values are: 10 , 25 , 50 , 100 , 250 . Defaults to 25 . |
{ "data": [ { "type": "login.success", "ip": "127.0.0.1", "date": "2021-02-03 12:21:40" }, { "type": "login.success", "ip": "127.0.0.1", "date": "2021-02-03 12:23:26" } ], "meta": { "page": 1, "results_per_page": 25, "total": 1, "total_pages": 1 }, "links": { "first": "https://widget.sg/api/payments?&page=1", "last": "https://widget.sg/api/payments?&page=1", "next": null, "prev": null, "self": "https://widget.sg/api/payments?&page=1" } }