API Guide

 

GETFEED

https://couponapi.org/api/getFeed/

REQUEST PARAMETERS

·       API_KEY

o   required

·       format

o   optional

o   Possible Values: csv|json

o   Default Value: csv

·       incremental

o   optional

o   Possible Values: 0|1

o   Default Value: 0

o   Explanation: If set to 1, the incremental feed will be called, ie. only new, updated or deleted offers since your last extract will be returned.

·       last_extract

o   optional

o   Possible Values: UNIX Timestamp in seconds

o   Example Value: 1553990400

o   Default Value: Your last extract datetime as recorded by our system.

o   Explanation: If you are calling an ‘incremental’ feed, then Coupon API returns only the new, updated & deleted offers since your last extract. You can use this field to pass a custom value instead of using the last extract recorded by our system.

·       off_record

o   optional

o   Possible Values: 0|1

o   Default Value: 0

o   Explanation: Our system keeps a track of your API calls to understand which offers to send when an ‘incremental’ feed is called. If in case, you want to test the API while it is already being used on a live website, you can set this parameter to 1 in your test website. This way, your last extract time will not be updated in our system, and hence there will be no disturbance to your live website. Note that this call will still be counted in your daily limit.

SAMPLE REQUEST

API call for full feed

https://couponapi.org/api/getFeed/?API_KEY=[YOUR_API_KEY]

API call for incremental feeds

https://couponapi.org/api/getFeed/?API_KEY=[YOUR_API_KEY]&incremental=1&last_extract=1553990400

RESPONSE PARAMETERS

·       offer_id

o   integer

o   A unique ID for the offer.

·       title

o   string

o   Heading of the offer

·       description

o   string

o   Detailed description about the offer

·       code

o   string

o   Coupon Code required to avail the offer. This field will be empty if coupon code is not required.

·       featured

o   Possible Values: Yes|No

·       source

o   string

o   The name of the Affiliate Network/Program from where this offer was fetched

·       url

o   url

o   Final landing page of the offer. May be blank if not provided at source.

·       affiliate_link

o   url

o   Affiliate Link required to monetize the offer.

·       image_url

o   url

o   url of the image to use with this offer. May be blank if not provided at source.

·       brand_logo

o   url

o   url of the store logo fetched from brandlogos.org (If you do not have a premium subscription, then this response will be blank

·       type

o   string

o   Possible Values: Code|Deals

·       store

o   string

o   Unique store name. In most cases, this will be the primary domain name of the merchant promoting this offer.

·       merchant_home_page

o   url

o   The homepage URL of the merchant promoting this offer.

·       categories

o   string

o   List of categories to which this offer belongs. Please note, this will only include custom names added to the Category Mapping table in your account. If you have not mapped any custom category to the categories added for this offer by source, then this field will be blank in your response.

·       start_date

o   date (yyyy-mm-dd)

·       end_date

o   date (yyyy-mm-dd)

·       status

o   string

o   This field will contain the status of the offer in case of incremental feeds. It will be blank in case of full feed. Possible Values are new | updated | suspended|(empty).

·       primary_location

o   string

o   List of Countries in which this offer is to be promoted. Usually mapped to the countries in this merchant has allowed the affiliate campaign.

·       rating

o   integer

o   Numeric rating of the offer. Higher number signifies better rating.

SAMPLE CODE

PHP code to process incremental feeds

<?php

 $API_KEY = '[YOUR_API_KEY]';

$incremental = true;

$last_extract_datetime = '2010-01-01 00:0:00'; // Ideally leave this blank. Populate only if you want to override last extract time stored in the system

$format = 'json';

$off_record= false; // If set to true, system will not update your last extract time. This is useful for debugging purpose. Please note, this will still count in your daily limit

 $last_extract = (empty($last_extract_datetime) ? '' : strtotime($last_extract_datetime) );

 $api_response = json_decode(file_get_contents('https://couponapi.org/api/getFeed/?API_KEY='.$API_KEY.'&incremental='.$incremental.'&last_extract='.$last_extract.'&format='.$format.'&off_record='.$off_record);,true);

$coupons = $api_response['offers'];

 foreach($coupons as $coupon) {    

          if($coupon['status'] == 'new') {               

                    // Insert the coupon in your database

          } elseif($coupon['status'] == 'updated') { 

                    // Update coupon with offer_id = $coupon['offer_id']

          } elseif($coupon['status'] == 'suspended') {                 

                    // Delete coupon with offer_id = $coupon['offer_id']

                   

          }

         

}

 

?>