Time to read: 4 min
The article covers the following topics:
General Info
First of all, to get started with API, you need to find your API-key. To do it, just navigate to 'Users' Tab - > 'Users management' -> 'User edit page':
Only the General manager has permission to get the 'User edit page'.
Next thing you need is API URL, you can find it in 'Settings' Tab -> 'Settings' -> 'Tracking domains' -> 'URLs' section:
Find out more about where you can find your/Affiliate's API-key and API URL here.
API Request Structure: GET/POST + api domain + path + ? + api-key=189471975956279174174.
It should be noted that header content-type - application/x-www-form-urlencoded is used on an ongoing basis.
[POST] Add offer
To create a new offer with Targeting groups via API, you need to navigate to the 'Offers' section in the API Doc and choose the 'Add offer' method (follow the link):
Here you may see a lot of parameters that can be used to create a new offer.
These parameters are required:
- title - Offer title
- advertiser - Advertiser ID
- url - Tracking URL
- payout - at least one general payout. Check this article out to learn how to do it.
Example on how to add new offer with Targeting groups via API:
1) First of all, make sure that headers are entered correctly:
2) Enter required and all needed parameters in body section:
Where for general targeting groups:
- targeting[0][country][allow/deny][] - set specific countries you allow or deny traffic (clicks) to be accepted from. To Get the list of countries, you may use the GET /3.1/countries method.
- targeting[0][region][allow/deny][] - set specific regions you allow or deny traffic (clicks) to be accepted from. To Get the list of regions, you may use the GET /3.1/regions method.
- targeting[0][city][allow/deny][] - set specific cities for the chosen countries you allow or deny traffic (clicks) to be accepted from. To Get the list of cities, you may use the GET /3.1/cities method.
- targeting[0][os][allow/deny][0][name] - the option to filter incoming traffic based on OS targeting. To Get the list of OSes names, you may use the GET /3.1/oses method.
- targeting[0][os][allow/deny][0][comparison] - comparison operation for OS version.
Available values for [comparison] operation: LT, LTE, EQ, GT, GTE, where: LT means "<", LTE means "<=", EQ means "=", GT means ">", GTE means ">=".
- targeting[0][os][allow/deny][0][version] - OS version for comparision. To Get the list of OS versions, you may use the GET /3.1/oses/{OS} method.
- targeting[0][isp][allow/deny][ISO_country_code][0] - list of allowed or denied ISP (mobile carries) for chosen country(ISO). To Get the ISP list, you may use the GET /3.1/isp method.
- targeting[0][ip][allow/deny][0] - list of allowed or denied ip ranges (IPv4 , IPv6).
Available formats for [ip] : “100.0.0.1” (single IP), “100.0.0.1-100.0.0.255” (IP range), “222.1.1.20/26” (IP/mask).
- targeting[0][device_type][] - list of allowed device types. To Get the list of devices, you may use the GET /3.1/devices method.
Available values for [device_type]: “mobile”, “tablet”, “desktop”, “mediahub”, “ereader”, “console”, “tv”, “smartwatch”. To Get the list of devices, you may use the GET /3.1/devices method.
- targeting[0][browser][allow/deny][0] - list of allowed or denied browsers. To Get the list of browsers, you may use the GET /3.1/browsers method.
- targeting[0][brand][allow/deny][0] - list of allowed or denied brands. To Get the list of brands, you may use the GET /3.1/vendors method.
- targeting[0][sub][allow/deny][1-8][] - list of allowed or denied subs (sub1 - sub8) for chosen sub parameter.
- targeting[0][sub][deny_groups][0][1-2] - list of denied sub restricted groups.
You may use this parameter when it is needed to block sub pairs. For example, if you want to block sub1="abc" with sub2="123":
targeting[1][sub][deny_groups][0][1]=abc
targeting[1][sub][deny_groups][0][2]=123
To implement “Block traffic if empty sub” option, put an empty string:
targeting[0][sub][deny_groups][1][1-8]
- targeting[0][connection][0] - list of allowed connection types.
Available values for [connection] : “wi-fi”, “cellular”. To get the list of connection types, you may use the GET /3.1/connection-types method.
- targeting[0][block_proxy] - enable or disable “Click-level Anti-fraud” feature. 0 - logical "no", 1- logical "yes".
“Click-level Anti-fraud” feature available only for Enterprise and Custom pricing plans. If you are looking for a pricing plan upgrade, feel free to contact your Dedicated Account Manager.
- targeting[0][affiliate_id][] - Affiliate ID for personal targeting group.
- targeting[0][url] - additional Tracking URL.
cURL Request
The example of offer creation with Targeting groups via cURL request:
curl --location --request POST 'https://api-rocketcompany.affise.com/3.0/admin/offer' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'api-key: bf09c801ff9b95b14ac8e17d6e4904b6' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'title=OFFER WITH Targeting groups' \
--data-urlencode 'advertiser=5e39279bac611cda7e5765ab' \
--data-urlencode 'url=https://track.gjane.com/hc/click?afclick={clickid}&afpid={pid}&afoffer={offer_id}' \
--data-urlencode 'targeting[0][country][allow][]=RU' \
--data-urlencode 'targeting[0][device_type][]=mobile' \
--data-urlencode 'targeting[0][connection][]=cellular' \
--data-urlencode 'targeting[0][sub][allow][1][]=qwerty' \
--data-urlencode 'targeting[0][os][allow][0][name]=iOS' \
--data-urlencode 'targeting[0][os][allow][0][comparison]=EQ' \
--data-urlencode 'targeting[0][os][allow][0][version]=12.0' \
--data-urlencode 'targeting[0][isp][allow][RU][0]=Mts' \
--data-urlencode 'targeting[0][ip][allow][0]=11.12.13.0-17.18.19.22' \
--data-urlencode 'targeting[0][browser][allow][0]=Yandex.Browser for iOS' \
--data-urlencode 'targeting[0][brand][deny][0]=Smartbook Entertainment' \
--data-urlencode 'targeting[0][connection][0]=wi-fi' \
--data-urlencode 'targeting[0][block_proxy]=1' \
--data-urlencode 'targeting[0][url]=http://test-url.com' \
--data-urlencode 'targeting[1][country][allow][]=US' \
--data-urlencode 'targeting[1][device_type][]=desktop' \
--data-urlencode 'targeting[1][connection][]=wi-fi' \
--data-urlencode 'targeting[1][affiliate_id][]=2' \
--data-urlencode 'targeting[1][sub][deny][2][]=qwerty213' \
--data-urlencode 'targeting[1][sub][deny_groups][1][4]=' \
--data-urlencode 'targeting[1][sub][deny_groups][0][1]=fu' \
--data-urlencode 'targeting[1][sub][deny_groups][0][2]=lu'
You may also find the following articles helpful:
- Getting started
- Setting API Integration with Affiliate
- How to create an offer via API?
- How to create an offer with logo or creatives?
If you have more questions on how to create an offer with Targeting groups via API, feel free to contact the Affise Support Team via support@affise.com or your Dedicated Account Manager.
Written by Anastasia Deryugina
0 Comments