# Random-d.uk

> Put a duck in your workflow with Random-d.uk, the free keyless picture site at random-d.uk: 559 duck photographs and 57 animations, and counting. Get one at random for a stand-up opener or a channel mascot, get a handful for a gallery, download one as a file to attach to an email, or get it inline as a data URI where a link will not load. It also keeps a duck for fifteen HTTP status codes, so an alert about a 404 or a 500 can carry the duck that stands for it. Every duck has a number, so a duck worth keeping can be fetched again exactly, and a seeded pick gives the same duck all day and a new one tomorrow.

App · Images & Design · 10 actions. Web page: https://docs.lodol.com/docs/integrations/random-d-uk

## Actions

### Check service status

Check whether Random-d.uk is up and handing out ducks, and how quickly. This is the one action that reports a problem as a value instead of failing the step, so a workflow can decide what to do about it. Answering at all and answering with a duck are reported separately, because a parked domain does the first and not the second.

**Inputs**: None.

**Outputs**

- `byte_size` (number): How many bytes the site answered with.
- `content_type` (text): The media type the site answered with, application/json when it is handing out ducks.
- `image_url` (text): The picture the check itself was given, so a green check comes with a duck. Null when the site answered without one.
- `message` (text): A one-line summary of the result.
- `online` (true/false): True when the site answered with a duck. This is the field to branch on.
- `reachable` (true/false): True when the site answered at all, whatever it said.
- `response_time_ms` (number): How long the request took, in milliseconds.
- `status_code` (number): The HTTP status the site answered with, or null when it could not be reached.

**Example output**

```json
{
  "byte_size": 74,
  "content_type": "application/json",
  "image_url": "https://random-d.uk/api/v2/449.jpg",
  "message": "Random-d.uk is up and handing out ducks (172.7 ms for /api/v2/random).",
  "online": true,
  "reachable": true,
  "response_time_ms": 172.7,
  "status_code": 200
}
```

### Count the ducks

Find out how many ducks Random-d.uk has right now, across the photos, the GIFs and the HTTP status codes, and which photo is the newest. The collection grows as people send more ducks in. Use it to pin a seeded pick, to bound a duck number a workflow makes up, or to notice when new ducks have arrived. Two counts come back for the photos because the site reports two: duck_count is how many pictures there are, and file_count is the site's own tally of filenames, which is higher because it lists most pictures twice.

**Inputs**: None.

**Outputs**

- `duck_count` (number): How many distinct photos the site has. This is the number to quote and the one a seeded pick draws from. It goes up over time and never down.
- `file_count` (number): The site's own image_count, which counts filenames rather than pictures: most photos are listed twice, once as n.jpg and once as n.JPG, and the two are the same picture. It runs about half again as high as duck_count, so do not report it as a number of ducks.
- `gif_count` (number): How many distinct GIFs the site has.
- `gif_file_count` (number): The site's own gif_count. The GIFs are listed once each, so this matches gif_count.
- `http_code_count` (number): How many HTTP status codes have a duck of their own.
- `newest` (object): The newest photo. They are numbered from 1 upwards, so it is the last one.
- `source_url` (text): The address the counts were read from.

**Example output**

```json
{
  "duck_count": 559,
  "file_count": 822,
  "gif_count": 57,
  "gif_file_count": 57,
  "http_code_count": 15,
  "newest": {
    "attribution": "Powered by random-d.uk",
    "content_type": "image/jpeg",
    "duck_number": 559,
    "filename": "random-d-uk-559.jpg",
    "image_tag": "<img src=\"https://random-d.uk/api/v2/559.jpg\" alt=\"Duck photo number 559 from Random-d.uk\" />",
    "image_url": "https://random-d.uk/api/v2/559.jpg",
    "markdown": "![Duck photo number 559 from Random-d.uk](https://random-d.uk/api/v2/559.jpg)",
    "type": "jpg"
  },
  "source_url": "https://random-d.uk/api/v2/list"
}
```

### Download a duck

Download a duck as a file, so a later step can attach it to an email, post it into a chat or put it in storage. Use this where a link will not do and the picture has to travel with the message. Name a duck by its number or by an HTTP status code, or leave both empty to download one at random. These are full-size pictures rather than thumbnails, so expect a few hundred kilobytes for a photo and a few megabytes for a GIF.

**Inputs**

- Duck number (`duck_number`, number): Optional. Which duck to fetch, by the number in its filename: 449 is the duck at https://random-d.uk/api/v2/449.jpg. Leave both this and the status code empty to fetch one at random, which costs one extra request. At least 1.
- HTTP status code (`status_code`, number): Optional. Fetch the duck for an HTTP status code instead of a numbered one, such as 404. Give this or a duck number, not both: they are different pictures, since duck number 404 is an unrelated photograph. From 100 to 599.
- Kind of picture (`type`, text): Optional, photo by default. The photos and the GIFs are numbered separately, so duck 46 the photo and duck 46 the GIF are two different ducks. There are 57 GIFs, so a GIF number is a much smaller number than a photo number. One of: `jpg` (Photo (JPG)), `gif` (Animated (GIF)). Default: `jpg`.

