npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

brickset

v0.3.1

Published

NodeJS adapter to Brickset API

Downloads

13

Readme

node-brickset NPM version Build Status

NodeJS adapter to Brickset API

What This Module Provides

Brickset is an online LEGO® set guide.

The Brickset API v2 provides an API into the site's functionality. This module eases authentication and provides Promise wrappers around these API functions.

The API is a SOAP API, and this module leverages node-soap to access it. Promises are provided by Q.

Like node-soap, as the WSDL file changes, so does the JS API--client object methods are generated automatically.

You need an API key from Brickset to use this module; get one here. Many functions also require a Brickset user name and password. It's recommended to store these in the environment variables BRICKSET_API_KEY, BRICKSET_USERNAME, and BRICKSET_PASSWORD, respectively.

Passwords are sent in plaintext; Brickset does not provide https. Use a unique password!

This module supports the Brickset API v2 only.

Installation

npm install brickset

Usage


var brickset = require('brickset');

brickset({
  api_key: YOUR_API_KEY,
  username: YOUR_BRICKSET_USERNAME, // optional, for functions requiring auth
  password: YOUR_BRICKSET_PASSWORD  // ditto
})
  .then(function(bs) {
    // this function requires auth; login happens automatically
    return bs.getSet({
      setID: '7722-1'
    });
  })
  .get(0) // getSet() returns an array; get first item
  .get('bricksetURL')
  .then(function(url) {
    console.log(url);
  });

// alternatively, you can use node-style callbacks
brickset({
  api_key: YOUR_API_KEY,
  username: YOUR_BRICKSET_USERNAME, // optional, for functions requiring auth
  password: YOUR_BRICKSET_PASSWORD  // ditto
}, function(err, bs) {
  bs.getSet({
    setID: '7722-1'
  }, function(err, legoSet) {
    // etc.
  });
});

Cache Busting

For performance, the module will cache the API definition (WSDL) file. If you do not want to cache this information, use:

brickset({
  api_key: YOUR_API_KEY,
  cache: false
});

The definition is located in /path/to/brickset/lib/.BricksetAPIv2Soap.wsdl (thus, if you have installed globally for some reason, you may incur permissions issues if superuser access is needed to write to this file).

Since the API is in beta as of this writing, it's subject to change. You should probably remove the cache every so often until it is finalized.

Brickset API URL

If the URL of the WSDL should change, you can define a custom URL:

brickset({
  api_key: YOUR_API_KEY,
  url: 'http://some/url.wsdl'
});

Testing

  1. (Fork and) clone this repo
  2. npm install
  3. npm test

Resources

License

MIT

Author

Christopher Hiller