次の方法で共有


ターゲット キー サービス

targeting-key サービスは、ターゲティング値サービスと組み合わせて機能し、広告申込情報やキャンペーンなどのターゲティングで使用する独自のキーと値の組み合わせを定義できます。 詳細については、「 カスタム キー値のターゲット設定 」を参照してください。

REST API

HTTP メソッド エンドポイント 説明
POST https://api.appnexus.com/targeting-key
(create_target_key JSON)
新しいターゲット キーを追加します。
PUT https://api.appnexus.com/targeting-key?id=TARGETING_KEY_ID
(update_targeting_key JSON)
ターゲット キーを変更します。
GET https://api.appnexus.com/targeting-key すべてのターゲット キーを表示します。
GET https://api.appnexus.com/targeting-key?id=TARGETING_KEY_ID 特定のターゲット キーを表示します。
GET https://api.appnexus.com/targeting-key?name=TARGETING_KEY_NAME1,TARGETING_KEY_NAME2,TARGETING_KEY_NAME3 ターゲット キーのセットを名前で表示します。
DELETE https://api.appnexus.com/targeting-key?id=TARGETING_KEY_ID ターゲット キーを削除します。

JSON フィールド

一般

フィールド 型 (長さ) 説明
id int ターゲット キーの ID。

既定値: 自動生成された数値
必須:PUT/ DELETE クエリ文字列内の 、
type 列挙 キーとその関連する値のデータ型。 次のいずれかの値を指定する必要があります。
- string
- numeric
必須:POST
name string ターゲット キーの名前。
値は、スペースを含めずに 1 つの単語にする必要があります。 この名前は、メンバー内で一意である必要があります。

必須:POST
label string レポートに使用するキーのラベル。 この値は必須ではありませんが、値を含める場合は、メンバー内で一意である必要があります。 ラベルの最大文字数は 190 文字です。
state 列挙 ターゲット キーの状態。 可能な値は、activeinactive です。

既定値: active
created_on date 読み取り専用。 ターゲット キーが作成された日時。
last_modified date 読み取り専用。 ターゲット キーが最後に変更された日時。

主な要件

キーの数

  • 一度に最大 500 個のアクティブ キーを使用できます。
  • キーごとに最大 100,000 個の値を使用できます。
  • 一度に最大 2,500,000 個のアクティブな値を使用できます。

キーの名前付け

  • キー名では大文字と小文字は区別されません。
  • 最大キー名の長さは 50 文字です。
  • キー名は、空白を含めずに 1 つの単語にする必要があります。
  • キー名には、次の特殊文字を含めることはできません。
    • " (二重引用符)
    • ' (アポストロフィ)
    • = (等号)
    • ! (感嘆符)
    • + (正符号)
    • # (ハッシュタグ)
    • * (アスタリスク)
    • ~ (チルダ)
    • ;(セミコロン)
    • ^ (キャレット)
    • () (かっこ)
    • <> (山かっこ)
    • [ ](角かっこ)
    • , (コンマ)
    • & (ampersand)
    • @ (at)
    • : (コロン)
    • ? (疑問符)
    • % (パーセント記号)
    • / (スラッシュ)

すべてのターゲット キーを表示する

$ curl -b cookies 'https://api.appnexus.com/targeting-key'

{
    "targeting-keys": [
        {
            "id": 7,
            "type": "string",
            "name": "key1",
            "label": null,
            "state": "active",
            "created_on": "2016-08-26 06:29:29",
            "last_modified": "2016-08-26 06:29:29"
        },
        {
            "id": 11,
            "type": "string",
            "name": "testkey",
            "label": null,
            "state": "active",
            "created_on": "2016-08-26 06:30:37",
            "last_modified": "2016-08-26 06:30:37"
        },
        {
            "id": 12,
            "type": "string",
            "name": "testkey3",
            "label": "This is a test",
            "state": "active",
            "created_on": "2016-08-26 08:04:42",
            "last_modified": "2016-08-26 08:15:02"
        }
    ]...
}