**Outputs**

- `attribution` (text): The credit the site asks to be shown with its pictures, normally 'Powered by random-d.uk'. On a random draw it is the site's own wording, taken from the answer itself.
- `byte_size` (number): The stored file's size in bytes.
- `content_type` (text): The picture's media type, image/jpeg or image/gif.
- `document_ref` (text): The stored document's reference.
- `documents` (list): The downloaded picture as a document, ready to attach to a later step.
- `duck_number` (number): The duck's number, which is how a duck is named on this site: duck 449 is the picture at https://random-d.uk/api/v2/449.jpg, and it stays that duck for good. Keep it to fetch the same duck again later. Null for a duck that has no number: the HTTP status code ducks are filed under their code instead, and a random draw that came back with an address carrying no number leaves it empty.
- `filename` (text): A file name for this duck, safe to write anywhere, such as random-d-uk-449.jpg. It is what the download step names the file.
- `image_tag` (text): The picture as a ready-made HTML img tag with alt text, for a step that writes an email body or a web page.
- `image_url` (text): The picture itself, ready to use as an img src, in a Markdown image or in most chat apps' unfurls. Always https, including where the site answered with a plain http address of its own.
- `markdown` (text): The picture as a ready-made Markdown image, for a README, an issue or a chat app that renders Markdown.
- `type` (text): Which kind of picture this is, jpg or gif. The photos and the GIFs are numbered separately, so duck 46 the photo and duck 46 the GIF are two different ducks.
- `url` (text): A URL that serves the stored file. The duck's own address on the site stays in image_url.
- `was_random` (true/false): True when no duck was named and one was drawn at random. Branch on this rather than on whether the field was filled in.

**Example output**

```json
{
  "attribution": "Powered by random-d.uk",
  "byte_size": 313205,
  "content_type": "image/jpeg",
  "document_ref": "doc_7c1f4a8e05b3427d9a6e2f8b3c5d1e90",
  "documents": [
    {
      "content_type": "image/jpeg",
      "document_ref": "doc_7c1f4a8e05b3427d9a6e2f8b3c5d1e90",
      "filename": "random-d-uk-449.jpg",
      "size_bytes": 313205,
      "url": "/actions/core/serve-document/doc_7c1f4a8e05b3427d9a6e2f8b3c5d1e90"
    }
  ],
  "duck_number": 449,
  "filename": "random-d-uk-449.jpg",
  "image_tag": "<img src=\"https://random-d.uk/api/v2/449.jpg\" alt=\"Duck photo number 449 from Random-d.uk\" />",
  "image_url": "https://random-d.uk/api/v2/449.jpg",
  "markdown": "![Duck photo number 449 from Random-d.uk](https://random-d.uk/api/v2/449.jpg)",
  "type": "jpg",
  "url": "/actions/core/serve-document/doc_7c1f4a8e05b3427d9a6e2f8b3c5d1e90",
  "was_random": false
}
```

### Get a duck as a data URI

Get a duck inline, as a data URI rather than a link or a file, for somewhere that renders HTML but will not fetch a remote picture: an email whose images are blocked by default, a self-contained report, a page a later step builds. These are full-size photographs, and base64 adds a third again on top, so a picture over about 1.5 MB is refused and told to use the download step instead. Most photos are well under that; most GIFs are not.

**Inputs**

- Duck number (`duck_number`, number): Optional. Which duck to fetch, by the number in its filename: 449 is the duck at https://random-d.uk/api/v2/449.jpg. Leave both this and the status code empty to fetch one at random, which costs one extra request. At least 1.
- HTTP status code (`status_code`, number): Optional. Fetch the duck for an HTTP status code instead of a numbered one, such as 404. Give this or a duck number, not both: they are different pictures, since duck number 404 is an unrelated photograph. From 100 to 599.
- Kind of picture (`type`, text): Optional, photo by default. The photos and the GIFs are numbered separately, so duck 46 the photo and duck 46 the GIF are two different ducks. There are 57 GIFs, so a GIF number is a much smaller number than a photo number. One of: `jpg` (Photo (JPG)), `gif` (Animated (GIF)). Default: `jpg`.

**Outputs**

