> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# ViewPost

# Package: blog

# Namespace: PostService

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/blog/posts-stats/view-post.md

## Permission Scopes:
Read Blog : SCOPE.DC-BLOG.READ-BLOGS

## Introduction

Increments a post's view count.

Call this method when a site visitor views a published post. The post must already be published. The response returns the post's updated total number of views.

This method accepts up to 100 calls per minute from an IP address on the site, and up to 100 calls per minute from an IP address for a single post. Further calls are rejected.

---

## REST API

### Schema

```
 Method: viewPost
 Description: Increments a post's view count.  Call this method when a site visitor views a published post. The post must already be published. The response returns the post's updated total number of views.  This method accepts up to 100 calls per minute from an IP address on the site, and up to 100 calls per minute from an IP address for a single post. Further calls are rejected.
 URL: https://www.wixapis.com/v3/posts/{postId}/view
 Method: POST
 Return type: ViewPostResponse
  - name: views | type: integer | description: Updated total number of views for the post.  


```

### Examples

### Increment a post's view count
```curl
curl -X POST \
  'https://www.wixapis.com/blog/v3/posts/894a58a2-dc75-422d-9ca6-00a489750dfd/view' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: <AUTH>'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.blog.posts.viewPost(postId)
 Description: Increments a post's view count.  Call this method when a site visitor views a published post. The post must already be published. The response returns the post's updated total number of views.  This method accepts up to 100 calls per minute from an IP address on the site, and up to 100 calls per minute from an IP address for a single post. Further calls are rejected.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  postId
 Method parameters: 
   param name: postId | type: string | description: Post GUID. | required: true | validation: minLength 1, maxLength 38
 Return type: PROMISE<ViewPostResponse>
  - name: views | type: integer | description: Updated total number of views for the post.  


```

### Examples

### Increment a post's view count
This example uses the `viewPost()` function to increment a published post's view count and return the updated total.

```javascript
import { posts } from '@wix/blog';

/* Sample postId value:
 * 'ccbb6257-ed0e-4521-97df-8b5b207adb00'
 */

export async function viewPostFunction(postId) {
  try {
    const result = await posts.viewPost(postId);
    const views = result.views;
    console.log('Retrieved Result:', result);
    return result;
  } catch (error) {
    console.log(error);
  }
}

/* Promise resolves to:
 * {
 *    "views": 32
 *  }
 */

```

### viewPost (self-hosted)
Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { posts } from '@wix/blog';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { posts },
  // Include the auth strategy and host as relevant
});


async function viewPost(postId) {
  const response = await myWixClient.posts.viewPost(postId);
};
```

---