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

@37teams/adbutler

v2.0.0

Published

AdButler API wrapper

Downloads

13

Readme

AdButler node.js bindings

Build Status

These bindings are intended for use on the server side because they deal with secret keys explicitly. DO NOT use them in the browser.

Installation

Install using the following NPM command:

npm install --save adbutler

This will save the AdButler dependency in package.json.

Usage

The first step is to load the library by requiring it.

var AdButler = require('adbutler');

Next, create an adButler instance. You can pass in your secret API key in the configuration object as shown below.

var adButler = new AdButler({
    'apiKey': 'YOUR_API_KEY'
})

Every resource can be accessed via the adButler instance and supports create, read, update, delete, and list operations. The library supports callback based and promise based usage. Pick the programming style you like. A brief overview of both follows.

Callback based usage

Every resource method accepts a callback function as the last argument. Following Node.js convention, the error object is always passed as the first argument to the callback function, and is null if no error occurred. Here is a simple example.

adButler.advertisers.read(123, function(error, data) {
  // error is null on success
  if (error) {
	console.log(error); // some error occurred
  } else {
	console.log(data); // the response data
  }
});

Promise based usage

Every resource method returns a promise if no callback function is given.

// Create a new media group
adButler.mediaGroups.create({
  "name": "Demo Media Group"
}).then(function(mediaGroup) {
  // Create a new image creative
  return adButler.creatives.image.create({
	'file': 'image-ad.png', // this file must exist where the script is executed
	'group': mediaGroup.id,
	'name': 'My Image Creative',
	'description': 'This is a description of my image creative.'
  });
}).then(function(imageCreative){
  // Create a new image banner
  return adButler.banners.image.create({
	'name': 'My Image Banner',
	'width': 300,
	'height': 250,
	'creative': imageCreative.id
  });
}).then(function(imageBanner) {
  // New image banner created in a new media group
}).catch(function(error) {
  // Deal with the error
});

Configuration

  • adButler.set('apiKey', 'your_SECRET_api_key ');
  • adButler.set('timeout', 20000); // in ms (default is node's default: 120000ms)

Documentation

See our detailed API documentation.

Development

Run the tests using npm:

$ npm install
$ npm test

If you wish, you may run tests using your AdButler Test API key by setting the environment variable ADBUTLER_TEST_API_KEY before running tests:

$ export ADBUTLER_TEST_API_KEY='your_api_key'
$ npm test

Note: On Windows use SET instead of export for setting the ADBUTLER_TEST_API_KEY environment variable.

License

© 2016–2017 SparkLIT. Released under the MIT license.