- `attribution` (text): The credit the site asks to be shown with its pictures, normally 'Powered by random-d.uk'. On a random draw it is the site's own wording, taken from the answer itself.
- `byte_size` (number): The picture's size in bytes before encoding. The data URI is roughly a third longer again.
- `content_type` (text): The picture's media type, image/jpeg or image/gif.
- `data_uri` (text): The whole picture as a 'data:image/jpeg;base64,...' string, ready to use as the src of an img tag.
- `duck_number` (number): The duck's number, which is how a duck is named on this site: duck 449 is the picture at https://random-d.uk/api/v2/449.jpg, and it stays that duck for good. Keep it to fetch the same duck again later. Null for a duck that has no number: the HTTP status code ducks are filed under their code instead, and a random draw that came back with an address carrying no number leaves it empty.
- `filename` (text): A file name for this duck, safe to write anywhere, such as random-d-uk-449.jpg. It is what the download step names the file.
- `image_tag` (text): The picture as a ready-made HTML img tag with alt text, for a step that writes an email body or a web page.
- `image_url` (text): The picture itself, ready to use as an img src, in a Markdown image or in most chat apps' unfurls. Always https, including where the site answered with a plain http address of its own.
- `markdown` (text): The picture as a ready-made Markdown image, for a README, an issue or a chat app that renders Markdown.
- `type` (text): Which kind of picture this is, jpg or gif. The photos and the GIFs are numbered separately, so duck 46 the photo and duck 46 the GIF are two different ducks.
- `was_random` (true/false): True when no duck was named and one was drawn at random. Branch on this rather than on whether the field was filled in.

**Example output**

```json
{
  "attribution": "Powered by random-d.uk",
  "byte_size": 6680,
  "content_type": "image/jpeg",
  "data_uri": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYn",
  "duck_number": 449,
  "filename": "random-d-uk-449.jpg",
  "image_tag": "<img src=\"https://random-d.uk/api/v2/449.jpg\" alt=\"Duck photo number 449 from Random-d.uk\" />",
  "image_url": "https://random-d.uk/api/v2/449.jpg",
  "markdown": "![Duck photo number 449 from Random-d.uk](https://random-d.uk/api/v2/449.jpg)",
  "type": "jpg",
  "was_random": true
}
```

### Get a duck by number

Get one particular duck by its number, the number in its filename: 449 is the duck at https://random-d.uk/api/v2/449.jpg. This is the way back to a duck that has already been seen, because a draw is random and cannot be asked for a particular duck: keep the duck number a step reported and this fetches the same duck for good. Nothing is fetched unless the check is turned on, which confirms the picture is really there without downloading it.

**Inputs**

- Duck number (`duck_number`, number, required): Which duck to get, by the number in its filename: 449 is the duck at https://random-d.uk/api/v2/449.jpg. Wire in the duck number an earlier step reported to come back to the same duck. At least 1.
- Kind of picture (`type`, text): Optional, photo by default. The photos and the GIFs are numbered separately, so duck 46 the photo and duck 46 the GIF are two different ducks. There are 57 GIFs, so a GIF number is a much smaller number than a photo number. One of: `jpg` (Photo (JPG)), `gif` (Animated (GIF)). Default: `jpg`.
- Check the picture is there (`verify`, true/false): Optional, off by default. Confirm the picture exists, which costs one request but does not download the file. Worth turning on for a number that came from outside the workflow, since a number above the site's current duck count has no picture. The step still succeeds either way and reports what it found. Default: `false`.

**Outputs**

- `attribution` (text): The credit the site asks to be shown with its pictures, normally 'Powered by random-d.uk'. On a random draw it is the site's own wording, taken from the answer itself.
- `byte_size` (number): The picture's size in bytes, when it was checked and found. Null otherwise.
- `content_type` (text): The picture's media type, image/jpeg or image/gif.
- `duck_number` (number): The duck's number, which is how a duck is named on this site: duck 449 is the picture at https://random-d.uk/api/v2/449.jpg, and it stays that duck for good. Keep it to fetch the same duck again later. Null for a duck that has no number: the HTTP status code ducks are filed under their code instead, and a random draw that came back with an address carrying no number leaves it empty.
- `exists` (true/false): Whether the picture is there. Null when it was not checked, so test for true rather than for not false.
- `filename` (text): A file name for this duck, safe to write anywhere, such as random-d-uk-449.jpg. It is what the download step names the file.
- `image_tag` (text): The picture as a ready-made HTML img tag with alt text, for a step that writes an email body or a web page.
- `image_url` (text): The picture itself, ready to use as an img src, in a Markdown image or in most chat apps' unfurls. Always https, including where the site answered with a plain http address of its own.
- `markdown` (text): The picture as a ready-made Markdown image, for a README, an issue or a chat app that renders Markdown.
- `type` (text): Which kind of picture this is, jpg or gif. The photos and the GIFs are numbered separately, so duck 46 the photo and duck 46 the GIF are two different ducks.
- `verified` (true/false): True when the picture was checked to confirm it is there.

**Example output**

```json
{
  "attribution": "Powered by random-d.uk",
  "byte_size": 313205,
  "content_type": "image/jpeg",
  "duck_number": 449,
  "exists": true,
  "filename": "random-d-uk-449.jpg",
  "image_tag": "<img src=\"https://random-d.uk/api/v2/449.jpg\" alt=\"Duck photo number 449 from Random-d.uk\" />",
  "image_url": "https://random-d.uk/api/v2/449.jpg",
  "markdown": "![Duck photo number 449 from Random-d.uk](https://random-d.uk/api/v2/449.jpg)",
  "type": "jpg",
  "verified": true
}
```

