This is a javascript/node client library for the GitBook (https://www.gitbook.com) API.
This API is promise-based.
$ npm install gitbook-api
var GitBook = require("gitbook-api");
var client = new GitBook();
Create an API client with an authentified user:
var client = new GitBook({
username: "MyUsername",
token: "password or token"
});
To use this api client with a GitBook Enterprise instance, simply add a host
option, example: "host": "http://gitbook.mycompany.com"
.
List books fron the authenticated user:
client.books()
.then(function(result) {
// result.list: list of books
// result.total: total count of books
}, function(err) {
// Error occured
});
List all public books:
client.books('all')
Use pagination:
client.books({ skip: 50, limit: 100 })
client.books('all', { skip: 50, limit: 100 })
client.book("GitBookIO/javascript").then(function(book) { });
client.author("GitBookIO").then(function(org) { });