特定のターゲット キーを表示する

$ curl -b cookies 'https://api.appnexus.com/targeting-key?id=12'
 
{
    "targeting-key": {
        "id": 12,
        "type": "string",
        "name": "testkey3",
        "label": "This is a test",
        "state": "active",
        "created_on": "2016-08-26 08:04:42",
        "last_modified": "2016-08-26 08:15:02"
    }...
}

ターゲット キーを追加する

$ cat create_targeting_key.json
{
    "targeting-key": {
        "name": "testkey4",
        "type": "string"
    } 
}
 
$ curl -b cookies -H "Content-Type:application/json" -X POST -d '@create_targeting_key.json' 'https://api.appnexus.com/targeting-key'

ターゲット キーを変更する

$ cat update_targeting_key.json
{
    "targeting-key": {
        "name": "newtestkey3",
        "label": "This is a test"
    } 
}
 
$ curl -b cookies -H "Content-Type:application/json" -X PUT -d @update_target_key.json 'https://api.appnexus.com/targeting-key?id=12'

名前でターゲット キーをフィルター処理する

$ curl -b cookies 'https://api.appnexus.com/targeting-key?name=key1,key2'

{
    "targeting-keys": [
        {
            "id": 7,
            "type": "string",
            "name": "key1",
            "label": null,
            "state": "active",
            "created_on": "2016-08-26 06:29:29",
            "last_modified": "2016-08-26 06:29:29"
        },
        {
            "id": 8,
            "type": "string",
            "name": "key2",
            "label": null,
            "state": "active",
            "created_on": "2016-08-26 06:30:37",
            "last_modified": "2016-08-26 06:30:37"
        }
    ]...
} 

名前またはラベル内で検索する

次の使用例は、 または label フィールド内の任意の場所で文字列"car"name検索します。

$ curl -b cookies 'https://api.appnexus.com/targeting-key?search=car'

{
    "targeting-keys": [
        {
            "id": 1,
            "type": "string",
            "name": "bluecar",
            "label": null,
            "state": "active",
            "created_on": "2016-08-26 06:29:29",
            "last_modified": "2016-08-26 06:29:29"
        },
        {
            "id": 2,
            "type": "string",
            "name": "key5",
            "label": "Scary values",
            "state": "active",
            "created_on": "2016-08-26 06:29:29",
            "last_modified": "2016-08-26 06:29:29"
        },
        {
            "id": 3,
            "type": "string",
            "name": "car",
            "label": null,
            "state": "active",
            "created_on": "2016-08-26 06:30:37",
            "last_modified": "2016-08-26 06:30:37"
        }
    ]...
} 

最終更新日による並べ替え

結果は、、name、、labelcreated_onまたは last_modifiedid並べ替えることができます。 昇順 (asc) または降順descで並べ替えることができます。

$ curl -b cookies 'https://api.appnexus.com/targeting-key?sort=last_modified.asc'

{
    "targeting-keys": [
        {
            "id": 7,
            "type": "string",
            "name": "key1",
            "label": null,
            "state": "active",
            "created_on": "2016-08-26 06:29:29",
            "last_modified": "2016-08-26 06:29:29"
        },
        {
            "id": 10,
            "type": "string",
            "name": "akey",
            "label": null,
            "state": "active",
            "created_on": "2016-08-26 04:45:07",
            "last_modified": "2016-08-26 12:52:29"
        },
        {
            "id": 8,
            "type": "string",
            "name": "key2",
            "label": null,
            "state": "active",
            "created_on": "2016-08-26 06:30:37",
            "last_modified": "2016-08-30 10:34:37"
        }
    ]...
} 

ターゲット キーを削除する

ターゲット キーを削除すると、そのキーの下にあるすべての値が自動的に削除されます。

$ curl -b cookies -X DELETE 'https://api.appnexus.com/targeting-key?id=12'