### Get a random duck

Get one duck at random from Random-d.uk: the picture's address, ready-made HTML and Markdown snippets, and the credit the site asks to be shown with it. Nothing is downloaded, so this is the cheap way to put a duck in a Slack message, a stand-up post or an email. The result carries the duck's number, so a later run can come back to the very same duck.

**Inputs**

- Kind of picture (`type`, text): Optional. Which kind of picture to draw. Leave it on anything and the site picks from everything it has, which is nearly always a photo because it holds 559 of those to 57 GIFs. Choose GIF for an animation, which is a few megabytes rather than a few hundred kilobytes. One of: `any` (Anything the site sends), `jpg` (Photo (JPG)), `gif` (Animated (GIF)). Default: `any`.

**Outputs**

- `attribution` (text): The credit the site asks to be shown with its pictures, normally 'Powered by random-d.uk'. On a random draw it is the site's own wording, taken from the answer itself.
- `content_type` (text): The picture's media type, image/jpeg or image/gif.
- `duck_number` (number): The duck's number, which is how a duck is named on this site: duck 449 is the picture at https://random-d.uk/api/v2/449.jpg, and it stays that duck for good. Keep it to fetch the same duck again later. Null for a duck that has no number: the HTTP status code ducks are filed under their code instead, and a random draw that came back with an address carrying no number leaves it empty.
- `filename` (text): A file name for this duck, safe to write anywhere, such as random-d-uk-449.jpg. It is what the download step names the file.
- `image_tag` (text): The picture as a ready-made HTML img tag with alt text, for a step that writes an email body or a web page.
- `image_url` (text): The picture itself, ready to use as an img src, in a Markdown image or in most chat apps' unfurls. Always https, including where the site answered with a plain http address of its own.
- `markdown` (text): The picture as a ready-made Markdown image, for a README, an issue or a chat app that renders Markdown.
- `requested_type` (text): What the draw asked the site for: jpg, gif, or any for the mixed pool.
- `source_url` (text): The address exactly as the site spelled it, which is a plain http one. It is kept here because image_url is the same address over https: the plain one redirects, but a browser blocks it as mixed content on an https page before the redirect is followed. Use image_url unless you specifically want what the site said.
- `type` (text): Which kind of picture this is, jpg or gif. The photos and the GIFs are numbered separately, so duck 46 the photo and duck 46 the GIF are two different ducks.

**Example output**

```json
{
  "attribution": "Powered by random-d.uk",
  "content_type": "image/jpeg",
  "duck_number": 449,
  "filename": "random-d-uk-449.jpg",
  "image_tag": "<img src=\"https://random-d.uk/api/v2/449.jpg\" alt=\"Duck photo number 449 from Random-d.uk\" />",
  "image_url": "https://random-d.uk/api/v2/449.jpg",
  "markdown": "![Duck photo number 449 from Random-d.uk](https://random-d.uk/api/v2/449.jpg)",
  "requested_type": "any",
  "source_url": "http://random-d.uk/api/449.JPG",
  "type": "jpg"
}
```

### Get several random ducks

Get a handful of ducks at random in one step, for a gallery, a digest or a set of avatars. The site draws with replacement, so three draws can be the same duck three times; by default the draws are repeated until the ducks are all different, and the step reports how many requests that took. Asking for more ducks than the site has comes back short rather than looping, with complete set to false.

**Inputs**

- Number of ducks (`count`, number): Optional. How many ducks to fetch, from 1 to 20. Defaults to 3. Each duck is its own request, and the site allows ten a second, so keep it modest. From 1 to 20. Default: `3`.
- No repeats (`unique`, true/false): Optional, on by default. The site draws with replacement, so three draws can be the same duck three times. On, draws are repeated until the ducks are all different, which is what a gallery wants. Off, every draw is kept as it comes, which is exactly one request per duck. Default: `true`.
- Kind of picture (`type`, text): Optional. Which kind of picture to draw. Leave it on anything and the site picks from everything it has, which is nearly always a photo because it holds 559 of those to 57 GIFs. Choose GIF for an animation, which is a few megabytes rather than a few hundred kilobytes. One of: `any` (Anything the site sends), `jpg` (Photo (JPG)), `gif` (Animated (GIF)). Default: `any`.

**Outputs**

- `complete` (true/false): True when as many ducks came back as were asked for. False means the site ran out of distinct ducks to give.
- `count` (number): How many ducks came back.
- `ducks` (list): The ducks, in the order they were drawn.
- `requested_count` (number): How many ducks were asked for.
- `requested_type` (text): What the draw asked the site for: jpg, gif, or any for the mixed pool.
- `requests_made` (number): How many draws it took, which is more than the number of ducks whenever a repeat came up.
- `unique` (true/false): True when repeats were drawn again rather than kept.

**Example output**

