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

cheezburger

v0.0.1

Published

A module for interfacing with the cheezburger api

Downloads

14

Readme

node-cheezburger

A module for interfacing with the cheezburger api

Usage

Add cheezburger to your package.json

npm install --save cheezburger

Require & Instantiate a Cheezburger instance with your access token

var Cheezburger = require('cheezburger')
var cheezburger = new Cheezburger({ access_token : "<your access token>"})

You can now make cheezburger calls:

cheezburger.ohai("Hello Ohai",function(err,response){ console.log(response) })

All responses are javascript objects with an items key containing an array of responses. If pagination is available, it will be returned as page and page_size keys.

Endpoints & Options

ohai

cheezburger.ohai(message - String, callback)

Cheezburger docs

Returns an object with an items key. The first item is the response.

Assets

cheezburger.assets.get(id - String, callback)

Cheezburger docs

Returns an object with an items key. The first item is the requested asset.

cheezburger.assets.post(options - Mixed, callback)

Cheezburger docs

Accepts the following options (or you can pass a file in place of options to accept all defaults):

  • content The image file Required File name, URL, or encoded data.
  • title Title of the asset Optional string
  • description Description of the asset Optional string
  • site_id ID of the site to post on Optional integer
  • anonymous Whether the posting is anonymous or not. If false, then the asset is associated with the current user account. Optional. Default is false. Boolean

Returns an object with an items key. The first item is the posted asset info.

Asset Types

cheezburger.assettypes(callback)

Cheezburger docs

Returns an object with an items key. Each item is an asset type.

Site Types

cheezburger.sitetypes(callback)

Cheezburger docs

Returns an object with an items key. Each item is a site type.

Me

cheezburger.me(callback)

Cheezburger docs

Returns an object with an items key. The first item is the user belonging to the access token.

User

cheezburger.user(id - String,callback)

Cheezburger docs

Returns an object with an items key. The first item is the user belonging to the specified id.

Me

cheezburger.me(callback)

Cheezburger docs

Returns an object with an items key. The first item is the user belonging to the access token.

Sites

cheezburger.sites(options - Mixed, callback)

Cheezburger docs

If called with an object, accepts the following arguments:

  • parent_site_id Parent site ID. If supplied, restricts the response to only children of that parent. Only a single value can be provided. Optional integer
  • site_type_id Site type ID. If supplied, restricts the response to only sites of a particular type. Default is 1 (Network). See sitetypes for more information. Optional integer

If called with an id as the first argument, will return the specified site.

If called with mine or my as the first argument, will return the logged in users' sites.

This endpoint may return more than 10 items. If it does, paging info will also be returned.

Returns an object with an items key. Each Item is a site.

My Sites

cheezburger.mysites([options],callback)

Cheezburger docs

If called without options, returns up to the first 10 sites for the current user.

Returns an object with an items key. Each item is a site belonging to the logged in user.

Page

cheezburger.page(page,pageSize,method, [arguments ...])

Cheezburger docs

Meta method for calling other methods with paging info. The only methods that will return paged info are sites and mysites.

Call curried with page, pageSize, and method - the other arguments are the same as the method specified. For instance, to call requesting sites:

cheezburger.page(2,25,'sites','mine',function(err,obj){
  // obj.items is now an array of the 2nd page (25 per page) of my own sites.
})

Using without an access token

You can use cheezburger without an access token by instantiating with a client id and secret:

var cheezburger = new Cheezburger({ id : "<your client id>", secret : "<your client secret>" })

Cheezburger will automatically try to generate a token when you call the api.

Note that any user specific API endpoints will not work unless a user has logged in (see next section)

Prompting a user to log in

If using without an initial access_token, you can generate a url to send the user to.

Instantiate the Cheezburger API with your client_id:

var cheezburger = new Cheezburger({ id : "<your client id>" })

Then when prompting your user to authorize your app, redirect them to:

cheezburger.authUrl("http://yoursite.com/auth/success/handler")

where the passed url is where you want cheezburger to redirect back with the access token or error.

The redirected request will contain JSON with an access_token key. When you have that, set the access token on cheezburger to use the rest of the API:

cheezburger.setAccessToken(response.access_token)

Reference for the cheezburger api is located here: https://developer.cheezburger.com/docs/

Bugs & Stuff

Please file any bugs in the github issue tracker for this repo.

You can also contact me on twitter: @jesseditson