SDK Ad Ops Tasks Examples

On this page, you will find examples of common ad ops tasks that can be made easier by using SDK. Please keep in mind that these examples might include details that should be altered depending on your use case.

Change Supply Tag Optimization Metric to Revenue per Second

import springserve tag_ids = [1,2,3] for i in tag_ids: st = springserve.supply_tags.get(i) st.optimization = {'active': True, 'version': '', 'learn_pct': '1.0', 'mode': 'black_box', 'settings': {'metric': 'revenue_per_second', 'lookback_minutes': '60'}} resp = st.save() if resp.ok == True: print(st.id, resp.ok) else: print(st.id, resp.error)

Add Reporting Keys on Multiple Supply Tags

import springserve tag_ids = [1,2] for i in tag_ids: st = springserve.supply_tags.get(i) if st.key_ids == []: st.key_ids = [300, 400] resp = st.save() print(st.id, resp.ok) else: st.key_ids.extend([300, 400]) resp = st.save() print(st.id, resp.ok)

 

Add Impression Frequency Caps on Multiple Demand Tags

import springserve tag_ids = [1,2,3] for i in tag_ids: dt = springserve.demand_tags.get(i) dt.frequency_caps.append({ 'frequency_cap_period': 'minute', 'frequency_cap_period_amount': 3, 'frequency_cap_metric': 'impressions', 'frequency_cap_value': 3, 'frequency_cap_type': 'springserve', 'frequency_cap_third_party_id': None}) resp = dt.save() if resp.ok == True: print(dt.id, resp.ok) else: print(dt.id, resp.error)

Add Budgets on Multiple Demand Tags