Skip to content
This repository has been archived by the owner on Jan 29, 2023. It is now read-only.

Latest commit

 

History

History
118 lines (83 loc) · 5.74 KB

README.md

File metadata and controls

118 lines (83 loc) · 5.74 KB

classeur-api-client

Archived: this project, and Classeur itself, are in various states of deactivated and spun down, so this GitHub repository has been archived.

Node.js client for the REST API of http://classeur.io/ Build Status npm version

Classeur is an online writing and collaboration platform by the creators of StackEdit. In addition to a web and desktop UI, it provides a read-only REST API. classeur-api-client is a simple object-oriented Node.js library for interacting with that API.

If you just want to download content out of Classeur, or if you want to see this module get used, you might be interested in my classeur-downloader script and NPM module.

Documentation

Documentation for this module is available on GitHub pages. For documentation on older or unreleased package versions, go here.

Source code for this package is avaiable at https://github.com/zbentley/classeur-api-client.

Installation

npm install classeur-api-client

Usage

Getting Started

This module provides an object-oriented interface to the Classeur API. Once it is installed, you should be able to to write:

const ClasseurClient = require('classeur-api-client');
const myClient = new ClasseurClient({ userId: 'my id', apiKey: 'my key' });

...and be up and running.

Getting Files

For more information on method arguments, return types, etc., see the full API Documentation.

ClasseurClient#GetFile can be used to retrieve single files:

const fs = require('fs');
const myClient = new ClasseurClient({ userId: 'my id', apiKey: 'my key' });

myClient.getFile('some file ID', function(error, result) {
	if ( error ) {
		console.log(`Oh no! Something went wrong: ${error}`);
	} else {
		console.log(`Saving file ${result.name}...`);
		fs.writeFile('/path/to/file.md', result.content.text, function(error, result) {
		...
		});
	}
});

ClasseurClient#getFiles or getFolders can be used to get more than one file or folder at a time (at the cost of one API hit, done in parallel, per file):

myClient.getFiles(['id1', 'id2', ... ], function(error, results) {
	if ( error ) {
		console.log(`Oh no! Something went wrong: ${error}`);
	} else {
		results.forEach(function (result) {
			console.log(`Found file ${result.name} with ${result.content.text}`);
		});
	}
});

getFiles and getFolders are multisignature functions, which means they can also be called with lists of parameters, e.g. GetFiles('id1', 'id2', ..., function(error, result) { ... }). This does not depend on ES6 rest parameters.

Getting Metadata

Metadata getters (e.g. getUserMetadata, or getFoldersMetadata) work in much the same way as getFile and getFiles. There are single versions:

myClient.getUserMetadata('some user id', function(error, result) {
	if ( error ) {
		console.log(`Oh no! Something went wrong: ${error}`);
	} else {
		console.log(`User id ${result.id}'s real name is ${result.name}`);
	}
});

. . . and plural versions:

myClient.getFilesMetadata(['file id 1', 'file id 2' ... ], function(error, result) {
	if ( error ) {
		console.log(`Oh no! Something went wrong: ${error}`);
	} else {
		results.forEach(function (result) {
			console.log(`File ${result.name} was last updated at ${result.updated}`);
		});
	}
});

Using IDs

The REST API operates only by ID. You cannot get any information by human-visible name; you have to use the object IDs of files and folders to retrieve them using classeur-api-client. The IDs of files are visible in the URI bar of Classeur (if you are using Classeur in a browser). IDs of other objects, including files, are visible via the 'properties' windows of those objects in the Classeur UI.

Making Changes

See the Developer's Guide for more info.

NPM package versions will follow Semantic Versioning.

Bugs

File a GitHub issue on the main repository.

Release Notes

Release notes are available here, under the "Release Notes" heading.