> 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 # GetTotalPosts # Package: blog # Namespace: BlogStatsService # Method link: https://dev.wix.com/docs/api-reference/business-solutions/blog/posts-stats/get-total-posts.md ## Permission Scopes: Read Blog : SCOPE.DC-BLOG.READ-BLOGS ## Introduction Retrieves the total amount of published posts of the blog. --- ## REST API ### Schema ``` Method: getTotalPosts Description: Retrieves the total amount of published posts of the blog. URL: https://www.wixapis.com/blog/v2/stats/posts/total Method: GET Method parameters: query param name: language | type: language | description: Language filter. 2-or-4-letter language code in [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. Pass a language to receive the total amount of posts in that specified language. Return type: GetTotalPostsResponse - name: total | type: integer | description: Total amount of published posts. ``` ### Examples ### GetTotalPosts ```curl ~~~cURL curl 'www.wixapis.com/blog/v2/stats/posts/total' \ -H 'Content-Type: application/json' \ -H 'Authorization: ' ~~~ ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.blog.BlogStatsService.getTotalPosts(options) Description: Retrieves the total amount of published posts of the blog. Method parameters: param name: options | type: GetTotalPostsOptions none - name: language | type: string | description: Language filter. 2-or-4-letter language code in [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. Pass a language to receive the total amount of posts in that specified language. Return type: PROMISE - name: total | type: integer | description: Total amount of published posts. ``` ### Examples ### Get the total amount of posts in the blog ```javascript import { posts } from '@wix/blog'; export async function getTotalPostsFunction() { try { const result = await posts.getTotalPosts(); console.log('Retrieved Result:', result); return result; } catch (error) { console.log(error); } } /* Promise resolves to: * { * "total": 19 * } */ ``` ### Get total number of posts in a specified language ```javascript import { posts } from '@wix/blog'; /* Sample options value: * { * language: 'en' * } */ export async function getTotalPostsFunction(options) { try { const getTotalPostsResult = await posts.getTotalPosts(options); console.log('Success! Retrieved getTotalPostsResult:', getTotalPostsResult); return getTotalPostsResult; } catch (error) { console.log(error); } } /* Promise resolves to: * { * "total": 17 * } */ ``` ### getTotalPosts (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 getTotalPosts(options) { const response = await myWixClient.posts.getTotalPosts(options); }; ``` ---