To list multiple public IDs via the Admin API can be done by using sending a request to our API endpoint or using our SDKs.
API Endpoint
The Admin API is accessed using HTTPS to endpoints. By default, the API endpoint uses the following format:
https://api.cloudinary.com/v1_1/:cloud_name/:action
To list by multiple public IDs via the Admin API, you can use the following code:
GET http://api.cloudinary.com/v1_1/{cloud_name}/resources/{resource_type}/{type}
with public_ids parameter containing a comma-separated list of public IDs (e.g. image1,image2
or multiple public_ids parameters (e.g. public_ids[]=image1&public_ids[]=image2
).
For example:
https://api.cloudinary.com/v1_1/{cloud_name}/resources/{resource_type}/{type}?public_ids[]=image1&public_ids[]=image2
https://api.cloudinary.com/v1_1/{cloud_name}/resources/{resource_type}/{type}?public_ids=image,image2
SDK
This can be also done via one of our integration libraries that have an Admin API list resources_by_ids call. For example in Rails:
Cloudinary::Api.resources_by_ids(["image1", "image2"])
You can view another example in our documentation.
Comments
6 comments
Hi,
Can you please help with an example to use resourcesByIds using Java Library please?
I'm stuck on it for days now.
Hi Bharat,
Here's an example from the Admin-API documentation (click the Java tab on the widget):
http://cloudinary.com/documentation/admin_api#list_all_uploaded_images_with_the_given_ids
Does it help?
Hi Cloudinary Support,
Is there a way to bulk list resources? I know that I can pass up to 100 public_ids in a single API call, but is there a way to use a next_cursor or something similar to get resources_by_ids in excess of 1000 public_ids? I'm writing a script which would update the Avatar of all users but have been road-blocked by the 100 public_id limit. If I loop through an perform an API call per user I hit the Cloudinary API rate limit of 500 transactions per hour. Any suggestions?
Hi Ryan,
Here is more information of how to list all your resources using next_cursor and checking the API rate limit.
https://support.cloudinary.com/hc/en-us/articles/205714121-How-do-I-browse-through-all-the-resources-in-my-account-using-the-API-
Please let me know if that works for you
Hi Shirly,
Thanks for your reply. Actually rather than just browsing all resources I am looking to get information from Cloudinary about a large group of images used as Avatar images for users.
```if user.avatar?
cloudinary_public_ids << user.avatar.public_id # this returns hundreds of results
end
Cloudinary::Api.resources_by_ids(cloudinary_public_ids) # should return has of info about these resources
# results in error because .resources_by_ids only allows 100 public_ids at a time
```
I however found a work-around for this by using the Ruby API method ``` .in_groups_of(n)``` which would then allow me to break my array of public IDs into chunks and get my resources that way.
```cloudinary_public_ids.in_groups_of(100) do |cpi|
cpi.each do |p_ids|
results << Cloudinary::Api.resources_by_ids(p_ids)
end
end```
I ended up finding a solution which didn't require making any API calls to get the necessary information, but I'm hoping this helps someone else who is trying to do something similar.
Thank you Ryan for sharing your code with Cloudinary community!
Please sign in to leave a comment.