I am working with Twitter ad API from the last one week. I need to find the Ad image corresponding to a particular Ad published through twitter. i am beginner in this platform.
so kindly any one can please help me in this case !! how to get an Ad image through an Ad API ?

Hello,

Thanks for reaching out. Could you share some example of an Ad which you would like to find the image? Would be great if you could share the link to the Ad (Or screenshot) as well for us to further troubleshoot the issue.

In here we are sharing promoted tweet details with image and tweet id obtained from twitter UI-creative page. when we try to access this same tweet details through an Ad API we can’t get the images . The API request and response is attached below:

**Request**
https://ads-api.twitter.com/{{version}}/accounts/{{account_id}}/tweets?tweet_type=PUBLISHED&tweet_ids=1559802708978044928

**Response**
{
    "request": {
        "params": {
            "tweet_ids": [
                "1559802708978044928"
            ],
            "tweet_type": "PUBLISHED",
            "account_id": "18ce54kub0e"
        }
    },
    "next_cursor": null,
    "data": [
        {
            "coordinates": null,
            "retweeted": false,
            "name": "202208_02",
            "conversation_settings": "EVERYONE",
            "source": "<a href=\"https://help.twitter.com/en/using-twitter/how-to-tweet#source-labels\" rel=\"nofollow\">advertiser-interface</a>",
            "entities": {
                "hashtags": [],
                "symbols": [],
                "user_mentions": [],
                "urls": []
            },
            "display_text_range": [
                0,
                103
            ],
            "favorite_count": 1,
            "in_reply_to_status_id_str": null,
            "geo": null,
            "id_str": "1559802708978044928",
            "scopes": {
                "followers": false
            },
            "in_reply_to_user_id": null,
            "truncated": false,
            "retweet_count": 0,
            "scheduled_status": null,
            "id": 1559802708978044928,
            "in_reply_to_status_id": null,
            "nullcast": true,
            "created_at": "Wed Aug 17 07:22:00 +0000 2022",
            "place": null,
            "scheduled_at": null,
            "tweet_type": "PUBLISHED",
            "favorited": false,
            "card_uri": "card://1559801617725407232",
            "full_text": "制作部門に「働き方改革」をもたらすクリエイティブ特化型プロジェクト管理ツール「AdFlow」(アドフロー)。\n利用者16万人突破!クリエイティブワークの生産性を高めてより効率的なweb広告運用を実現します!",
            "lang": "ja",
            "contributors": null,
            "in_reply_to_screen_name": null,
            "in_reply_to_user_id_str": null,
            "user": {
                "utc_offset": null,
                "name": "AdFlow@制作進行管理ツール・web広告/販促物の管理に(テレワーク中)",
                "friends_count": 479,
                "screen_name": "AdFlow_PR",
                "location": "東京都渋谷区",
                "protected": false,
                "url": "http://adflow.jp",
                "profile_image_url": "http://pbs.twimg.com/profile_images/915085391111139328/AQ666GQp_normal.jpg",
                "profile_background_color": "EBEBEB",
                "profile_use_background_image": true,
                "is_translator": false,
                "geo_enabled": false,
                "description": "制作業務に特化したプロジェクト管理ツール「AdFlow」の公式アカウントです。バナー・LPなどクリエイティブ関連のニュースをメインにAdFlowの最新情報などをお知らせしていきます。(開発・運営:株式会社クリエイターズマッチ)",
                "profile_link_color": "990000",
                "id_str": "606110726",
                "listed_count": 8,
                "default_profile_image": false,
                "followers_count": 296,
                "profile_image_url_https": "https://pbs.twimg.com/profile_images/915085391111139328/AQ666GQp_normal.jpg",
                "profile_sidebar_border_color": "DFDFDF",
                "profile_background_image_url": "http://abs.twimg.com/images/themes/theme7/bg.gif",
                "favourites_count": 151,
                "following": null,
                "default_profile": false,
                "withheld_in_countries": [],
                "id": 606110726,
                "profile_background_tile": false,
                "contributors_enabled": false,
                "follow_request_sent": null,
                "created_at": "Tue Jun 12 07:28:49 +0000 2012",
                "profile_sidebar_fill_color": "F3F3F3",
                "translator_type": "none",
                "lang": null,
                "profile_text_color": "333333",
                "notifications": null,
                "verified": false,
                "time_zone": null,
                "profile_banner_url": "https://pbs.twimg.com/profile_banners/606110726/1588061460",
                "statuses_count": 4431,
                "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme7/bg.gif",
                "is_translation_enabled": false
            },
            "tweet_id": "1559802708978044928"
        }
    ]
}

How we can get the tweet image URL or its media key through this Ad API ?

Hello,

You can actually use the card endpoint to retrieve the tweet image URL.

So from your previous API call, there is a card_uri field:

"card_uri": "card://1559801617725407232"

With this detail, you can perform an API call to the card endpoint:

twurl -H ads-api.twitter.com "/11/accounts/18ce54kub0e/cards?card_uris=card://1559801617725407232" | jq .

Which will return:

{
  "request": {
    "params": {
      "account_id": "18ce54kub0e",
      "card_uris": [
        "card://1559801617725407232"
      ]
    }
  },
  "next_cursor": null,
  "data": [
    {
      "name": "202208_02",
      "components": [
        {
          "media_key": "3_1559801584586227712",
          "media_metadata": {
            "3_1559801584586227712": {
              "type": "IMAGE",
              "url": "https://pbs.twimg.com/media/FaWHRulagAAlph0.jpg",
              "width": 800,
              "height": 800
            }
          },
          "type": "MEDIA"
        },
        {
          "title": "大手企業も続々導入!事例集や資料をダウンロード",
          "destination": {
            "url": "https://adflow.jp/?utm_source=twitter&utm_medium=cpc&utm_campaign=all",
            "type": "WEBSITE"
          },
          "type": "DETAILS"
        }
      ],
      "id": "1559801617725407232",
      "created_at": "2022-08-17T07:17:40Z",
      "card_uri": "card://1559801617725407232",
      "updated_at": "2022-08-17T07:17:40Z",
      "deleted": false,
      "card_type": "IMAGE_WEBSITE"
    }
  ]
}

If you see the url field, it returns https://pbs.twimg.com/media/FaWHRulagAAlph0.jpg which is the url of the image. Hope this helps.

Hello, thank you for your response,

we find that there is an error in twitter ad API document its seen like all is appended with this URL, so we cant get it earlier. the URL of that page is attached below. please check.

Hello,

The Card Fetch endpoint does not return Unified Card. As such, using the card fetch endpoint, you may not be able to retrieve the necessary data. Moving forward, please use the cards endpoint to retrieve any data related to the cards you have created. The card fetch endpoint will be deprecated soon but there is no timeline yet.

Thank your for your response. have a nice day