New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

displayer-api-client

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

displayer-api-client

A client library for the Backpack Displayer API

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
increased by80%
Maintainers
1
Weekly downloads
 
Created
Source

displayer-api-client

Example

  var DisplayerAPI = require("displayer-api-client");
  var api = new DisplayerAPI("http://backpack.openbadges.org");

  var user = api.user("someone@example.org");

  user.id(function (err, id) {
    console.log("Looked up user id, and it is", id);
  });

  user.groups(function (err, groups) {
    console.log("Looked up user groups, and they are", groups);
  });

  user.group(10, function (err, badges) {
    console.log("Looked up group 10, and the badges in it are", badges);
  });

ID lookups are cached, but group lookups are not. You may also provide the user id if known to skip that step, like so:

  var user = api.user({
    id: 1,
    email: "optional@example.org"
  });

Callback Styles

All of the user methods support three styles of invocation:

  user.id(function callback (err, id) {});                        // node style callback
  user.id(function success (id) {}, function failure (err) {});   // success/failure style callbacks
  var idPromise = user.id();                                      // promises 

If additional arguments are needed, they preceed the callbacks (if any).

Promises are implemented by bluebird.

Streams

There are two additional methods that return JSONStream streams:

  var g = user.getGroupStream();
  g.on("data", function (data) {
    console.log("A group:", data);
  });

  var b = user.getBadgeStream(10);
  b.on("data", function (data) {
    console.log("A badge in group 10:", data);
  });

FAQs

Package last updated on 09 Apr 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc