NodeJS client for HelpScout Docs API written in TypeScript
$ npm install docscout
import { listCollections } from 'docscout/collections'
const apiToken = process.env.HELPSCOUT_DOCS_API_TOKEN;
(async () => {
try {
const collectionsEnvelope = await listCollections(apiToken, { visibility: 'private', sort: 'createdAt', order: 'asc' });
console.log(JSON.stringify(collectionsEnvelope, null, 2));
} catch (error) {
console.error(error);
}
})();
The OOP Client has two subtle differences from the functional approach:
- Stores the API token internally so that you don't have to pass it in every single function call.
- Unboxes the envelope data from the API responses. More info about HS Docs Data Envelopes
import DocscoutClient from 'docscout'
const apiToken = process.env.HELPSCOUT_DOCS_API_TOKEN;
(async () => {
try {
const docscoutClient = new DocscoutClient(apiToken);
const collections = await docscoutClient.listCollections({
visibility: 'private',
sort: 'createdAt',
order: 'desc'
});
console.log(JSON.stringify(collections, null, 2));
} catch (error) {
console.error(error);
}
})();
At this time the client if focused on fetching data, i.e. the API Reads.
We'll happily welcome your PRs to improve this client.
Articles | Source Code
List Articles | Docs
listArticlesInCollection( apiToken: string, collectionId: string, options?: ListArticleOptions )
listArticlesInCategory( apiToken: string, categoryId: string, options?: ListArticleOptions )
Search Articles | Docs
searchArticles( apiToken: string, options: SearchArticlesOptions )
List Related Articles | Docs
listRelatedArticles( apiToken: string, articleId: string, options?: ListRelatedArticlesOptions )
List Revisions | Docs
listRevisions( apiToken: string, articleId: string, options?: ListRevisionsOptions )
Get Article | Docs
getArticle( apiToken: string, articleIdOrNumber: string | number, options?: GetArticleOptions )
Get Revision | Docs
getRevision( apiToken: string, revisionId: string )
Assets | Source Code
Create Article Asset | Docs
createArticleAsset( apiToken: string, options: CreateArticleAssetOptions )
Categories | Source Code
List Categories | Docs
listCategories( apiToken: string, collectionId: string, options?: ListCategoriesOptions )
Get Category | Docs
getCategory( apiToken: string, categoryIdOrNumber: string | number )
Collections | Source Code
List Collections | Docs
listCollections( apiToken: string, options?: ListCollectionsOptions )
Get Collection | Docs
getCollection( apiToken: string, collectionIdOrNumber: string | number )
Sites | Source Code
List Sites | Docs
listSites( apiToken: string, options?: ListSitesOptions )
Copyright (c) 2019 You Need A Budget, LLC
Licensed under the Apache-2.0 license