Demand Tag API
Creating a Demand Tag
SDK
Use tab completion with SDK to auto-complete function names or show field options!
In [1]: import springserve In [2]: tag = springserve.demand_tags.new({"name": "TEST API DOCS", "rate": 10.0, 'vast_endpoint_url': 'http://myvastendpoint.com/123', 'demand_partner_id':4321}) In [3]: print tag.ok, tag.id True, 30424
REST API
POST /api/v0/demand_tags
Headers
Content-Type application/json Authorization "yourAuthToken"
Body (example)
{ Â Â Â Â "name": "TEST API DOCS", Â Â "rate": 0.2, Â Â "vast_endpoint_url": "https://s3.amazonaws.com/...", Â Â "demand_partner_id": 4321 }
Response
Status code 200
{ 'account_id': 1, 'active': True, 'allowed_player_sizes': [ 's', 'm', 'l', 'u' ], 'bid_floor_type': 'dynamic', 'bid_margin': 1.0, 'bid_optional_params': {'context': 0}, 'bid_params': {'placementId': '1'}, 'bid_platform': None, 'budget_metric': None, 'budget_pacing': None, 'budget_period': None, 'budget_value': None, 'campaign_id': None, 'country_codes': [], 'country_targeting': 'All', 'demand_code': None, 'demand_group_id': None, 'demand_partner_id': 1764, 'tag_pixels': [], 'demand_class': 3, 'direct_connect': False, 'dma_codes': [], 'dma_targeting': 'All', 'domain_list_ids': [], 'domain_targeting': 'All', 'end_date': None, 'frequency_cap_metric': None, 'frequency_cap_period': None, 'frequency_cap_value': None, 'format': 'video', 'id': 30424, 'key_value_targeting': True, 'name': 'TEST API DOCS', 'player_size_targeting': 'All', 'rate': '0.01', 'start_date': None, 'demand_tag_priorities': [{'supply_tag_id': 123456, 'priority': 1, 'tier': 0}, {'supply_tag_id': 123456, 'priority': 1, 'tier': 1}], 'targeting_demand_ids': [], 'targeting_demand_white_list': '', 'timeout': 20000, 'updated_at': '2017-07-28T15:06:47.191Z', 'user_agent_devices': [], 'user_agent_operating_systems': [], 'vast_endpoint_url': 'http://test.com' }
Get a demand tag by id
SDK
In [1]: tag = springserve.demand_tags.get(30424) In [2]: print tag.name "TEST API DOCS"
REST API
GET /api/v0/demand_tags/<id>
Headers
Content-Type application/json Authorization "yourAuthToken"
Response
Status code 200
{ 'account_id': 1, 'active': True, 'id': 30424, 'name': 'TEST API DOCS', ... 'rate': '0.01', 'demand_tag_priorities': [{'supply_tag_id': 123456, 'priority': 1, 'tier': 0}, {'supply_tag_id': 123456, 'priority': 1, 'tier': 1}], 'demand_partner_id': 1764, 'vast_endpoint_url': 'http://test.com' }
Get demand tags based on multiple conditions
SDK
In [1]: active_tags_by_account = springserve.demand_tags.get(account_id=123, active=True) In [2]: print active_tags_by_account[0].name "TEST ACTIVE DEMAND TAG"
REST API
GET /api/v0/demand_tags
Headers
Content-Type application/json Authorization "yourAuthToken"
Body
{ "account_id": 123, "active": "True" }
Response
Status code 200
[ { 'account_id': 123, 'active': True, 'id': 30424, ... }, { 'account_id': 123, 'active': True, 'id': 30425, ... } ]
Edit a Demand Tag
SDK
In [1]: tag = springserve.demand_tags.get(30424) In [2]: tag.name = "I want to change the name" In [3]: changed = tag.save() In [4]: changed.ok Out [4]: True In [5]: print changed.name "I want to change the name"
REST API
PUT /api/v0/demand_tags/<id>
Headers
Content-Type application/json Authorization "yourAuthToken"
Body (example)
{ Â Â Â Â "name" : "I want to change the name" } |
Response
Status code 200
{ 'account_id': 1, 'active': True, 'demand_partner_id': 1764, 'id': 30424, 'name': 'I want to change the name', ... 'rate': '0.01', 'demand_tag_priorities': [{'supply_tag_id': 123456, 'priority': 1, 'tier': 0}, {'supply_tag_id': 123456, 'priority': 1, 'tier': 1}], 'vast_endpoint_url': 'http://test.com' }
Duplicate a Demand Tag
Please note that this works for both Managed and Direct Connect tags.Â
SDK
In [1]: tag = springserve.demand_tags.get(30424) ln [2]: dupe = tag.duplicate() ln [3]: dupe.ok Out [3]: True In [4]: print dupe.id 72302
REST API
GET /api/v0/demand_tags/<id>/duplicate
Headers
Content-Type application/json Authorization "yourAuthToken"
Response
Status code 201
{ 'account_id': 1, 'active': True, 'demand_partner_id': 1764, 'id': 72302, 'name': 'I want to change the name (copy)', ... 'rate': '0.01', 'demand_tag_priorities': [{'supply_tag_id': 123456, 'priority': 1, 'tier': 0}, {'supply_tag_id': 123456, 'priority': 1, 'tier': 1}], 'vast_endpoint_url': 'http://test.com' }
Add Content Targeting to Demand Tag
SDK
import springserve as ss tag = ss.demand_tags.get(30424) # The content targeting on a demand tag object is a list of dictionaries. ## Include the macro you want to target, allow/block list, values or list, ... ## ...targeted values or parameter list ids, and whether or not the param is required. content_targeting = [ { "macro_param": "{{CONTENT_TITLE}}", "list_type": "white_list", "source_type": "values", "targeted_values": ["Breaking Bad"], "param_required": False }, { "macro_param": "{{CONTENT_GENRE}}", "list_type": "black_list", "source_type": "list", "parameter_list_ids": [46], "param_required": False }, { "macro_param": "{{CONTENT_EPISODE}}", "list_type": "white_list_partial_match", "source_type": "values", "targeted_values": ["1", "2"], "param_required": True }, { "macro_param": "{{LANGUAGE}}", "list_type": "black_list_partial_match", "source_type": "values", "targeted_values": ["es"], "param_required": False } ] tag.targeted_macros = content_targeting if tag.ok: resp = tag.save() if not resp.ok: print(resp.error)
REST API
PUT /api/v0/demand_tags/<id>
Headers
Content-Type application/json Authorization "yourAuthToken"
Body (example)
curl -X PUT \ 'https://console.springserve.com/api/v0/demand_tags/1226067' \ --header 'Accept: application/json' \ --header 'Authorization: authtokenhere' \ --header 'Content-Type: application/json' \ --data-raw '{ "targeted_macros_enabled": true, "targeted_macros": [ { "macro_param": "{{CONTENT_GENRE}}", "list_type": "white_list", "source_type": "list", "parameter_list_ids": [46], "param_required": false }, { "macro_param": "{{RATING}}", "list_type": "black_list", "source_type": "values", "targeted_values": [ "r", "tv-ma" ], "param_required": false } ] }'