Newbie question: is there a way to export a csv?

Hi there, I’m trying to use Cloudflare images as my CDN for salesforce so I don’t have to load each image manually. The upload functionality works great in Cloudflare, and it’s creating my thumbnail nicely.

My question is: How can I export all the image links and image filenames in a csv? I really don’t want to have to click each one to copy the image url.

Thanks in advance!!

Sounds like a job for the API - or in other words, I’m pretty sure the API is the only way.

GET https://api.cloudflare.com/client/v4/accounts/:account_identifier/images/v1 will return a response like so:

{
    "result": {
        "images": [
            {
                "id": "cfac5b1c-3e54-4b0c-1d93-fb4effb51c00",
                "filename": "image1.png",
                "uploaded": "2022-04-07T18:22:47.846Z",
                "requireSignedURLs": false,
                "variants": [
                    "https://imagedelivery.net/accountid/cfac5b1c-3e54-4b0c-1d93-fb4effb51c00/public"
                ]
            },
            {
                "id": "4d263d6d-cdb6-4781-fe91-a4a45ee1bc00",
                "filename": "image2.png",
                "uploaded": "2022-03-16T12:52:34.495Z",
                "requireSignedURLs": false,
                "variants": [
                    "https://imagedelivery.net/accountid/4d263d6d-cdb6-4781-fe91-a4a45ee1bc00/public"
                ]
            }
        ]
    },
    "result_info": null,
    "success": true,
    "errors": [],
    "messages": []
}

You can find out how to make an API request & generate the necessary tokens at Cloudflare API v4 Documentation

You can copy just the insides of the "images": [] block into something like JSON To CSV Converter to make a CSV.

[
   {
      "id": "cfac5b1c-3e54-4b0c-1d93-fb4effb51c00",
      "filename": "image1.png",
      "uploaded": "2022-04-07T18:22:47.846Z",
      "requireSignedURLs": false,
      "variants": [
         "https://imagedelivery.net/accountid/cfac5b1c-3e54-4b0c-1d93-fb4effb51c00/public"
      ]
   },
   {
      "id": "4d263d6d-cdb6-4781-fe91-a4a45ee1bc00",
      "filename": "image2.png",
      "uploaded": "2022-03-16T12:52:34.495Z",
      "requireSignedURLs": false,
      "variants": [
         "https://imagedelivery.net/accountid/4d263d6d-cdb6-4781-fe91-a4a45ee1bc00/public"
      ]
   }
]

becomes

id,filename,uploaded,requireSignedURLs,variants/0
cfac5b1c-3e54-4b0c-1d93-fb4effb51c00,image1.png,2022-04-07T18:22:47.846Z,false,https://imagedelivery.net/accountid/cfac5b1c-3e54-4b0c-1d93-fb4effb51c00/public
4d263d6d-cdb6-4781-fe91-a4a45ee1bc00,image2.png,2022-03-16T12:52:34.495Z,false,https://imagedelivery.net/accountid/4d263d6d-cdb6-4781-fe91-a4a45ee1bc00/public
1 Like

@KianNH - thank you very much, works great. I do have one follow up - right now the API seems to default to just 50 images (+their variants) in the returned JSON. Is there a way to have it return ALL images?

1 Like

@KianNH - nevermind, I went through the documentation and saw that I needed to add a couple of additional parameters to the api request (page=2&per_page=50) and that it only returns a max of 50 per request. Good to go :slight_smile:

1 Like

This topic was automatically closed after 15 days. New replies are no longer allowed.