Skip to main content

How do I browse through all the resources in my account using the API?

Comments

20 comments

  • Debra Ornelas

    I don't understand what it is I need to get my phone with the right files and URL's it needs can you help me?

    0
  • Roee Ben Ari

    Hi Debra, please contact us via a support ticket with more information regarding your use-case.

    0
  • Susan Lindroos

    How can I do this in node.js?

    0
  • Roee Ben Ari

    Hi Susan, 

    You can do something like this:

    var result = [];
    var options = options = { type: "upload", max_results: 500 };

    function listResources(next_cursor) {
    if(next_cursor) {
    options["next_cursor"] = next_cursor;
    }
    cloudinary.api.resources(options, function(error,res){
    resources = res.resources;
    result = result.concat(resources);
    var more = res.next_cursor;
    listResources(more);
    });
    }

    1
  • Susan Lindroos

    Thank you! With few modifications I got it work nicely. :-)

    0
  • Roee Ben Ari

    That's great! thanks for the update :)

    0
  • Håkan Lindström

    How can I do this with php

    0
  • Roee Ben Ari

    Hi Håkan,

    You can try something like this:

    $resources = array();
    $api = new \Cloudinary\Api();

    $result = $api->resources(
    $options
    );

    $resources = array_merge($resources, $result["resources"]);

    while (!empty($result) && array_key_exists("next_cursor", $result)) {
    $options['next_cursor'] = $result["next_cursor"];
    $result = $api->resources(
    $options
    );
    $resources = array_merge($resources, $result["resources"]);
    }

     

    0
  • Håkan Lindström

    Thank you Roee Ben Ari

    0
  • Susan Lindroos

    How can I do it with .NET? There is many examples of uploding pictures but not how to do f.ex. listing

    0
  • Susan Lindroos

    I managed to do this in .NET but now that I would like to make listing according to given tag/tags I end up with problems. I can retrieve data but only 10 pics at the time and I'm talking about more than 1000 pictures/query. How can I increase that amount to 500?

    I'm using Visual Studio 2017 with cloudinarydotnet -package.

    My function call is getResult = cloudinary.ListResourcesByTag(TxtBxTag.Text, options.NextCursor).

    Your documentation says that I can use max_result as parameter but I don't know how because definition of the function says

    Public Function ListResourcesByTag(tag As String, Optional nextCursor As String = Nothing) As ListResourcesResult

     

    0
  • Yakir Perlin

    Hi, 

    Try to use this code:

    cloudinary.ListResources(new ListResourcesByTagParams()
                    {
                        MaxResults = 500,
                        Tag = "tag"
                    }); 

    Please let me know if it works for you.

    Best, Yakir

     

    0
  • Susan Lindroos

    It doesn't let me use ListResourcesByTagParams(). Your definition says

    Public Function ListResources(parameters As ListResourcesParams) As ListResourcesResult

    0
  • Yakir Perlin

    Hi Susan, 

    I'm sorry for the late response.

    Could you please elaborate on the error you received while using this code?

    The code I attached earlier in my response works for me.

    Best,

    Yakir

    0
  • Olaegbe Samuel

    Hi, 

    Please I need the FULL php example to fetch my files from the cloud.

    The above example seems to be incomplete.

     

    I have tried it and I get the following error: 

    Fatal error: Uncaught Error: Class 'Cloudinary\Api\Response' not found in C:\xampp\htdocs\libra_gold\src\Api.php:540 Stack trace: #0 C:\xampp\htdocs\libra_gold\src\Api.php(54): Cloudinary\Api->call_api('get', Array, Array, NULL) #1 C:\xampp\htdocs\libra_gold\drive.php(37): Cloudinary\Api->resources(NULL) #2 {main} thrown in C:\xampp\htdocs\libra_gold\src\Api.php on line 540

    0
  • Aditi Madan

    Hi Olaegbe,

    It looks like this is missing Api.php file. Please make sure you have included all the required PHP files in your project.

    You can download them from here: https://github.com/cloudinary/cloudinary_php/tree/master/src

    If you still experience issue then please raise a support ticket here: https://support.cloudinary.com/hc/en-us/requests/new and attach the zipped up project and we will be happy to take a look at it.

    Thanks,

    Aditi

    0
  • iotech

    hi i'm tring to get all my cloudinary acount statistique with 

        // cloudinary.v2.api.usage(callback);
     
    in loopback4 controller (node.js)
    but i get an error be like : cant resolve  api of undefined !!
    0
  • Stephen Doyle

    Hi iotech,

    The most likely reasons for that error are if you didn't include our SDK in your project, didn't include it in the 'require' section at the top of your file, or if your 'require' statement specifies v2 and you're also specifying v2 when making the API calls.

    If you did specify cloudinary.v2 in the require section, like this:

    const cloudinary = require('cloudinary').v2;

    then you don't need to use 'v2' again when calling the API methods, and you can change your example to 'cloudinary.api.usage(....)'

    Can you please check it and let me know if it works?
    Thanks!

     

    0
  • Fasaha Skill

    Hi,

    I use https://api.cloudinary.com/v1_1/<cloudname>/resources/image to get my resources, I will like to know how I can append max_result to this url to get all my images at once

    0
  • Loic Verger Del Bove

    Hi Fasaha,

    In our Admin API documentation, you can follow the cURL syntax to do so i.e you can add `?max_results=30` if you want to return 30 images e.g:

     https://api.cloudinary.com/v1_1/<cloudname>/resources/image?max_results=30

    Note that the maximum is 500 so if you have more than 500 images, you will need to use the `next_cursor` parameter for all the calls after the 1st one i.e:

    https://api.cloudinary.com/v1_1/<cloudname>/resources/image?max_results=30&next_cursor=value

    Hope that helps.

    Loic

     

    0

Please sign in to leave a comment.