A Python wrapper around the Admitad API
Dependencies
- requests
- simplejson
Install by cloning from the GitHub repo:
$ git clone git://github.com/trezorg/admitad-python-api.git
$ cd admitad-python-api
$ python setup.py test
$ python setup.py build
$ python setup.py install
or just
$ cp -r admitad-python-api/pyadmitad path/to/destination
from pyadmitad import api
client_id = ""
client_secret = ""
username = ""
password = ""
scope = "private_data"
client = api.get_oauth_password_client(
client_id,
client_secret,
username,
password,
scope
)
or already having an access token
client = api.get_oauth_client(access_token)
info = client.Me.get()
scope = "public_data"
client = api.get_oauth_password_client(
client_id,
client_secret,
username,
password,
scope
)
print client.WebsiteTypes.get()
print client.WebsiteTypes.get(limit=2, offset=1)
res = client.Me.get()
res = client.Balance.get()
res = client.WebsiteTypes.get()
res = client.WebsiteTypes.get(limit=2, offset=1)
res = client.WebsiteRegions.get()
res = client.WebsiteRegions.get(limit=2, offset=1)
res = client.SystemLanguages.get()
res = client.SystemLanguages.get(limit=2, offset=1)
res = client.SystemLanguages.getOne(code='ru')
res = client.SystemCurrencies.get()
res = client.SystemCurrencies.get(limit=2, offset=1)
res = client.AdvertiserServices.get()
res = client.AdvertiserServices.get(limit=2, offset=1)
res = client.AdvertiserServices.getOne(_id=2)
res = client.AdvertiserServices.getOne(1)
res = client.AdvertiserServices.getForKind(kind='website')
res = client.AdvertiserServices.getForKind('website')
res = client.AdvertiserServices.getForKindOne(_id=2, kind='website')
res = client.AdvertiserServices.getForKindOne(2, 'website')
res = client.CampaignCategories.get()
res = client.CampaignCategories.get(limit=2, offset=1)
res = client.CampaignCategories.getOne(_id=2)
res = client.CampaignCategories.getOne(2)
res = client.Coupons.get()
res = client.Coupons.get(order_by=date_start)
res = client.Coupons.get(order_by=-date_end)
res = client.Coupons.get(campaign=1, category=2)
res = client.Coupons.get(campaign=[1, 2], category=2)
res = client.Coupons.getOne(_id=2)
res = client.Coupons.getOne(2)
res = client.CouponsForWebsite.get(_id=2)
res = client.CouponsForWebsite.get(2)
res = client.CouponsForWebsite.get(2, order_by=date_start)
res = client.CouponsForWebsite.get(2, campaign=1, category=2)
res = client.CouponsForWebsite.get(2, campaign=[1, 2], category=2)
res = client.CouponsForWebsite.getOne(_id=2, c_id=1)
res = client.CouponsForWebsite.getOne(2, 1)
res = client.Websites.get()
res = client.Websites.get(status='new', campaign_status='active')
res = client.Websites.getOne(_id=2)
res = client.Websites.getOne(2)
res = client.WebsitesManage.create(
regions=['RU'],
atnd_hits='20',
atnd_visits='10',
name='website1',
language='ru',
site_url='http://site.com',
description='description',
categories=['1', '2'],
kind='website'
)
res = client.WebsitesManage.update(50, name='test', language='de')
res = client.WebsitesManage.verify(50)
res = client.WebsitesManage.delete(50)
res = client.StatisticWebsites.get(website=1, campaign=1)
res = client.StatisticWebsites.get(subid="ADS778")
res = client.StatisticWebsites.get(limit=2)
res = client.StatisticWebsites.get(date_start='01.01.2013')
res = client.StatisticCampaigns.get()
res = client.StatisticCampaigns.get(website=1, campaign=1)
res = client.StatisticCampaigns.get(subid="ADS778")
res = client.StatisticCampaigns.get(limit=2)
res = client.StatisticCampaigns.get(date_start='01.01.2013')
res = client.StatisticDays.get()
res = client.StatisticDays.get(website=1, campaign=1)
res = client.StatisticDays.get(subid="ADS778")
res = client.StatisticDays.get(limit=2)
res = client.StatisticDays.get(date_start='01.01.2013')
res = client.StatisticMonths.get()
res = client.StatisticMonths.get(website=1, campaign=1)
res = client.StatisticMonths.get(subid="ADS778")
res = client.StatisticMonths.get(limit=2)
res = client.StatisticMonths.get(date_start='01.01.2013')
res = client.StatisticActions.get()
res = client.StatisticActions.get(date_start='01.01.2013')
res = client.StatisticActions.get(website=1, campaign=1)
res = client.StatisticActions.get(subid="ADS778")
res = client.StatisticActions.get(subid2="ADS778")
res = client.StatisticActions.get(limit=2)
res = client.StatisticSubIds.get()
res = client.StatisticSubIds.get(date_start='01.01.2013')
res = client.StatisticSubIds.get(subid="ADS778")
res = client.StatisticSubIds.get(subid1="ADS778", sub_id_number=2)
res = client.StatisticSubIds.get(limit=2)
res = client.StatisticSources.get()
res = client.StatisticSources.get(date_start='01.01.2013')
res = client.StatisticSources.get(limit=2)
res = client.StatisticKeywords.get()
res = client.StatisticKeywords.get(date_start='01.01.2013')
res = client.StatisticKeywords.get(limit=2)
res = client.Referrals.get()
res = client.Referrals.get(limit=2)
res = client.Referrals.getOne(_id=2)
res = client.Referrals.getOne(2)
res = client.Banners.get(_id=2)
res = client.Banners.get(2)
res = client.Banners.get(2, limit=2)
res = client.BannersForWebsite.get(_id=2, w_id=3)
res = client.BannersForWebsite.get(2, 3)
res = client.BannersForWebsite.get(2, 3, limit=5)
res = client.Campaigns.get()
res = client.Campaigns.get(limit=2)
res = client.Campaigns.getOne(2)
res = client.CampaignsForWebsite.get(22)
res = client.CampaignsForWebsite.get(limit=2)
res = client.CampaignsForWebsite.getOne(6, 22)
res = client.CampaignsManage.connect(6, 22)
res = client.CampaignsManage.connect(c_id=6, w_id=22)
res = client.CampaignsManage.disconnect(6, 22)
res = client.CampaignsManage.disconnect(c_id=6, w_id=22)
res = client.ProductCategories.get()
res = client.ProductCategories.get(limit=1, order_by=-name)
res = client.ProductCategories.getOne(2)
res = client.ProductVendors.get()
res = client.ProductVendors.get(limit=1, order_by=-name)
res = client.ProductVendors.getOne(2)
res = client.ProductCampaigns.get(22)
res = client.ProductCampaigns.get(22, limit=1, order_by=-name)
res = client.ProductCampaigns.getOne(22, 6)
res = client.Products.get(22)
res = client.Products.get(22, limit=1)
res = client.Products.get(22, limit=1, order_by=-price)
res = client.Products.get(22, price_from=1000)
res = client.ProductCampaigns.getOne(22, 2)
res = client.Announcements.get()
res = client.Announcements.get(limit=1, offset=2)
res = client.Announcements.getOne(2)
res = client.AnnouncementsManage.delete(12)
res = client.Payments.get()
res = client.Payments.get(limit=2)
res = client.Payments.getOne(2)
res = client.PaymentsManage.create('USD')
res = client.PaymentsManage.confirm(71)
res = client.PaymentsManage.delete(71)
res = client.MoneyTransfers.get()
res = client.MoneyTransfers.get(limit=2)
res = client.MoneyTransfers.getOne(2)
res = client.MoneyTransfers.get(sender='sender')
res = client.MoneyTransfers.get(currency='USD')
res = client.MoneyTransfersManage.create(
currency='USD',
recipient='recipient',
comment='comment',
sum=10)
It is possible to override the default response handler by passing handler as a keyword argument to a client function call. For example:
func = lambda x: (x, x)
result = client.Me.get(handler=func)