```json
{
  "complete": true,
  "count": 3,
  "ducks": [
    {
      "attribution": "Powered by random-d.uk",
      "content_type": "image/jpeg",
      "duck_number": 449,
      "filename": "random-d-uk-449.jpg",
      "image_tag": "<img src=\"https://random-d.uk/api/v2/449.jpg\" alt=\"Duck photo number 449 from Random-d.uk\" />",
      "image_url": "https://random-d.uk/api/v2/449.jpg",
      "markdown": "![Duck photo number 449 from Random-d.uk](https://random-d.uk/api/v2/449.jpg)",
      "type": "jpg"
    },
    {
      "attribution": "Powered by random-d.uk",
      "content_type": "image/jpeg",
      "duck_number": 12,
      "filename": "random-d-uk-12.jpg",
      "image_tag": "<img src=\"https://random-d.uk/api/v2/12.jpg\" alt=\"Duck photo number 12 from Random-d.uk\" />",
      "image_url": "https://random-d.uk/api/v2/12.jpg",
      "markdown": "![Duck photo number 12 from Random-d.uk](https://random-d.uk/api/v2/12.jpg)",
      "type": "jpg"
    },
    {
      "attribution": "Powered by random-d.uk",
      "content_type": "image/jpeg",
      "duck_number": 301,
      "filename": "random-d-uk-301.jpg",
      "image_tag": "<img src=\"https://random-d.uk/api/v2/301.jpg\" alt=\"Duck photo number 301 from Random-d.uk\" />",
      "image_url": "https://random-d.uk/api/v2/301.jpg",
      "markdown": "![Duck photo number 301 from Random-d.uk](https://random-d.uk/api/v2/301.jpg)",
      "type": "jpg"
    }
  ],
  "requested_count": 3,
  "requested_type": "any",
  "requests_made": 4,
  "unique": true
}
```

### Get the duck for an HTTP status code

Get the duck that stands for an HTTP status code: a duck that is 404 Not Found, a duck that is 418 I'm a teapot. Wire in the status an earlier HTTP step came back with to illustrate an alert, a status page or a failure notice. The site has ducks for fifteen codes and the step reads the live list rather than a copy, so a code added later works the day it is added. A code it has no duck for is refused with the nearest ones named, or falls back to the generic duck for that class when you ask it to.

**Inputs**

- HTTP status code (`status_code`, number, required): Which status code to get the duck for, such as 404. Wire in the status an earlier HTTP step came back with. The site has ducks for fifteen codes; a code it has none for is refused unless the fallback below is turned on. Use 'List the ducks' with HTTP status codes to see which ones it has. From 100 to 599.
- Use the class's duck instead (`fallback_to_class`, true/false): Optional, off by default. When the site has no duck for the exact code, use the generic one for its class: 400 for any client error, 500 for any server error, 301 for any redirect. Turn this on when the code comes from a live HTTP step and the workflow must not fail on a code the site never got round to. The result says whether it fell back and which code it was asked for. Default: `false`.
- Check the picture is there (`verify`, true/false): Optional, off by default. Confirm the picture exists, which costs one request but does not download the file. Worth turning on for a number that came from outside the workflow, since a number above the site's current duck count has no picture. The step still succeeds either way and reports what it found. Default: `false`.

**Outputs**

- `attribution` (text): The credit the site asks to be shown with its pictures, normally 'Powered by random-d.uk'. On a random draw it is the site's own wording, taken from the answer itself.
- `byte_size` (number): The picture's size in bytes, when it was checked and found. Null otherwise.
- `class_name` (text): What that class is called, such as 'Client error'.
- `content_type` (text): The picture's media type, image/jpeg or image/gif.
- `duck_number` (number): The duck's number, which is how a duck is named on this site: duck 449 is the picture at https://random-d.uk/api/v2/449.jpg, and it stays that duck for good. Keep it to fetch the same duck again later. Null for a duck that has no number: the HTTP status code ducks are filed under their code instead, and a random draw that came back with an address carrying no number leaves it empty.
- `exists` (true/false): Whether the picture is there. Null when it was not checked, so test for true rather than for not false.
- `fell_back` (true/false): True when the site had no duck for the exact code and the class's generic duck was used instead. Report this where it matters, since the picture then names a different code than the one that happened.
- `filename` (text): A file name for this duck, safe to write anywhere, such as random-d-uk-449.jpg. It is what the download step names the file.
- `image_tag` (text): The picture as a ready-made HTML img tag with alt text, for a step that writes an email body or a web page.
- `image_url` (text): The picture itself, ready to use as an img src, in a Markdown image or in most chat apps' unfurls. Always https, including where the site answered with a plain http address of its own.
- `markdown` (text): The picture as a ready-made Markdown image, for a README, an issue or a chat app that renders Markdown.
- `requested_code` (number): The code the step was asked for.
- `status_class` (text): The class the requested code belongs to, such as 4xx.
- `status_code` (number): The code this duck actually stands for. It differs from requested_code only when the step fell back.
- `type` (text): Which kind of picture this is, jpg or gif. The photos and the GIFs are numbered separately, so duck 46 the photo and duck 46 the GIF are two different ducks.
- `verified` (true/false): True when the picture was checked to confirm it is there.

