You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks a lot for this information! That is tremendously helpful.
I notice that they send a cookie (Set-Cookie: sessionid=oxd81rvw70noo42xqwg594t6ngc8ncsq; expires=Mon, 25-May-2015 19:16:28 GMT; httponly; Max-Age=1209600; Path=/), that is a bit odd. Otherwise, it all seems straightforward.
Since this issue comes up at the top of the result list when searching for how to get a badge that shows the latest version of a collection on Ansible Galaxy, I'll post our solution for that.
That allows using the dynamic badge creation feature of shields.io, e.g. in Markdown syntax:

Resulting in this badge:
Reacted by Ken Dreyer, Dmytro Bondar, Leigh Johnson Zaman and Mark Hansen
Thanks for sharing @andy-maier! Given the above, it seems like we should be able to add a native version badge if you or anyone else would be interested in submitting a PR
E.g. https://galaxy.ansible.com/api/v1/roles/?search=olivetin URL is: https://img.shields.io/ansible/role/57702
URL is: https://img.shields.io/badge/dynamic/json?color=blueviolet&label=Galaxy%20Downloads&query=%24.download_count&url=https%3A%2F%2Fgalaxy.ansible.com%2Fapi%2Fv1%2Froles%2F57702%2F%3Fformat%3Djson
Activity
espadrine commentedon Oct 22, 2014
All this information is greatly appreciated!
Lacking knowledge about Ansible, however, it is difficult for me to understand which kind of badge I can provide.
tersmitten commentedon Oct 29, 2014
How thoughtful of me :-) I will look into it...
igormukhingmailcom commentedon May 5, 2015
Hi, @espadrine!
For example, I have some ansible role at https://github.com/ansible-roles/ansible-role-sublimetext3_packagecontrol and published at Galaxy https://galaxy.ansible.com/list#/roles/3078
So, 3078 is the role ID that used in API calls.
I think there will be cool if next badges for ansible will be available at shields.io:
To generate all this badges we need get only role ID from user. Or even just role's galaxy URL and then automatically extract ID from hash.
espadrine commentedon May 11, 2015
Thanks a lot for this information! That is tremendously helpful.
I notice that they send a cookie (
Set-Cookie: sessionid=oxd81rvw70noo42xqwg594t6ngc8ncsq; expires=Mon, 25-May-2015 19:16:28 GMT; httponly; Max-Age=1209600; Path=/), that is a bit odd. Otherwise, it all seems straightforward.igormukhingmailcom commentedon May 12, 2015
@espadrine Don't think that cookies matter something.
You can just get information and not care about cookies.
Try
wget -qO - https://galaxy.ansible.com/api/v1/roles/3078/versions/.igormukhingmailcom commentedon Sep 6, 2015
@espadrine Hi. How can I help you to force some progress on this?
espadrine commentedon Sep 7, 2015
I tried making the first one, with this kind of style:
I am unsure of whether that suits the notion of "role" that users are familiar with, or how easy it is to figure out where to find the role id.
Ansible role
igormukhingmailcom commentedon Sep 7, 2015
Oh, cool :)
Role Id assigned to role once it added to galaxy.
For example this is list of my roles: https://galaxy.ansible.com/list#/users/9737
smiller171 commentedon Feb 19, 2016
@igormukhingmailcom does getting the information like this still work? I can't find IDs on my roles.
tersmitten commentedon Feb 19, 2016
Ansible galaxy 2 uses "name based" urls now, but old urls should be
redirected.
On Friday, 19 February 2016, Scott Miller notifications@github.com wrote:
smiller171 commentedon Feb 19, 2016
Sounds like we probably need a PR to fix this functionality then
danvaida commentedon Mar 14, 2017
@smiller171 here's a one-liner for finding your role's ID once it's on Galaxy:
This works on Ansible
2.2.2.0but I recon it's working on older versions, too.andy-maier commentedon Nov 27, 2020
Since this issue comes up at the top of the result list when searching for how to get a badge that shows the latest version of a collection on Ansible Galaxy, I'll post our solution for that.
Ansible Galaxy returns the latest version of a collection using an HTTP GET on
https://galaxy.ansible.com/api/v2/collections/{NS}/{COLL}/ as follows:
That allows using the dynamic badge creation feature of shields.io, e.g. in Markdown syntax:
Resulting in this badge:
calebcartwright commentedon Nov 27, 2020
Thanks for sharing @andy-maier! Given the above, it seems like we should be able to add a native version badge if you or anyone else would be interested in submitting a PR
IronTooch commentedon Jan 29, 2022
For anyone who finds this search, you can use the API to query for a role directly. E.g.
https://galaxy.ansible.com/api/v1/roles/?search=myroleAnd once you get the role ID, you can use this to get the downloads count:
https://img.shields.io/badge/dynamic/json?color=blueviolet&label=Galaxy%20Downloads&query=%24.download_count&url=https%3A%2F%2Fgalaxy.ansible.com%2Fapi%2Fv1%2Froles%2FROLEID%2F%3Fformat%3Djson
E.g.

URL is:
https://galaxy.ansible.com/api/v1/roles/?search=olivetinhttps://img.shields.io/ansible/role/57702https://img.shields.io/badge/dynamic/json?color=blueviolet&label=Galaxy%20Downloads&query=%24.download_count&url=https%3A%2F%2Fgalaxy.ansible.com%2Fapi%2Fv1%2Froles%2F57702%2F%3Fformat%3Djson