Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

yandex-direct-api

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yandex-direct-api

Api wrapper for YandexDirect API v5

  • 0.0.1
  • PyPI
  • Socket score

Maintainers
1

Yandex Direct Api Wrapper (yandex direct api v5)

Installation

Instal user pip...

pip install yandex-direct-api

Usage

from direct_api import DirectAPI

client = DirectAPI('<access_token>', '<clid>', lang='ru')

AgencyClient:add

  • doc: https://yandex.ru/dev/direct/doc/ref-v5/agencyclients/add-docpage/
  • params:
nametypedefault value
loginstr*required
first_namestr*required
last_namestr*required
currencystr*required
grantslistNone
notificationdictNone
settingsdictNone

result = client.AgencyClient.add(login='<login>', first_name='<fname>', last_name='<lname>', currency='RUB')

AgencyClient:get

nametypedefault value
field_nameslist*required
limitint500
offsetint0
loginslistNone
archivedstrNone
result = client.AgencyClient.get(field_names=["ClientId", "ClientInfo"])

AgencyClient:update

nametypedefault value
clientslist*required
clients = [{
        "ClientId": 1
        "ClientInfo": 'client info',
    },
]
result = client.AgencyClient.update(clients=clients)

AdExtension:add

nametypedefault value
ad_extensionslist*required
ad_extendsions = [{
        "Callout": {"CalloutText": "<callout text>"},
    },
]
result = client.AdExtension.add(ad_extendsions=ad_extendsions)

AdExtension:delete

nametypedefault value
idslist*required
ids = ['1', '2', '3']
result = client.AdExtension.delete(ids)

AdExtension:get

nametypedefault value
field_nameslist*required
idslistNone
typeslistNone
statuseslistNone
modify_sincestrNone
callout_field_nameslistNone
limitint500
offsetint0
field_names = ['Id', 'Type', 'Status']
result = client.AdExtension.get(field_names)

AdGroup:add

nametypedefault value
ad_groupslist*required
ad_groups = [{'Name': 'Test', 'CampaignId': '123', 'RegionIds'}]
result = client.AdGroup.add(ad_groups)

AdGroup:delete

nametypedefault value
idslist*required
ids = ['123', '124', '125']
result = client.AdGroup.get(ids=ids)

AdGroup:get

nametypedefault value
field_nameslist*required
idslistNone
campaign_idslistNone
typeslistNone
statuseslistNone
serving_statuseslistNone
app_icon_statuseslistNone
negative_keyword_shared_set_idslistNone
mobile_app_ad_group_field_nameslistNone
dynamic_text_ad_group_field_nameslistNone
dynamic_text_feed_ad_group_field_nameslistNone
limitint500
offsetint500
field_names = ['AdGroupId', 'Name', 'CampaignId']
result = client.AdGroup.get(field_names=field_names)

AdGroup:update

nametypedefault value
ad_groupslist*required
ad_groups = [{'Name': 'Test', 'CampaignId': '123', 'RegionIds', 'AdGroupId': '123'}]
result = client.AdGroup.update(ad_groups)

AdImage:add

nametypedefault value
ad_imageslist*required
ad_images = [{'Name': 'Test', 'ImageData': '<binary>'}]
result = client.AdImage.add(ad_images)

AdImage:delete

nametypedefault value
hasheslist*required
hashes = ['<hash1>', '<hash2>']
result = client.AdImage.delete(hashes)

AdImage:get

nametypedefault value
field_nameslist*required
ad_images_hasheslistNone
associatedstrNone
limitinit500
offsetinit0
field_names = ['AdImageHash', 'Name']
result = client.AdImage.get(field_names)

Ad:add

nametypedefault value
adslist*required
ads = [{'AdgroupId': '<id>', 'TextAd': {}}]
result = client.Ad.add(ads)

Ad:archive

nametypedefault value
idslist*required
ids = ['123', '124']
result = client.Ad.archive(ids)

Ad:delete

nametypedefault value
idslist*required
ids = ['123', '124']
result = client.Ad.delete(ids)

Ad:get

