1.0.4 • Published 5 years ago

llms-api-node v1.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

LifterLMS REST API Wrapper - Node.js

CircleCI Maintainability Test Coverage

Node.js wrapper for the LifterLMS REST API

CHANGELOG

Installation

npm install --save llms-api-node

Setup and Configuration

const api = require( 'llms-api-node' );

// Authenticate and configure the API.
const llms = new api( {
  url: 'https://mysite.tld',
  consumerKey: 'ck_XXXXXXXXXXXXXXXXXXXXXX',
  consumerSecret: 'cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
} );

Configuration Options

OptionTypeRequiredDescription
urlstringyesThe URL of the WordPress site where LifterLMS is installed. Example: https://mysite.tld
consumerKeystringyesYour API consumer key
consumerSecretstringyesYour API consumer secret
authMethodstringnoDefine the authorization method used. Accepts "basic" (default) or "headers".
versionstringnoLifterLMS REST API version. Default: "v1".
verifySslboolnoVerify SSL certificates. Disable when testing with self-signed certificates. Default: true.
encodingstringnoEncoding. Default: "utf-8".
portstringnoProvide support for URLs with ports, eg: 8080.
timeoutintnoDefine the request timeout (in seconds).
wpPrefixstringnoDefine a custom REST API URL prefix to support custom prefixes defined via the rest_url_prefix filter.
wpVersionstringnoDefine the WP Core REST API version to use. Default: "v2".

Example Usage

Requests using async (promified) methods.

llms.getAsync( '/courses' ).then( response => {
  if ( 200 !== response.statusCode ) {
    throw new Error( 'Error!' );
  }
  return JSON.parse( response.body );
} );

Requests using regular methods.

llms.get( '/courses', function( err, data, res ) ) {
  if ( err ) {
    throw new Error( err );
  }
  return JSON.parse( data );
}

Releasing

  • Commit and push changes
  • Bump version with npm version
  • Push changes and push tags git push origin master && git push --tags
  • CircleCI automatically publishes to npm when tags are created.