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

true-jsonist

v2.0.1

Published

Easily send {'Content-Type': 'application/json'} requests

Downloads

18

Readme

jsonist

JSON over HTTP: A simple wrapper around hyperquest for dealing with JSON web APIs.

A simple GET:

var url  = 'https://api.github.com/users/rvagg'
  , opts = { headers: { 'User-Agent': 'yee haw grandma' } }
  , fn   = function (err, data, resp) {
      console.log(data)
    }

jsonist.get(url, opts, fn)

// → { login: 'rvagg',
//     id: 495647,
//   ...
//   }

or a POST:

var url  = 'https://api.github.com/repos/rvagg/jsonist/issues'
  , opts = {
        headers : { 'User-Agent': 'yee haw grandma' }
      , auth    : 'rvagg:24d5dee258c64aef38a66c0c5eca459c379901c2'
    }
  , data = {
        'title' : 'Not a bug'
      , 'body'  : 'Just guinea-pigging your repo dude, move along.'
    }
  , fn   = function (err, data, resp) {
      console.log(data)
    }

jsonist.post(url, data, opts, fn)

// → { url: 'https://api.github.com/repos/rvagg/jsonist/issues/1',
//   ...
//   }

// you can also jsonist.put(), the kids love PUT requests these days

API

jsonist.get(url, [ options, ] callback)

Send a GET request to url and return the callback with an error or JSON deserialised data.

The options object is optional and is passed on to hyperquest.

The callback is called with up to 3 arguments. If there is an error there will only be an error argument in the first position, otherwise it will be null. The second argument will contain the deserialised object obtained from the server and the third argument will be the response object itself if you need to fetch headers or other metadata.

jsonist.post(url, data, [ options, ] callback)

Send a POST request to url, writing JSON serialised data to the request, and return the callback with an error or JSON deserialised data (if any).

'method' is set to 'POST' for you before passing on to hyperquest.

The data parameter can also be a readable stream that will get .pipe()'d to the request.

The options object is optional and is passed on to hyperquest.

jsonist.put(url, data, [ options, ] callback)

Same as jsonist.post() but for when that extra character is too much to type or you have to use someone's overloaded API. 'method' is set to 'PUT'.

Note: in each of the requests you can provide an optional 'hyperquest' parameter in your options if you want to really customise the http chain (see this)

License

jsonist is Copyright (c) 2014 Rod Vagg @rvagg and licensed under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.
true-jsonist is Copyleft (ç)