nametypedefault value
field_nameslist*required
idslistNone
campaign_idslistNone
ad_group_idslistNone
stateslistNone
statuseslistNone
typeslistNone
mobilestrNone
v_card_idslistNone
sitelink_set_idslistNone
ad_image_hasheslistNone
v_card_moderation_statuseslistNone
sitelink_moderation_statuseslistNone
ad_image_moderation_statuseslistNone
ad_extension_idslistNone
text_ad_field_nameslistNone
text_ad_price_extension_field_nameslistNone
mobile_app_field_nameslistNone
dynamic_text_ad_field_nameslistNone
mobile_app_image_ad_field_nameslistNone
text_ad_builder_ad_field_nameslistNone
mobile_app_ad_builder_ad_field_nameslistNone
cpc_video_ad_builder_ad_field_nameslistNone
cpm_banner_ad_builder_ad_field_nameslistNone
cpm_video_ad_builder_ad_field_nameslistNone
limitint500
offsetint0
field_names = ['Id', 'CampaignId']
result = client.Ad.get(field_names)

Ad:moderate

nametypedefault value
idslist*required
ids = ['123', '124']
result = client.Ad.moderate(ids)

Ad:resume

nametypedefault value
idslist*required
ids = ['123', '124']
result = client.Ad.resume(ids)

Ad:suspend

nametypedefault value
idslist*required
ids = ['123', '124']
result = client.Ad.suspend(ids)

Ad:unarchive

nametypedefault value
idslist*required
ids = ['123', '124']
result = client.Ad.unarchive(ids)

Ad:update

nametypedefault value
adslist*required
ads = [{'AdgroupId': '<id>', 'TextAd': {}, 'Id': '<Id>'}]
result = client.Ad.update(ads)

AudienceTarget:add

nametypedefault value
adslist*required
ads = [{'AdgroupId': '<id>', }]
result = client.AudienceTarget.add(ids)

AudienceTarget:delete

nametypedefault value
idslist*required
ids = ['232324353']
result = client.AudienceTarget.delete(ids)

AudienceTarget:get_audience_targets

nametypedefault value
field_nameslist*required
idslistNone
ad_group_idslistNone
campaign_idslistNone
retargeting_list_idslistNone
interest_idslistNone
stateslistNone
limitint500
offsetint0
field_names = ['Id']
result = client.AudienceTarget.get_audience_targets(field_names, campaigns_ids=[123])

AudienceTarget:resume

nametypedefault value
idslist*required
ids = ['232324353']
result = client.AudienceTarget.resume(ids)

AudienceTarget:set_bids

nametypedefault value
bidslist*required
bids = [{'Id': '<id>', 'AdGroupId': '<Id>'}]
result = client.AudienceTarget.set_bids(bids)

Bid:get

nametypedefault value
field_nameslist*required
keyword_idslistNone
ad_group_idslistNone
campaign_idslistNone
serving_statuseslistNone
limitint500
offsetint0
field_names = ['Id']
result = client.Bid.suspend(field_names, campaign_ids=[1232424532])

Bid:set

nametypedefault value
bidslist*required
bids = [{'Bid': '<long>'}]
result = client.Bid.set(bids)

Bid:set_auto

nametypedefault value
bidslist*required
bids = [{'CampaignID': '<long>', 'Scope': 'SEARCH'}]
result = client.Bid.set_auto(bids)

BidsModifier:add

nametypedefault value
bid_modifierslist*required
bid_modifiers = [{'MobileAdjustment': {'BidModifier': '<id>'}}]
result = client.BidsModifier.add(bid_modifiers)

BidsModifier:delete

nametypedefault value
idslist*required
ids = ['1312324343']
result = client.BidsModifier.delete(ids)

BidsModifier:get

nametypedefault value
field_nameslist*required
idslistNone
campaign_idslistNone
ad_group_idslistNone
typeslistNone
levelslistNone
mobile_adjustment_field_nameslistNone
desktop_adjustment_field_nameslistNone
demographics_adjustment_field_nameslistNone
retargeting_adjustment_field_nameslistNone
regional_adjustment_field_nameslistNone
video_adjustment_field_nameslistNone
limitlist500
offsetlist0
field_names = ['Id', 'CampaignId', 'Type']
result = client.BidsModifier.get(field_names, campaign_ids=['123453534'])

BidsModifier:set

