# `album.getPublicImage`

<span class="badge">public</span>

**Get a visitor photo within a published album**

Returns the full description and adjacent visible photo IDs. Authentication never changes the visitor view.

## Parameters

Passed by name in the `params` object.

| Name | Type | Required | Description |
|---|---|---|---|
| `alias` | string | no | Album alias (public albums only) |
| `id` | string | no | Album UUID (public albums only) |
| `token` | string | no | Share-link token |
| `photo_id` | string | yes | Photo UUID within this album |

## Result

Returns `AlbumImage`:

| Field | Type | Description |
|---|---|---|
| `image *` | `Image` |  |
| `next_id *` | string |  |
| `prev_id *` | string |  |
| `total *` | integer |  |

## Errors

| Code | Message | When |
|---|---|---|
| `2001` | `not_found` | No such resource owned by the caller. |
| `2002` | `validation_failed` | Malformed request; see error.data. |
| `4002` | `rate_limited` | Too many requests; wait before retrying. |

See the [error reference](/docs/errors) for the full catalog, including the authentication codes.

## Example

Request:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "album.getPublicImage",
  "params": {
    "token": "abcdefghijklmnopqrstuv",
    "photo_id": "018f3a7d-2b8c-7f1a-a4d5-6e7f8a9b0c1d"
  }
}
```

Response:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "image": {
      "id": "018f3a7d-2b8c-7f1a-a4d5-6e7f8a9b0c1d",
      "index": 1,
      "title": "Mountain pass",
      "description": "",
      "alt": "Mountain pass",
      "width": 640,
      "height": 480,
      "renders": [
        {
          "url": "https://img.example.com/r/018f3a7d-2b8c-7f1a-a4d5-6e7f8a9b0c1d/medium.webp?v=1",
          "format": "webp",
          "width": 640,
          "height": 480
        }
      ]
    },
    "total": 1,
    "prev_id": "",
    "next_id": ""
  }
}
```

**curl**

```bash
curl -s https://peinture.gumeniuk.com/rpc \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"album.getPublicImage","params":{"token":"abcdefghijklmnopqrstuv","photo_id":"018f3a7d-2b8c-7f1a-a4d5-6e7f8a9b0c1d"}}'
```

**JavaScript**

```js
const res = await fetch("https://peinture.gumeniuk.com/rpc", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    jsonrpc: "2.0", id: 1, method: "album.getPublicImage", params: {"token":"abcdefghijklmnopqrstuv","photo_id":"018f3a7d-2b8c-7f1a-a4d5-6e7f8a9b0c1d"},
  }),
});
const { result, error } = await res.json();
```

**Go**

```go
body := []byte(`{"jsonrpc":"2.0","id":1,"method":"album.getPublicImage","params":{"token":"abcdefghijklmnopqrstuv","photo_id":"018f3a7d-2b8c-7f1a-a4d5-6e7f8a9b0c1d"}}`)
req, _ := http.NewRequest("POST", "https://peinture.gumeniuk.com/rpc", bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
```

