helpscout-docs
HelpScout Docs API client for Node.js
Installation
$ npm install helpscout-docs
Usage
var HelpScoutDocs = require ( ' helpscout-docs ' ) ;
var apiKey = ' {your api key} ' ;
var hsdocs = new HelpScoutDocs ( apiKey ) ;
hsdocs . collections . getAll ( function ( err , result ) {
console . log ( result ) ;
} ) ;
All available methods are listed below
API Documentation
After module initialization:
var hsdocs = new HelpScoutDocs ( ' {your api key} ' ) ;
hsdocs
object has following methods to perform API calls:
Notice
All methods accept "error-first" callback function. In case of error, callback will be called with error message in first parameter, otherwise JSON result of API call will be passed as second parameter.
Some methods require data to pass. Provide object with data as first argument (see code examples).
Articles
hsdocs . articles . getAllByCollection ( { id : ' {collectionId} ' } , function ( err , result ) { } ) ;
hsdocs . articles . getAllByCategory ( { id : ' {categoryId} ' } , function ( err , result ) { } ) ;
hsdocs . articles . search ( {
fields : {
query : ' query string '
}
} , function ( err , result ) { } ) ;
hsdocs . articles . getRelated ( { id : ' {articleId} ' } , function ( err , result ) { } ) ;
hsdocs . articles . getRevisions ( { id : ' {articleId} ' } , function ( err , result ) { } ) ;
hsdocs . articles . get ( { id : ' {articleId or articleNumber} ' } , function ( err , result ) { } ) ;
hsdocs . articles . getRevision ( { id : ' {revisionId} ' } , function ( err , result ) { } ) ;
hsdocs . articles . create ( {
fields : {
collectionId : ' {collectionId} ' ,
name : ' article name ' ,
text : ' article text '
}
} , function ( err , result ) { } ) ;
hsdocs . articles . update ( {
id : ' {articleId} ' ,
fields : {
name : ' article name ' ,
text : ' article text '
}
} , function ( err , result ) { } ) ;
hsdocs . articles . upload ( {
fields : {
collectionId : ' {collectionId} ' ,
file : ' file data '
}
} , function ( err , result ) { } ) ;
hsdocs . articles . updateViewCount ( {
id : ' articleId ' ,
fields : {
count : 42
}
} , function ( err , result ) { } ) ;
hsdocs . articles . delete ( { id : ' {articleId} ' } , function ( err , result ) { } ) ;
hsdocs . articles . saveDraft ( {
id : ' articleId ' ,
fields : {
text : ' article text '
}
} , function ( err , result ) { } ) ;
hsdocs . articles . deleteDraft ( { id : ' {articleId} ' } , function ( err , result ) { } ) ;
Assets
hsdocs . assets . createArticleAsset ( {
fields : {
articleId : ' {articleId} ' ,
assetType : ' attachment ' ,
file : ' file data '
}
} , function ( err , result ) { } ) ;
hsdocs . assets . createSettingsAsset ( {
fields : {
assetType : ' favicon ' ,
file : ' file data '
}
} , function ( err , result ) { } ) ;
Categories
hsdocs . categories . getAllByCollection ( { id : ' {collectionId} ' } , function ( err , result ) { } ) ;
hsdocs . categories . get ( { id : ' {categoryId or categoryNumber} ' } , function ( err , result ) { } ) ;
hsdocs . categories . create ( {
fields : {
collectionId : ' {collectionId} ' ,
name : ' category name '
}
} , function ( err , result ) { } ) ;
hsdocs . categories . update ( {
id : ' {categoryId} ' ,
fields : {
name : ' category name '
}
} , function ( err , result ) { } ) ;
hsdocs . categories . updateOrder ( {
id : ' {collectionId} ' ,
fields : {
categories : [
{
id : ' {categoryId} ' ,
order : 1
} ,
{
id : ' {categoryId} ' ,
order : 2
} ,
}
}
} , function ( err , result ) { } ) ;
hsdocs . categories . delete ( { id : ' {categoryId} ' } , function ( err , result ) { } ) ;
Collections
hsdocs . collections . getAll ( function ( err , result ) { } ) ;
hsdocs . collections . get ( { id : ' {collectionId or collectionNumber} ' } , function ( err , result ) { } ) ;
hsdocs . collections . create ( {
fields : {
siteId : ' {siteId} ' ,
name : ' collection name '
}
} , function ( err , result ) { } ) ;
hsdocs . collections . update ( {
id : ' {collectionId} ' ,
fields : {
name : ' collection name '
}
} , function ( err , result ) { } ) ;
hsdocs . collections . delete ( { id : ' {collectionId} ' } , function ( err , result ) { } ) ;
Redirects
hsdocs . redirects . getAllBySite ( { id : ' {siteId} ' } , function ( err , result ) { } ) ;
hsdocs . redirects . get ( { id : ' {redirectId} ' } , function ( err , result ) { } ) ;
hsdocs . redirects . find ( {
fields : {
url : ' /some/path/123 ' ,
siteId : ' {siteId} '
}
} , function ( err , result ) { } ) ;
hsdocs . redirects . create ( {
fields : {
siteId : ' {siteId} ' ,
urlMapping : ' /some/path/123 ' ,
redirect : ' http://redirect.to/ '
}
} , function ( err , result ) { } ) ;
hsdocs . redirects . update ( {
id : ' {redirectId} ' ,
fields : {
siteId : ' {siteId} ' ,
urlMapping : ' /some/path/123 ' ,
redirect : ' http://redirect.to/ '
}
} , function ( err , result ) { } ) ;
hsdocs . redirects . delete ( { id : ' {redirectId} ' } , function ( err , result ) { } ) ;
Sites
hsdocs . sites . getAll ( function ( err , result ) { } ) ;
hsdocs . sites . get ( { id : ' {siteId} ' } , function ( err , result ) { } ) ;
hsdocs . sites . create ( {
fields : {
subDomain : ' some-subdomain ' ,
title : ' site title '
}
} , function ( err , result ) { } ) ;
hsdocs . sites . update ( {
id : ' {siteId} ' ,
fields : {
subDomain : ' some-subdomain ' ,
title : ' site title '
}
} , function ( err , result ) { } ) ;
hsdocs . sites . transfer ( {
id : ' {siteId} ' ,
fields : {
destinationApiKey : ' {another account Docs API key} '
}
} , function ( err , result ) { } ) ;
hsdocs . sites . delete ( { id : ' {siteId} ' } , function ( err , result ) { } ) ;
See full Help Scout Docs API description on official website: http://developer.helpscout.net/docs-api/