Posted in: Giveaway Features

SweepWidget API Access (Beta)

The SweepWidget API allows read and write data to and from your giveaways. This feature is currently beta and is accepting new feature requests. If you need any specific functionality, feel free to contact us.

First, you must get your API Key. Navigate to Integrations and click on API Access.

Then, copy your API Key.

API Endpoints

Get giveaway entry information

This method allows you to access all of the user entry information for a giveaway.

If uses the following endpoint with the GET method.

https://sweepwidget.com/sw_api/entries.php

Parameters

The following parameters are accepted.

Parameter Format Description Required
api_key String API developer key. Yes
competition_id Integer ID of your competition. Yes
page_start Integer The page you want to start on. JSON output returns 50 rows at a time. Yes

Example output

{
  "data": [
    {
      "user_id": 123785,
      "user_name": "Lisa",
      "user_email": "[email protected]",
      "birthday": "04-25-1994",
      "entry_type": "Twitter Follow",
      "action": "Follow @SweepWidget On Twitter",
      "value": "@AwesomeTwitterProfile",
      "entry_amount": "5",
      "timestamp": "2020-06-26 11:18:21"
      "country": "United States",
      "ip": "943.185.746"
    },
    {
      "user_id": 128734,
      "user_name": "Steven",
      "user_email": "[email protected]",
      "birthday": "06-01-1989",
      "entry_type": "Facebook Like",
      "action": "Like @SweepWidget On Facebook",
      "value": "Steven.123789",
      "entry_amount": "3",
      "timestamp": "2020-06-25 09:15:45"
      "country": "Canada",
      "ip": "123.789.384"
    }
}

Example implementation

The following example uses the get entry information endpoint and is written in PHP.

$curl = curl_init();

$url_get_lists = "https://sweepwidget.com/sw_api/entries.php?api_key=123456789&page_start=1&competition_id=123";

curl_setopt_array($curl, array(
    CURLOPT_URL => $url_get_lists,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => array(
        "Content-Type: application/json" // You must set the content-type to application/json
    ),
));

$response = json_decode(curl_exec($curl));
var_dump($response);

Update whitelisted emails

This method allows you update the whitelisted emails for a single competition. You can optionally update the globally whitelisted emails for all competitions.

If uses the following endpoint with the POST method.

https://sweepwidget.com/sw_api/white-list-emails.php

Parameters

All of the following parameters are accepted.

Parameter Format Description Required
api_key String API developer key. Yes
global Boolean If you want to update the globally whitelisted emails, or just for a single competition. Yes
competition_id Integer ID of your competition. Yes
whitelisted_emails Array Array of the emails you want to whitelist. Yes

Example implementation

The following example uses the post entry information endpoint and is written in PHP.

$post = [
    'api_key' => '123456789',
    'global' => 0, // If you set global => 1, competition_id is not required.
    'competition_id' => '123',
    'whitelisted_emails' => array('[email protected]', '[email protected]', '[email protected]')
];

$post_string = http_build_query($post);

$ch = curl_init('https://sweepwidget.com/sw_api/white-list-emails.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);

$response = curl_exec($ch);
curl_close($ch);
var_dump($response);