nametypedefault value
bid_modifierslist*required
ids = [{'Id': '<id>', 'BidModifier': 124242}]
result = client.BidsModifier.set(bid_modifiers)

BidsModifier:toggle

nametypedefault value
bid_modifier_toggle_itemslist*required
bid_modifier_toggle_items = [{'CampaignId': '<id>', 'Type': "DEMOGRAPHICS_ADJUSTMENT","Enabled": "YES"}]
result = client.BidsModifier.toggle(bid_modifier_toggle_items)

Campaign:add

nametypedefault value
campaignslist*required
campaign_item = {} # campaign object
campaigns = [campaign_item]
result = client.Campaign.add(campaigns)

Campaign:archive

nametypedefault value
idslist*required
ids = ['12312535', '345345345', '23432325345']
result = client.Campaign.archive(ids)

Campaign:delete

nametypedefault value
idslist*required
ids = ['12312535', '345345345', '23432325345']
result = client.Campaign.delete(ids)

Campaign:get

nametypedefault value
field_nameslist*required
idslistNone
typeslistNone
stateslistNone
statuseslistNone
statuses_paymentslistNone
text_campaign_field_nameslistNone
mobile_app_campaign_field_nameslistNone
dynamic_text_campaign_field_nameslistNone
cpm_banner_campaign_field_nameslistNone
limitint500
offsetint0
field_names = ['Id', 'Name', 'Type']
result = client.Campaign.get(field_names=field_names)

Campaign:resume

nametypedefault value
idslist*required
ids = ['12312535', '345345345', '23432325345']
result = client.Campaign.resume(ids)

Campaign:suspend

nametypedefault value
idslist*required
ids = ['12312535', '345345345', '23432325345']
result = client.Campaign.suspend(ids)

Campaign:unarchive

nametypedefault value
idslist*required
ids = ['12312535', '345345345', '23432325345']
result = client.Campaign.unarchive(ids)

Campaign:update

