> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreflux.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Docker Hub

> Client-mode REST API connector for a curated Docker Hub v2 slice: list repositories and image tags

Technical Preview

# Docker Hub

Client-mode REST API connector for a curated Docker Hub v2 slice: list repositories and image tags.

* Hub category: **Work and DevOps**.
* Base: `https://hub.docker.com`

## Template reference

Generated from the shipped broker template `docker-hub` (`-routeCode DOCKER_HUB`). It lists every event the template defines.

### Auth

Auth headers used by the template: `Authorization: Bearer {value.json.api_token}`.

### Template parameters

| Placeholder | Type | Description | Required |
| - | - | - | - |
| `RouteName` | string | Name of the Docker Hub connector | no |
| `BaseUrl` | string | Docker Hub base URL without trailing slash (e.g. [https://hub.docker.com](https://hub.docker.com)) | yes |

`BASE_ADDRESS` default: `https://hub.docker.com`.

### Events

| Event | Method | Endpoint | Request topic | Response topic | Payload fields |
| - | - | - | - | - | - |
| `Listrepos` | GET | `/v2/repositories/{value.json.namespace}/` | `devops/dockerhub/repos/list` | `devops/dockerhub/repos/list/response` | `api_token`, `namespace` |
| `Listtags` | GET | `/v2/repositories/{value.json.namespace}/{value.json.repository}/tags` | `devops/dockerhub/tags/list` | `devops/dockerhub/tags/list/response` | `api_token`, `namespace`, `repository` |
| `Getrepo` | GET | `/v2/repositories/{value.json.namespace}/{value.json.repository}/` | `devops/dockerhub/repos/get` | `devops/dockerhub/repos/get/response` | `api_token`, `namespace`, `repository` |

### Deploy

Get the template card (JSON with `template` and `metadata`) from the broker, then deploy the connector:

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
mosquitto_pub -t '$SYS/Coreflux/Command' -m "-routeCode DOCKER_HUB"
```

The deployable connector from the REST API app, with `BASE_ADDRESS` already filled in:

```lot theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
DEFINE ROUTE DockerHubRestApi WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://hub.docker.com"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '60'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT Listrepos
        WITH SOURCE_TOPIC "devops/dockerhub/repos/list"
        WITH DESTINATION_TOPIC "devops/dockerhub/repos/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/v2/repositories/{value.json.namespace}/"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.api_token}"
    ADD EVENT Listtags
        WITH SOURCE_TOPIC "devops/dockerhub/tags/list"
        WITH DESTINATION_TOPIC "devops/dockerhub/tags/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/v2/repositories/{value.json.namespace}/{value.json.repository}/tags"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.api_token}"
    ADD EVENT Getrepo
        WITH SOURCE_TOPIC "devops/dockerhub/repos/get"
        WITH DESTINATION_TOPIC "devops/dockerhub/repos/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/v2/repositories/{value.json.namespace}/{value.json.repository}/"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.api_token}"
```

Deploy it with `-addRoute` (do not include `ADD METADATA`).

### Usage example

Call `Listrepos` by publishing a JSON payload to its request topic, and read the reply on the response topic:

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
mosquitto_sub -t 'devops/dockerhub/repos/list/response' &
mosquitto_pub -t 'devops/dockerhub/repos/list' -m '{"api_token": "<api_token>", "namespace": "<namespace>"}'
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.