# `album.preview`

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

**Preview an owned album as a visitor**

Returns safe preview HTML and its stylesheet in every publication state. after requests the next grid fragment.

## Parameters

Passed by name in the `params` object.

| Name | Type | Required | Description |
|---|---|---|---|
| `album_id` | string | yes |  |
| `after` | string | no |  |

## Result

Returns `albumPreviewResult`:

| Field | Type | Description |
|---|---|---|
| `html *` | string |  |
| `next_after *` | string |  |
| `og_image_url` | string |  |
| `stats *` | `sharingStatsDTO` |  |
| `stylesheet_url *` | string |  |
| `visitor_state *` | string |  |

## Errors

| Code | Message | When |
|---|---|---|
| `2001` | `not_found` | No such resource owned by the caller. |
| `2002` | `validation_failed` | Malformed request; see error.data. |
| `2003` | `cursor_stale` | The cursor photo is no longer visible; restart pagination. |

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

## Example

Request:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "album.preview",
  "params": {
    "album_id": "018f3a80-1c2d-7e00-9a00-0b1c2d3e4f50"
  }
}
```

Response:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "html": "\u003cfigure\u003ePhoto preview\u003c/figure\u003e",
    "stylesheet_url": "/_p/public.example.css",
    "visitor_state": "private",
    "stats": {
      "visible": 0,
      "total": 0,
      "breakdown": {
        "processing": 0,
        "failed": 0,
        "too_small": 0,
        "taken_down": 0
      },
      "exif": {
        "location": {
          "visible": 0,
          "disabled_on_photo": 0
        },
        "date": {
          "visible": 0,
          "disabled_on_photo": 0
        },
        "camera": {
          "visible": 0,
          "disabled_on_photo": 0
        }
      },
      "captioned": 0,
      "exposing_location": 0
    },
    "next_after": ""
  }
}
```

**curl**

```bash
curl -s https://peinture.gumeniuk.com/rpc \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"album.preview","params":{"album_id":"018f3a80-1c2d-7e00-9a00-0b1c2d3e4f50"}}'
```

**JavaScript**

```js
const res = await fetch("https://peinture.gumeniuk.com/rpc", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": `Bearer ${token}`,
  },
  body: JSON.stringify({
    jsonrpc: "2.0", id: 1, method: "album.preview", params: {"album_id":"018f3a80-1c2d-7e00-9a00-0b1c2d3e4f50"},
  }),
});
const { result, error } = await res.json();
```

**Go**

```go
body := []byte(`{"jsonrpc":"2.0","id":1,"method":"album.preview","params":{"album_id":"018f3a80-1c2d-7e00-9a00-0b1c2d3e4f50"}}`)
req, _ := http.NewRequest("POST", "https://peinture.gumeniuk.com/rpc", bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+token)
resp, err := http.DefaultClient.Do(req)
```