**Example output**

```json
{
  "attribution": "Powered by random-d.uk",
  "byte_size": 212522,
  "class_name": "Client error",
  "content_type": "image/jpeg",
  "duck_number": null,
  "exists": true,
  "fell_back": false,
  "filename": "random-d-uk-http-404.jpg",
  "image_tag": "<img src=\"https://random-d.uk/api/v2/http/404\" alt=\"A duck for HTTP 404, from Random-d.uk\" />",
  "image_url": "https://random-d.uk/api/v2/http/404",
  "markdown": "![A duck for HTTP 404, from Random-d.uk](https://random-d.uk/api/v2/http/404)",
  "requested_code": 404,
  "status_class": "4xx",
  "status_code": 404,
  "type": "jpg",
  "verified": true
}
```

### Get the duck of the day

Pick a duck from a seed, so the same seed always picks the same duck. Seed with the date, which is the default, and a daily post that retries, or that two people run an hour apart, shows the same duck, while tomorrow shows a different one. Seed with a channel or a customer name instead and each one gets its own duck. The pick is over however many ducks the site has, so give a duck count to pin it: the collection grows, and a bigger collection means a different duck for the same seed.

**Inputs**

- Seed (`seed`, text): Optional. Any text you like. The same seed always picks the same duck, so a channel name gives each channel its own duck and a date gives a duck of the day. Leave empty for today's date in UTC.
- Duck count (`duck_count`, number): Optional. How many ducks to pick from. Leave empty to use however many the site has right now, which costs one request. Wire in the duck count a 'Count the ducks' step reported, or write down a number, to pin the pick: the collection grows, and a pick over a bigger collection is a different duck for the same seed. At least 1.
- Kind of picture (`type`, text): Optional, photo by default. The photos and the GIFs are numbered separately, so duck 46 the photo and duck 46 the GIF are two different ducks. There are 57 GIFs, so a GIF number is a much smaller number than a photo number. One of: `jpg` (Photo (JPG)), `gif` (Animated (GIF)). Default: `jpg`.

**Outputs**

- `attribution` (text): The credit the site asks to be shown with its pictures, normally 'Powered by random-d.uk'. On a random draw it is the site's own wording, taken from the answer itself.
- `content_type` (text): The picture's media type, image/jpeg or image/gif.
- `duck_number` (number): The duck's number, which is how a duck is named on this site: duck 449 is the picture at https://random-d.uk/api/v2/449.jpg, and it stays that duck for good. Keep it to fetch the same duck again later. Null for a duck that has no number: the HTTP status code ducks are filed under their code instead, and a random draw that came back with an address carrying no number leaves it empty.
- `filename` (text): A file name for this duck, safe to write anywhere, such as random-d-uk-449.jpg. It is what the download step names the file.
- `image_tag` (text): The picture as a ready-made HTML img tag with alt text, for a step that writes an email body or a web page.
- `image_url` (text): The picture itself, ready to use as an img src, in a Markdown image or in most chat apps' unfurls. Always https, including where the site answered with a plain http address of its own.
- `markdown` (text): The picture as a ready-made Markdown image, for a README, an issue or a chat app that renders Markdown.
- `pool_counted` (true/false): True when the pool was the site's live duck count, false when it was the count given to the step.
- `pool_size` (number): How many ducks the pick was made from. When the step counted for itself this is the number of distinct pictures, not the site's own file count, which runs higher and would pick numbers no duck has.
- `seed` (text): The seed the pick was made with, which is today's date in UTC when none was given.
- `type` (text): Which kind of picture this is, jpg or gif. The photos and the GIFs are numbered separately, so duck 46 the photo and duck 46 the GIF are two different ducks.

**Example output**

```json
{
  "attribution": "Powered by random-d.uk",
  "content_type": "image/jpeg",
  "duck_number": 176,
  "filename": "random-d-uk-176.jpg",
  "image_tag": "<img src=\"https://random-d.uk/api/v2/176.jpg\" alt=\"Duck photo number 176 from Random-d.uk\" />",
  "image_url": "https://random-d.uk/api/v2/176.jpg",
  "markdown": "![Duck photo number 176 from Random-d.uk](https://random-d.uk/api/v2/176.jpg)",
  "pool_counted": false,
  "pool_size": 559,
  "seed": "2026-09-18",
  "type": "jpg"
}
```

### List the ducks

Page through what the site holds: the photos, the GIFs, or the HTTP status codes that have a duck. Listing the status codes is the only way to find out which ones the site covers, and there are only fifteen, so that one fits in a single page. The photos run to several hundred, which is why this pages rather than handing back the lot. Each entry comes back as a full duck with its address and snippets, alongside a plain list of the numbers for wiring into a later step.

**Inputs**