nametypedefault value
campaignslist*required
campaigns = [{'Id': '12312535','Name': 'updated!']
result = client.Campaign.unarchive(campaigns)

Change:check_dictionaries

nametypedefault value
timestampint*required
from time import time

timestamp = int(time.now()- 1800)
result = client.Change.check_dictionaries(timestamp)

Change:check_campaigns

nametypedefault value
timestampint*required
from time import time

timestamp = int(time.now()- 1800)
result = client.Change.check_campaigns(timestamp)

Change:check

nametypedefault value
timestampint*required
field_nameslist*required
campaign_idslistNone
ad_group_idslistNone
ad_idslistNone
from time import time

timestamp = int(time.now()- 1800)
field_names = ['Id', 'Name']
result = client.Change.check(timestamp, fiel_names)

Creative:get

nametypedefault value
field_nameslist*required
idslistNone
typeslistNone
video_extension_creative_field_nameslistNone
cpc_video_creative_field_nameslistNone
cpm_video_creative_field_nameslistNone
limitint10000
offsetint0
field_names = ['Id', 'Name', 'Type', 'PreviewUrl']
result = client.Creative.get(field_names)

Dictionary:get

nametypedefault value
dictionary_nameslist*required
dictionary_names = ['TimeZones', 'Currencies']
result = client.Dictionary.get(dictionary_names)

DynamicTextAdTarget:add

nametypedefault value
webpageslist*required
bidlistNone
context_bidstrNone
context_bidstrNone
strategy_prioritystrNone
webpages = [{'Name': 'Test', 'AdGroupId': '123242453253'}]
result = client.DynamicTextAdTarget.add(webpages)

DynamicTextAdTarget:delete

nametypedefault value
idslist*required
ids = ['213232432432']
result = client.DynamicTextAdTarget.delete(ids)

DynamicTextAdTarget:get

nametypedefault value
field_nameslist*required
idslistNone
ad_group_idslistNone
campaign_idslistNone
stateslistNone
limitint10000
offsetint0
ids = ['AdGroupId', 'Bid']
result = client.DynamicTextAdTarget.get(ids)

DynamicTextAdTarget:resume

nametypedefault value
idslist*required
ids = ['213232432432']
result = client.DynamicTextAdTarget.resume(ids)

DynamicTextAdTarget:suspend

nametypedefault value
idslist*required
ids = ['213232432432']
result = client.DynamicTextAdTarget.suspend(ids)

DynamicTextAdTarget:set_bids

nametypedefault value
bidslist*required
set_bit_item = {} # set bid item from doc
bids = [set_bit_item]
result = client.DynamicTextAdTarget.set_bids(bids)

KeywordBid:get

nametypedefault value
field_nameslist*required
campaign_idslistNone
ad_group_idslistNone
keyword_idslistNone
serving_statuseslistNone
search_field_nameslistNone
network_field_nameslistNone
limitint10000
offsetint0
field_names = ['Id']
campaign_ids = ['123123212353']
result = client.KeywordBid.get(field_names, campaign_ids=campaign_ids)

KeywordBid:set

nametypedefault value
keyword_bidslist*required
set_bit_item = {} # set bid item from doc
keyword_bids = [set_bit_item]
result = client.KeywordBid.set(keyword_bids)

KeywordBid:set_auto

nametypedefault value
keyword_bidslist*required
set_bit_item = {} # set bid item from doc
keyword_bids = [set_bit_item]
result = client.KeywordBid.set_auto(keyword_bids)

Keyword:add

nametypedefault value
keywordslist*required
keyword = {"Keyworod": "yandex-dircet-api-python", "AdGroupId": "12324324334"}
keywords = [keyword]
result = client.Keyword.add(keywords)

Keyword:delete

nametypedefault value
idslist*required
ids = ['1232432547357348']
result = client.Keyword.delete(ids)

Keyword:get

nametypedefault value
field_nameslist*required
idslistNone
ad_group_idslistNone
campaign_idslistNone
stateslistNone
statuseslistNone
serving_statuseslistNone
modified_sincestrNone
limitint10000
offsetint0
field_names = ['Id', 'Keyword']
result = client.Keyword.delete(field_names, campaign_ids=['23232343583'])

Keyword:resume

nametypedefault value
idslist*required
ids = ['1232432547357348']
result = client.Keyword.resume(ids)

Keyword:suspend

nametypedefault value
idslist*required
ids = ['1232432547357348']
result = client.Keyword.resume(ids)

Keyword:update

nametypedefault value
keywordslist*required
keywords = [{'Id': '123123243534', 'Keyword': 'updated yandex'}]
result = client.Keyword.update(keywords)

KeywordsResearch:deduplicate

nametypedefault value
keywordslist*required
operationlistNone
keywords = [{'Id': '123123243534', 'Keyword': 'updated yandex'}]
operation  = 'MERGE_DUPLICATES'
result = client.KeywordsResearch.deduplicate(keywords, operation)

KeywordsResearch:has_search_volume

nametypedefault value
field_nameslist*required
keywordslist*required
region_idslist*required
field_names = ['Keyword']
keywords = [{'Id': '123123243534', 'Keyword': 'updated yandex'}]
region_ids  = ['123123123']
result = client.KeywordsResearch.has_search_volume(field_names, keywords, region_ids)

Lead:get

nametypedefault value
field_nameslist*required
turbo_page_idslistNone
date_time_fromstrNone
date_time_tostrNone
limitint10000
offsetint0
field_names = ['TurboPageId', 'TurboPageName', 'id']
result = client.Lead.get(field_names)

NegativeKeywordSharedSet:add

nametypedefault value
negative_keyword_shared_setslist*required
negative_keyword_shared_sets = [{'Name': 'name', 'NegativeKeywords': [123]}]
result = client.Lead.get(negative_keyword_shared_sets)

NegativeKeywordSharedSet:delete

nametypedefault value
idslist*required
ids = [12312325]
result = client.NegativeKeywordSharedSet.delete(ids)

NegativeKeywordSharedSet:get

nametypedefault value
field_nameslist*required
idslistNone
limitint10000
offsetint0
field_names = ['Id', 'Name', 'NegativeKeywords']
result = client.NegativeKeywordSharedSet.get(field_names)

NegativeKeywordSharedSet:update

nametypedefault value
negative_keyword_shared_setslist*required
negative_keyword_shared_sets = [{'Id': '12324234234', 'Name': 'test', 'NegativeKeywords': ['1231321']}]
result = client.NegativeKeywordSharedSet.update(negative_keyword_shared_sets)

RetargetingList:add

nametypedefault value
retargeting_listlist*required
retargeting_obj = {} # object from doc
retargeting_list = [retargeting_obj]
result = client.RetargetingList.add(retargeting_list)

RetargetingList:delete

nametypedefault value
idslist*required
ids = [12313254325345345353]
result = client.RetargetingList.delete(ids)

RetargetingList:get

nametypedefault value
field_nameslist*required
idslistNone
typeslistNone
limitint10000
offsetint0
field_names = ['Type', 'Id', 'Name']
ids = [12313254325345345353]
result = client.RetargetingList.get(field_names, ids=ids)

RetargetingList:update

nametypedefault value
retargeting_listlist*required
retargeting_obj = {} # object from doc
retargeting_list = [retargeting_obj]
result = client.RetargetingList.update(retargeting_list)

Sitelink:add

nametypedefault value
sitelinks_setslist*required
sitelinks = [{'Title': 'sitelink1'}]
sitelinks_sets = [sitelinks]
result = client.Sitelink.add(sitelinks_sets)

Sitelink:delete

nametypedefault value
idslist*required
ids = [12313254325345345353]
result = client.Sitelink.delete(ids)

Sitelink:get

nametypedefault value
field_nameslist*required
idslistNone
sitelinks_field_nameslistNone
limitint10000
offsetint0
field_names = ['Id', 'Sitelinks']
result = client.Sitelink.get(field_names)

TurboPage:get

nametypedefault value
field_nameslist*required
idslistNone
limitint10000
offsetint0
field_names = ['Id', 'Name', 'Href']
result = client.TurboPage.get(field_names)

VCard:add

nametypedefault value
vcardslist*required
vcard = {
    'CampaignId': '1231231232131',
    'Country': '<country>',
    'City': '<City>',
    'CompanyName': '<CompanyName>',
}
vcards = [vcard]
result = client.VCard.add(vcards)

VCard:delete

nametypedefault value
idslist*required
ids = [12313254325345345353]
result = client.Sitelink.delete(ids)

VCard:get

nametypedefault value
field_nameslist*required
idslistNone
limitint10000
offsetint0
field_names = ['Id', 'Country', 'City']
result = client.VCard.get(field_names)

Report:get

nametypedefault value
selection_criterialist*required
field_nameslist*required
report_namestr*required
report_typestr*required
date_range_typestr*required
processing_modestrauto
headersdictNone
goalslistNone
attribution_modelslistNone
pagedictNone
order_bylistNone
formatstrTSV
include_vatstrYES
include_discountstrNO
selection_criteria= {
    "DateFrom": date_from.strftime('%Y-%m-%d'),
    "DateTo": date_to.strftime('%Y-%m-%d'),
}

field_names = [
    "Date",
    "Impressions",
    "Clicks",
    "Cost",
    "CriterionId",
    "Criterion",
    "CampaignId",
    "AdId",
    "Device",
    "AdGroupId",
    "CampaignType",
    "AvgClickPosition",
    "Slot",
    "LocationOfPresenceId",
    "Placement",
    "AvgImpressionPosition",
    "LocationOfPresenceName",
    "CampaignName",
    "AdNetworkType",
]
page = {"Limit": 100000000},
report_name = f"ActualData - 123"
report_type = "CUSTOM_REPORT",
date_range_type = "CUSTOM_DATE"
result = client.Report.get(
    selection_criteria=selection_criteria,
    field_names=field_names,
    report_name=report_name,
    report_type=report_type,
    date_range_type=date_range_type,
    page=page,
)

Client:add

nametypedefault value
loginstr*required
first_namestr*required
last_namestr*required
currencystr*required
grantslistNone
notificationdictNone
settingsdictNone
result = client.Client.add(login='clid', first_name='ivan', last_name='petrov', currency='RUB')

Client:get

nametypedefault value
field_nameslist*required
loginslistNone
archivedstrNone
limitint500
offsetint0
field_names = ['ClientId', 'ClientInfo']
result = client.Client.get(field_names)

TODO:

  • examples
  • tests
  • docs
  • Travis CI

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc