CMS360 SDK Documentation (JS)
Report a bug/issue 🪲
Prerequisite: Your API Key (16 digits alphanumeric). Head over to our website to create yours for free!
Installation
Import
```
const {ClientSDK} = require("@pyvot360/cms");
// import {ClientSDK} from "@pyvot360/cms";
const sdk = new ClientSDK('YOUR-API-KEY');
```
Methods
sdk.getAll()
(async) Fetches all articlessdk.getById(articleId: string)
(async) Fetches one article by idsdk.getByUrl(articleUrl: string)
(async) Fetches one article by url stringsdk.getTopics()
(async) Fetches all topicssdk.search(filters: ArticleFilters)
* (async) Fetches articles related to search filterssdk.viewed(articleId: string)
(async) Updates the view count of an article
Note: All methods are async (return a promise). You may choose to handle that using await
or .then()
Types & Interfaces
export declare interface Article {
id?: string;
title: string;
author: Partial<Author>;
banner: string;
content: string;
tags: string[];
stats?: ArticleStats;
dateWritten?: number;
dateEditted?: number;
isPublished: boolean;
_secondaryKey?: string;
url?: string;
}
export declare interface ArticleStats {
views: number;
}
export declare interface Author {
name?: string;
bio?: string;
email?: string;
avatar?: string;
}
export declare interface ArticleFilters {
title?: string;
tag?: string;
author?: string;
}
export declare class ClientSDK {
constructor(key: string);
getAll(): Promise<Article[]>;
getById(articleId: string): Promise<Article | undefined>;
getByUrl(articleUrl: string): Promise<Article | undefined>;
getTopics(): Promise<string[]>;
search(filters: ArticleFilters): Promise<Article[]>;
viewed(articleId: string);
}