- Which collection (`collection`, text): Optional, photos by default. The site keeps three collections and numbers them separately: the photos, the GIFs, and one duck per HTTP status code. The HTTP one is the collection worth listing whole, because it is the only way to find out which codes have a duck. One of: `photos` (Photos (JPG)), `gifs` (Animations (GIF)), `http` (HTTP status codes). Default: `photos`.
- How many to return (`limit`, number): Optional. How many entries this page carries, from 1 to 100. Defaults to 20. The site hands back its whole inventory in one answer, several hundred entries of it, which is more than a workflow wants in a value. From 1 to 100. Default: `20`.
- Start after (`offset`, number): Optional, 0 by default. How many entries to skip before this page. Add the limit to it each run to walk the whole collection; has_more says when there is nothing left. At least 0. Default: `0`.

**Outputs**

- `collection` (text): Which collection was listed: photos, gifs or http.
- `ducks` (list): The same entries as full ducks. A status code duck has no duck number, since it is filed under its code rather than in the numbered collection.
- `has_more` (true/false): True when there are entries after this page. Add the limit to the offset and run again.
- `numbers` (list): The numbers on this page, in order: duck numbers for the photos and the GIFs, status codes for the HTTP ducks.
- `offset` (number): How many entries were skipped.
- `returned` (number): How many entries this page carries.
- `total` (number): How many entries the whole collection holds, not just this page.

**Example output**

