The 7 Things I Know About Cyber Security After 25 Years | April 2024
Best ways to use the ShareASale API
1. Best Ways to
Use the API
ShareASale Think Tank 2013
Eric Nagel
eric@ericnagel.com
2. What is the ShareASale API?
● API = Application Programming Interface
○ An application programming interface (API) specifies
how some software components should interact with
each other.
○ It’s a way for your website to talk directly to the
ShareASale system
● Affiliate API
● Merchant API
3. Where to find the ShareASale API
Affiliate API Under
Tools
Merchant API
Under Tools
4. Affiliate API: Authentication
The Authentication Hash
Authentication Hash : SHA-256 Hash in 64 character Hex format of the string "YourAPIToken:CurrentDateInUTCFormat:
APIActionValue:YourAPISecret" (without quotes)
For example, for following values:
Token: NGc6dg5e9URups5o
API Secret: ATj7vd8b7CCjeq9yQUo8cc2w3OThqe2e
String to Hash: NGc6dg5e9URups5o:Thu, 14 Apr 2011 22:44:22 GMT:bannerList:ATj7vd8b7CCjeq9yQUo8cc2w3OThqe2e
UTC Date: Thu, 14 Apr 2011 22:44:22 GMT
API Action: bannerList
The correct HTTP Headers would be:
x-ShareASale-Date: Thu, 14 Apr 2011 22:44:22 GMT
x-ShareASale-Authentication: 78D54A3051AE0AAAF022AA2DA230B97D5219D82183FEFF71E2D53DEC6057D9F1
5. Affiliate API: Authentication
IP Restrictions
Start > Run
cmd
ping domain.com
Gives you the IP
These are the IPs that will be accessing the
data. Since the script will reside on your
server, use your server’s IP.
9. Affiliate API: Sample
if ($returnResult) {
//parse HTTP Body to determine result of request
if (stripos($returnResult,"Error Code ")) {
// error occurred
trigger_error($returnResult,E_USER_ERROR);
}
else{
// success
echo $returnResult;
}
This is where you take over and
put in your custom coding to do
whatever you want with the data.
}
else{
// connection error
trigger_error(curl_error($ch),E_USER_ERROR);
}
11. Example
Use Activity Details to download transaction
data daily and store in your tracking system or
email you your commissions.
Trans ID|User ID|Merchant ID|Trans
Date|Trans
Amount|Commission|Comment|Voided|Pendin
g Date|Locked|Aff Comment|Banner
Page|Reversal Date|Click Date|Click
Time|Banner Id
37697968|132296|8723|10/16/2012 11:41:05
AM|323.7|71.21|Sale - 620946||||WCG45500|http://www.wineclubreviewsandratings.
com/cellars-wine-club/sparkling-champagneclub-review||2012-10-16 00:00:00.0|11:34:11
AM|43027
12. Example
Use Coupon / Deal Merchants to download
coupons to show on your website
Deal Id|Merchant Id|Merchant|Start Date|End
Date|Publish Date|Title|Image(big)|Tracking
URL|Image(small)
|Category|Description|Restrictions|Keywords|C
oupon Code|Edit Date
12104|8684|Checks Unlimited|2009-06-15 00:
00:00.0|2050-12-31 00:00:00.0|2008-08-23 18:
09:10.0|Personal checks, additional 10% off
reorder check pricing.|http://|http://www.
shareasale.com/u.cfm?
d=12104&m=8684&u=132296|http://||Personal
checks only - additional 10% off reorder check
pricing default online.|||PJKA|2009-06-18 12:
26:34.0
13. Other Affiliate API Uses
● Get Products
○ Search by keyword
to return products for
a datafeed site
● Invalid Links
○ Make sure you’re not
wasting your traffic
● Merchant Status
○ Be alerted when
merchants go offline
● Merchant Creatives
○ Get the latest
banners from
merchants who run
seasonal offers
14. What Do I Do Now?
● Process the data
○
○
○
See fgetcsv(), split(), explode()
Save to database
Send an email
● Automate your script
○
Set up a “cron” to have the script run on a regular basis
● More help?
○
○
http://www.ericnagel.com/how-to-tips/shareasale-api.html
■ 4 years old, but it still works.
http://www.ericnagel.com/how-to-tips/shareasale-prosper202.html
■ If you use Prosper202
15. Tips
● You have limited API calls. Use them wisely.
○ 200 / month = less than 7 per day
i.
ii.
iii.
iv.
v.
vi.
Activity Details
Traffic
Get Products
Invalid Links
Coupon / Deal Merchants
Merchant Status
16. Tips
● While you’re writing your script to process
the data, download the data once, then use
the local file for processing. This way, only 1
API call will be used.
○
$cURL = 'https://shareasale.com/x.cfm?
action=couponDeals&affiliateId=132296&token=az7bFTu3LwioXNRA
&XMLFormat=0';
// $cURL = 'sas.csv';
$fp = fopen($cURL, "r");
17. Tips
Since we’re talking about APIs, why not combine a
merchant’s direct API with the ShareASale API?
● Get data from merchant’s own API
● Change links to ShareASale Deeplinks
● …
● Profit
http://www.wyzant.com/AffiliateProgram/
18. Resources
●
http://blog.shareasale.com/author/ryan/
○ Ryan Frey writes about using all the ShareASale techie things
●
http://www.ericnagel.com/tag/shareasale
○ I have a few blog posts about ShareASale - keep digging
●
http://www.programmableweb.com/api/shareasale-affiliate
○ Programmable Web is all things API