Key-Values API
Keys and Values can be created, edited, and deleted through the key-values api. Once keys have been created, you can add them to supply tags for reporting. You can also apply key-value targeting to demand tags.
Visit the Keys page for more information on Keys and Values.
Create Keys
SDK
In [1]: import springserve
In [2]: key = springserve.keys.new({'name': 'New Key', 'key': 'new_key', 'definition_type':'predefined'})
In [3]: key.ok
Out [3]: True
In [4]: print key.id
Out [4]: 28API
POST /api/v0/keys
Headers
Content-Type application/json
Authorization "yourAuthToken"Body (example)
{ } |
Required parameters: name, key, definition_type
Response
Status code 200
{
"id":30,
"account_id":1,
"name":"TEST API DOCS",
"key":"test_api",
"description":null,
"definition_type":"predefined"
}Get Keys
SDK
In [1]: key = springserve.keys.get(27)
In [2]: key.ok
Out [2]: True
In [3]: print key.name
Out [3]: "TEST API DOCS"API
GET /api/v0/keys
Headers
Content-Type application/json
Authorization "yourAuthToken"
Response
Status code 200
{
"id":30,
"account_id":1,
"name":"TEST API DOCS",
"key":"test_api",
"description":null,
"definition_type":"predefined"
}Get Values
SDK
In [1]: key = springserve.keys.get(27)
In [2]: values = key.get_values()
In [3]: for v in values:
....: print v.id
Out [3]: 104
105
106API
GET /api/v0/keys/<key_id>/values/<id>
Headers
Content-Type application/json
Authorization "yourAuthToken"
Response
Status code 200
{
"id":57,
"name":"TEST API DOCS",
"value":"test_api"
}Edit Keys
SDK
In [1]: key = springserve.keys.get(27)
In [2]: key.description = "Updated Description"
In [3]: saved = key.save()
In [4]: saved.ok
Out [4]: TrueAPI
PUT /api/v0/keys/<id>
Headers
Content-Type application/json
Authorization "yourAuthToken"Body (example)
{ } |
Response
Status code 200
{
"id":30,
"account_id":1,
"name":"I want to change the name",
"key":"test_api",
"description":null,
"definition_type":"predefined"
}Edit Values
SDK
In [1]: key = springserve.keys.get(27)
In [2]: values = key.get_values()
In [3]: value = values[0]
In [4]: value.name = 'Updated value name'
In [5]: saved = value.save()
In [6]: saved.ok
Out [6]: TrueAPI
PUT /api/v0/keys/<id>/values/<id>
Headers
Content-Type application/json
Authorization "yourAuthToken"Body (example)
{ } |
Response
Status code 200
{
"id":57,
"name":"I want to change the name",
"value":"test_api"
}Add Values to Existing Key
SDK
In [1]: key = springserve.keys.get(27)
In [2]: value = key.add_value({'name': 'new_value', 'value': '4'})
In [3]: saved = value.save()
In [4]: saved.ok
Out [4]: TrueAPI
POST /api/v0/keys/<id>/values
Headers
Content-Type application/json
Authorization "yourAuthToken"Body (example)
{ } |
Required parameters: name, value
Response
Status code 200
{
"id":57,
"name":"TEST API DOCS",
"value":"test_api"
}Add Keys to Supply Tag
SDK
In [1]: tag = springserve.supply_tags.get(28852)
In [2]: tag.key_ids
Out [2]: []
In [4]: tag.key_ids.append(27)
In [5]: saved = tag.save()
In [6]: saved.ok
Out [6]: TrueAPI
PUT /api/v0/supply_tags/<id>
Headers
Content-Type application/json
Authorization "yourAuthToken"Body (example)
|
Response
Status code 200
{
"vast_endpoint_url": "http://myvastendpoint.com/123",
"demand_type": 2,
"impression_budget": -1,
"rate": "10.0",
"domain_targeting": "None",
"id": 30424,
"domain_list_ids": [],
"country_codes": [],
"start_date": null,
"account_id": 1,
"end_date": null,
"key_ids": 27,
"demand_code": null,
"active": true,
"country_targeting": "None",
"demand_tag_type": 2,
"name": "I want to change the name",
"request_budget": -1,
"player_size_targeting": "All",
"allowed_player_sizes": [
"s",
"m",
"l",
"u"
],
"timeout": 20000,
"demand_group_id": null,
"demand_partner_id": null
}