```json
{
  "collection": "http",
  "ducks": [
    {
      "attribution": "Powered by random-d.uk",
      "content_type": "image/jpeg",
      "duck_number": null,
      "filename": "random-d-uk-http-100.jpg",
      "image_tag": "<img src=\"https://random-d.uk/api/v2/http/100\" alt=\"A duck for HTTP 100, from Random-d.uk\" />",
      "image_url": "https://random-d.uk/api/v2/http/100",
      "markdown": "![A duck for HTTP 100, from Random-d.uk](https://random-d.uk/api/v2/http/100)",
      "type": "jpg"
    },
    {
      "attribution": "Powered by random-d.uk",
      "content_type": "image/jpeg",
      "duck_number": null,
      "filename": "random-d-uk-http-200.jpg",
      "image_tag": "<img src=\"https://random-d.uk/api/v2/http/200\" alt=\"A duck for HTTP 200, from Random-d.uk\" />",
      "image_url": "https://random-d.uk/api/v2/http/200",
      "markdown": "![A duck for HTTP 200, from Random-d.uk](https://random-d.uk/api/v2/http/200)",
      "type": "jpg"
    },
    {
      "attribution": "Powered by random-d.uk",
      "content_type": "image/jpeg",
      "duck_number": null,
      "filename": "random-d-uk-http-301.jpg",
      "image_tag": "<img src=\"https://random-d.uk/api/v2/http/301\" alt=\"A duck for HTTP 301, from Random-d.uk\" />",
      "image_url": "https://random-d.uk/api/v2/http/301",
      "markdown": "![A duck for HTTP 301, from Random-d.uk](https://random-d.uk/api/v2/http/301)",
      "type": "jpg"
    },
    {
      "attribution": "Powered by random-d.uk",
      "content_type": "image/jpeg",
      "duck_number": null,
      "filename": "random-d-uk-http-302.jpg",
      "image_tag": "<img src=\"https://random-d.uk/api/v2/http/302\" alt=\"A duck for HTTP 302, from Random-d.uk\" />",
      "image_url": "https://random-d.uk/api/v2/http/302",
      "markdown": "![A duck for HTTP 302, from Random-d.uk](https://random-d.uk/api/v2/http/302)",
      "type": "jpg"
    },
    {
      "attribution": "Powered by random-d.uk",
      "content_type": "image/jpeg",
      "duck_number": null,
      "filename": "random-d-uk-http-400.jpg",
      "image_tag": "<img src=\"https://random-d.uk/api/v2/http/400\" alt=\"A duck for HTTP 400, from Random-d.uk\" />",
      "image_url": "https://random-d.uk/api/v2/http/400",
      "markdown": "![A duck for HTTP 400, from Random-d.uk](https://random-d.uk/api/v2/http/400)",
      "type": "jpg"
    },
    {
      "attribution": "Powered by random-d.uk",
      "content_type": "image/jpeg",
      "duck_number": null,
      "filename": "random-d-uk-http-403.jpg",
      "image_tag": "<img src=\"https://random-d.uk/api/v2/http/403\" alt=\"A duck for HTTP 403, from Random-d.uk\" />",
      "image_url": "https://random-d.uk/api/v2/http/403",
      "markdown": "![A duck for HTTP 403, from Random-d.uk](https://random-d.uk/api/v2/http/403)",
      "type": "jpg"
    },
    {
      "attribution": "Powered by random-d.uk",
      "content_type": "image/jpeg",
      "duck_number": null,
      "filename": "random-d-uk-http-404.jpg",
      "image_tag": "<img src=\"https://random-d.uk/api/v2/http/404\" alt=\"A duck for HTTP 404, from Random-d.uk\" />",
      "image_url": "https://random-d.uk/api/v2/http/404",
      "markdown": "![A duck for HTTP 404, from Random-d.uk](https://random-d.uk/api/v2/http/404)",
      "type": "jpg"
    },
    {
      "attribution": "Powered by random-d.uk",
      "content_type": "image/jpeg",
      "duck_number": null,
      "filename": "random-d-uk-http-409.jpg",
      "image_tag": "<img src=\"https://random-d.uk/api/v2/http/409\" alt=\"A duck for HTTP 409, from Random-d.uk\" />",
      "image_url": "https://random-d.uk/api/v2/http/409",
      "markdown": "![A duck for HTTP 409, from Random-d.uk](https://random-d.uk/api/v2/http/409)",
      "type": "jpg"
    },
    {
      "attribution": "Powered by random-d.uk",
      "content_type": "image/jpeg",
      "duck_number": null,
      "filename": "random-d-uk-http-413.jpg",
      "image_tag": "<img src=\"https://random-d.uk/api/v2/http/413\" alt=\"A duck for HTTP 413, from Random-d.uk\" />",
      "image_url": "https://random-d.uk/api/v2/http/413",
      "markdown": "![A duck for HTTP 413, from Random-d.uk](https://random-d.uk/api/v2/http/413)",
      "type": "jpg"
    },
    {
      "attribution": "Powered by random-d.uk",
      "content_type": "image/jpeg",
      "duck_number": null,
      "filename": "random-d-uk-http-418.jpg",
      "image_tag": "<img src=\"https://random-d.uk/api/v2/http/418\" alt=\"A duck for HTTP 418, from Random-d.uk\" />",
      "image_url": "https://random-d.uk/api/v2/http/418",
      "markdown": "![A duck for HTTP 418, from Random-d.uk](https://random-d.uk/api/v2/http/418)",
      "type": "jpg"
    },
    {
      "attribution": "Powered by random-d.uk",
      "content_type": "image/jpeg",
      "duck_number": null,
      "filename": "random-d-uk-http-420.jpg",
      "image_tag": "<img src=\"https://random-d.uk/api/v2/http/420\" alt=\"A duck for HTTP 420, from Random-d.uk\" />",
      "image_url": "https://random-d.uk/api/v2/http/420",
      "markdown": "![A duck for HTTP 420, from Random-d.uk](https://random-d.uk/api/v2/http/420)",
      "type": "jpg"
    },
    {
      "attribution": "Powered by random-d.uk",
      "content_type": "image/jpeg",
      "duck_number": null,
      "filename": "random-d-uk-http-426.jpg",
      "image_tag": "<img src=\"https://random-d.uk/api/v2/http/426\" alt=\"A duck for HTTP 426, from Random-d.uk\" />",
      "image_url": "https://random-d.uk/api/v2/http/426",
      "markdown": "![A duck for HTTP 426, from Random-d.uk](https://random-d.uk/api/v2/http/426)",
      "type": "jpg"
    },
    {
      "attribution": "Powered by random-d.uk",
      "content_type": "image/jpeg",
      "duck_number": null,
      "filename": "random-d-uk-http-429.jpg",
      "image_tag": "<img src=\"https://random-d.uk/api/v2/http/429\" alt=\"A duck for HTTP 429, from Random-d.uk\" />",
      "image_url": "https://random-d.uk/api/v2/http/429",
      "markdown": "![A duck for HTTP 429, from Random-d.uk](https://random-d.uk/api/v2/http/429)",
      "type": "jpg"
    },
    {
      "attribution": "Powered by random-d.uk",
      "content_type": "image/jpeg",
      "duck_number": null,
      "filename": "random-d-uk-http-451.jpg",
      "image_tag": "<img src=\"https://random-d.uk/api/v2/http/451\" alt=\"A duck for HTTP 451, from Random-d.uk\" />",
      "image_url": "https://random-d.uk/api/v2/http/451",
      "markdown": "![A duck for HTTP 451, from Random-d.uk](https://random-d.uk/api/v2/http/451)",
      "type": "jpg"
    },
    {
      "attribution": "Powered by random-d.uk",
      "content_type": "image/jpeg",
      "duck_number": null,
      "filename": "random-d-uk-http-500.jpg",
      "image_tag": "<img src=\"https://random-d.uk/api/v2/http/500\" alt=\"A duck for HTTP 500, from Random-d.uk\" />",
      "image_url": "https://random-d.uk/api/v2/http/500",
      "markdown": "![A duck for HTTP 500, from Random-d.uk](https://random-d.uk/api/v2/http/500)",
      "type": "jpg"
    }
  ],
  "has_more": false,
  "numbers": [
    100,
    200,
    301,
    302,
    400,
    403,
    404,
    409,
    413,
    418,
    420,
    426,
    429,
    451,
    500
  ],
  "offset": 0,
  "returned": 15,
  "total": 15
}
```
