並べ替え

並べ替えは(オブジェクトのリストを返す)ほとんどの広告APIで利用できます。エンドポイントによっては、並べ替えでさまざまなパラメータが有効になっていることが確認できます。こうしたパラメータによって返されるほとんどのフィールド(IDとENUM以外)は並べ替えることができます。

APIコレクション 並べ替え可能なパラメータ
アカウント created_atupdated_atdeletedname
お支払い方法 created_atupdated_atdeletedfunded_amount_local_microstart_timeend_time
キャンペーン created_atupdated_atdeletednamestart_timeend_timedaily_budget_amount_local_micrototal_budget_amount_local_microstandard_delivery
行項目 created_atupdated_atdeletedbid_amount_local_micro
カード created_atupdated_atdeletedname
プロモアカウント created_atupdated_atdeletedpaused
プロモツイート created_atupdated_atdeletedpaused
アプリイベントタグ created_atupdated_atdeletedpost_view_attribution_windowpost_engagement_attribution_windowassisted_conversionprovider_app_event_name

はじめに

属性がGETリクエストのJSONで返される有効なものである場合は、APIリクエストにsort_by=[attribute name]-[asc/desc]を追加します。

たとえば、?name-ascを使用して名前をアルファベット順に並べ替えたり、?name-descを使用して逆順に並べ替えたりできます。

詳細

以下はbid_amount_local_micro別にすべての行項目を降順に返すサンプルAPIリクエストです。

