Search code examples
dockerdocker-registrydockerhub

API to get Top Docker Hub images?


I would like to know is there an API to get the Top Docker Hub images?

Like what we can get when we open https://hub.docker.com/explore/

I have checked:

https://docs.docker.com/engine/api/v1.28/# and https://docs.docker.com/registry/spec/api/

But did not find what I want.


Solution

  • From https://hub.docker.com/explore/, the following API is called :

    https://hub.docker.com/v2/repositories/library/?page=1&page_size=15

    The default filter is by descending pull count, it will give you the following response :

    {
        "count": 139,
        "next": "https://hub.docker.com/v2/repositories/library/?page=1&page_size=15",
        "previous": null,
        "results": [{
            "user": "library",
            "name": "nginx",
            "namespace": "library",
            "repository_type": "image",
            "status": 1,
            "description": "Official build of Nginx.",
            "is_private": false,
            "is_automated": false,
            "can_edit": false,
            "star_count": 5777,
            "pull_count": 618674944,
            "last_updated": "2017-04-06T16:35:19.178373Z",
            "build_on_cloud": null
        },
        ...
        ...
       ]
    }
    

    So the following will give your the top 100 docker images pulled on docker hub :

    https://hub.docker.com/v2/repositories/library/?page=1&page_size=100

    The page_size has a maximum size of 100 (so 100 per page) and count is the maximum count this endpoint can give (for all pages).

    For instance with curl and jq JSON parser :

    curl -s "https://hub.docker.com/v2/repositories/library/?page=1&page_size=100" | \
        jq '.results'
    

    Now there is an internal API from https://store.docker.com to query images either from the store or from dockerhub. The most popular ones from dockerhub can be retrieved with :

    https://store.docker.com/api/content/v1/products/search?page_size=100&q=%2B&source=community&type=image%2Cbundle

    Request result has a popularity numeric field. To get the images filtered by descending popularity:

    curl -s "https://store.docker.com/api/content/v1/products/search?page_size=100&q=%2B&source=community&type=image%2Cbundle" | \
        jq '.summaries | sort_by(-.popularity)'