$ twurl -H ads-api.x.com"/5/accounts/k9w0oe/line_items?sort_by=bid_amount_local_micro-desc"
{
  "request": {
    "params": {
      "sort_by": [
        "bid_amount_local_micro-desc"
      ],
      "account_id": "k9w0oe"
    }
  },
  "data": [
    {
      "bid_type": "MAX",
      "name": "Untitled",
      "placements": [
        "ALL_ON_TWITTER"
      ],
      "bid_amount_local_micro": 3000000,
      "automatically_select_bid": false,
      "advertiser_domain": null,
      "primary_web_event_tag": null,
      "charge_by": "ENGAGEMENT",
      "product_type": "PROMOTED_TWEETS",
      "bid_unit": "ENGAGEMENT",
      "total_budget_amount_local_micro": null,
      "objective": "ENGAGEMENTS",
      "id": "1iw6k",
      "paused": true,
      "optimization": "DEFAULT",
      "categories": [

      ],
      "currency": "USD",
      "created_at": "2014-09-09T02:11:32Z",
      "updated_at": "2015-05-27T23:01:45Z",
      "include_sentiment": "POSITIVE_ONLY",
      "campaign_id": "1kv71",
      "creative_source": "MANUAL",
      "deleted": false
    },
    {
      "bid_type": "MAX",
      "name": "Untitled",
      "placements": [
        "ALL_ON_TWITTER"
      ],
      "bid_amount_local_micro": 3000000,
      "automatically_select_bid": false,
      "advertiser_domain": null,
      "primary_web_event_tag": null,
      "charge_by": "FOLLOW",
      "product_type": "PROMOTED_ACCOUNT",
      "bid_unit": "FOLLOW",
      "total_budget_amount_local_micro": null,
      "objective": "FOLLOWERS",
      "id": "1nlqp",
      "paused": false,
      "optimization": "DEFAULT",
      "categories": [

      ],
      "currency": "USD",
      "created_at": "2014-10-20T18:57:18Z",
      "updated_at": "2014-10-20T18:57:18Z",
      "include_sentiment": null,
      "campaign_id": "1pjkp",
      "creative_source": "MANUAL",
      "deleted": false
    },
    {
      "bid_type": "MAX",
      "name": "Untitled",
      "placements": [
        "ALL_ON_TWITTER"
      ],
      "bid_amount_local_micro": 2500000,
      "automatically_select_bid": false,
      "advertiser_domain": null,
      "primary_web_event_tag": null,
      "charge_by": "ENGAGEMENT",
      "product_type": "PROMOTED_TWEETS",
      "bid_unit": "ENGAGEMENT",
      "total_budget_amount_local_micro": null,
      "objective": "ENGAGEMENTS",
      "id": "1iw6l",
      "paused": true,
      "optimization": "DEFAULT",
      "categories": [

      ],
      "currency": "USD",
      "created_at": "2014-09-09T02:11:54Z",
      "updated_at": "2014-09-17T06:23:23Z",
      "include_sentiment": "POSITIVE_ONLY",
      "campaign_id": "1kv71",
      "creative_source": "MANUAL",
      "deleted": false
    },
    {
      "bid_type": "MAX",
      "name": "Untitled",
      "placements": [
        "ALL_ON_TWITTER"
      ],
      "bid_amount_local_micro": 2500000,
      "automatically_select_bid": false,
      "advertiser_domain": null,
      "primary_web_event_tag": null,
      "charge_by": "ENGAGEMENT",
      "product_type": "PROMOTED_TWEETS",
      "bid_unit": "ENGAGEMENT",
      "total_budget_amount_local_micro": null,
      "objective": "ENGAGEMENTS",
      "id": "1iw9q",
      "paused": false,
      "optimization": "DEFAULT",
      "categories": [

      ],
      "currency": "USD",
      "created_at": "2014-09-09T03:11:46Z",
      "updated_at": "2014-09-09T03:26:17Z",
      "include_sentiment": "POSITIVE_ONLY",
      "campaign_id": "1kv71",
      "creative_source": "MANUAL",
      "deleted": false
    },
    {
      "bid_type": "MAX",
      "name": "Untitled",
      "placements": [
        "ALL_ON_TWITTER"
      ],
      "bid_amount_local_micro": 2500000,
      "automatically_select_bid": false,
      "advertiser_domain": null,
      "primary_web_event_tag": null,
      "charge_by": "ENGAGEMENT",
      "product_type": "PROMOTED_TWEETS",
      "bid_unit": "ENGAGEMENT",
      "total_budget_amount_local_micro": null,
      "objective": "ENGAGEMENTS",
      "id": "1iw9r",
      "paused": false,
      "optimization": "DEFAULT",
      "categories": [

      ],
      "currency": "USD",
      "created_at": "2014-09-09T03:12:02Z",
      "updated_at": "2014-09-09T03:30:44Z",
      "include_sentiment": "POSITIVE_ONLY",
      "campaign_id": "1kv71",
      "creative_source": "MANUAL",
      "deleted": false
    },
    {
      "bid_type": "MAX",
      "name": "Untitled",
      "placements": [
        "TWITTER_TIMELINE",
        "TWITTER_PROFILE"
      ],
      "bid_amount_local_micro": 2000000,
      "automatically_select_bid": false,
      "advertiser_domain": null,
      "primary_web_event_tag": null,
      "charge_by": "ENGAGEMENT",
      "product_type": "PROMOTED_TWEETS",
      "bid_unit": "ENGAGEMENT",
      "total_budget_amount_local_micro": null,
      "objective": "ENGAGEMENTS",
      "id": "1kkze",
      "paused": false,
      "optimization": "DEFAULT",
      "categories": [

      ],
      "currency": "USD",
      "created_at": "2014-09-24T01:18:20Z",
      "updated_at": "2015-08-30T04:41:34Z",
      "include_sentiment": null,
      "campaign_id": "1mj4h",
      "creative_source": "MANUAL",
      "deleted": false
    },
    {
      "bid_type": "MAX",
      "name": "Untitled",
      "placements": [
        "TWITTER_TIMELINE",
        "TWITTER_PROFILE"
      ],
      "bid_amount_local_micro": 2000000,
      "automatically_select_bid": false,
      "advertiser_domain": null,
      "primary_web_event_tag": null,
      "charge_by": "ENGAGEMENT",
      "product_type": "PROMOTED_TWEETS",
      "bid_unit": "ENGAGEMENT",
      "total_budget_amount_local_micro": null,
      "objective": "ENGAGEMENTS",
      "id": "1kkzk",
      "paused": false,
      "optimization": "DEFAULT",
      "categories": [

      ],
      "currency": "USD",
      "created_at": "2014-09-24T01:23:06Z",
      "updated_at": "2015-08-30T04:41:34Z",
      "include_sentiment": null,
      "campaign_id": "1mj4n",
      "creative_source": "MANUAL",
      "deleted": false
    },
    {
      "bid_type": "MAX",
      "name": "Untitled",
      "placements": [
        "ALL_ON_TWITTER"
      ],
      "bid_amount_local_micro": 2000000,
      "automatically_select_bid": false,
      "advertiser_domain": null,
      "primary_web_event_tag": null,
      "charge_by": "ENGAGEMENT",
      "product_type": "PROMOTED_TWEETS",
      "bid_unit": "ENGAGEMENT",
      "total_budget_amount_local_micro": null,
      "objective": "ENGAGEMENTS",
      "id": "1kkzq",
      "paused": false,
      "optimization": "DEFAULT",
      "categories": [

      ],
      "currency": "USD",
      "created_at": "2014-09-24T01:25:06Z",
      "updated_at": "2014-09-24T01:34:20Z",
      "include_sentiment": "POSITIVE_ONLY",
      "campaign_id": "1mj48",
      "creative_source": "MANUAL",
      "deleted": false
    },
    {
      "bid_type": "MAX",
      "name": "Untitled",
      "placements": [
        "ALL_ON_TWITTER"
      ],
      "bid_amount_local_micro": 2000000,
      "automatically_select_bid": false,
      "advertiser_domain": null,
      "primary_web_event_tag": null,
      "charge_by": "ENGAGEMENT",
      "product_type": "PROMOTED_TWEETS",
      "bid_unit": "ENGAGEMENT",
      "total_budget_amount_local_micro": null,
      "objective": "ENGAGEMENTS",
      "id": "1kkzr",
      "paused": false,
      "optimization": "DEFAULT",
      "categories": [

      ],
      "currency": "USD",
      "created_at": "2014-09-24T01:25:09Z",
      "updated_at": "2014-09-24T01:34:41Z",
      "include_sentiment": "POSITIVE_ONLY",
      "campaign_id": "1mj48",
      "creative_source": "MANUAL",
      "deleted": false
    },
    {
      "bid_type": "MAX",
      "name": "Untitled",
      "placements": [
        "ALL_ON_TWITTER"
      ],
      "bid_amount_local_micro": 2000000,
      "automatically_select_bid": false,
      "advertiser_domain": null,
      "primary_web_event_tag": null,
      "charge_by": "ENGAGEMENT",
      "product_type": "PROMOTED_TWEETS",
      "bid_unit": "ENGAGEMENT",
      "total_budget_amount_local_micro": 6000000,
      "objective": "ENGAGEMENTS",
      "id": "1kl0e",
      "paused": false,
      "optimization": "DEFAULT",
      "categories": [

      ],
      "currency": "USD",
      "created_at": "2014-09-24T01:42:49Z",
      "updated_at": "2014-09-24T01:51:25Z",
      "include_sentiment": "POSITIVE_ONLY",
      "campaign_id": "1mj57",
      "creative_source": "MANUAL",
      "deleted": false
    },
    {
      "bid_type": "MAX",
      "name": "Untitled",
      "placements": [
        "ALL_ON_TWITTER"
      ],
      "bid_amount_local_micro": 2000000,
      "automatically_select_bid": false,
      "advertiser_domain": null,
      "primary_web_event_tag": null,
      "charge_by": "ENGAGEMENT",
      "product_type": "PROMOTED_TWEETS",
      "bid_unit": "ENGAGEMENT",
      "total_budget_amount_local_micro": 12000000,
      "objective": "ENGAGEMENTS",
      "id": "1kl0g",
      "paused": false,
      "optimization": "DEFAULT",
      "categories": [

      ],
      "currency": "USD",
      "created_at": "2014-09-24T01:43:19Z",
      "updated_at": "2014-09-24T01:51:40Z",
      "include_sentiment": "POSITIVE_ONLY",
      "campaign_id": "1mj57",
      "creative_source": "MANUAL",
      "deleted": false
    },
    {
      "bid_type": "MAX",
      "name": "Untitled",
      "placements": [
        "ALL_ON_TWITTER"
      ],
      "bid_amount_local_micro": 2000000,
      "automatically_select_bid": false,
      "advertiser_domain": null,
      "primary_web_event_tag": null,
      "charge_by": "ENGAGEMENT",
      "product_type": "PROMOTED_TWEETS",
      "bid_unit": "ENGAGEMENT",
      "total_budget_amount_local_micro": 6000000,
      "objective": "ENGAGEMENTS",
      "id": "1kl0l",
      "paused": false,
      "optimization": "DEFAULT",
      "categories": [

      ],
      "currency": "USD",
      "created_at": "2014-09-24T01:45:09Z",
      "updated_at": "2014-09-24T01:51:54Z",
      "include_sentiment": "POSITIVE_ONLY",
      "campaign_id": "1mj5d",
      "creative_source": "MANUAL",
      "deleted": false
    }
  ],
  "next_cursor": null
}