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

kitsu-json-api

v1.1.7

Published

This is a wrapper for the JSON API provided by Kitsu for Node.js. Full documentation can be found on their [website](https://kitsu.docs.apiary.io/#introduction/json-api).

Downloads

27

Readme

Kitsu JSON API

This is a wrapper for the JSON API provided by Kitsu for Node.js. Full documentation can be found on their website.

How to get started

Install with NPM

npm i kitsu-json-api --save

Import module to your js file

import KitsuApi from 'kitsu-json-api';

or

const KitsuApi =  require('kitsu-json-api');

then

let kitsuApi =  new KitsuApi();

Methods/Functions

execute()

Execution method for this wrapper API. You must call this to run the query/api call to kitsu! This method will return a promise with the response from kitsu. Kitsu response is modeled as

 {
   data: [{
      // object attributes
     }]
 }

query(keyword)

First method you need to call to properly call the API. The query function takes in a parameter that is a category the API allows you to query. For example if you want to query for animes you would do

 kitsuApi.query('anime')

Check here to see which categories you can query.

paginationOffset(number)

Sets the offset for pagination when receiving data.

paginationLimit(number)

Sets the limit for pagination when receiving data.

filter({Array.<{ filterKey: string, filterValue: string[], }>})

Allows you to [filter the category you](https://kitsu.docs.apiary.io/#introduction/json-api/filtering-and-search] query based on attributes of that category.) Check here to find what attributes the category has.

sort([ attributes ])

This methods takes in an array of flags and sorts based off the flags given by Kitsu. I haven't found all of them but some are specified in the documentation.

includes([ relationships ])

"You can include related resources with include=[relationship]. You can also specify successive relationships using a .. A comma-delimited list can be used to request multiple relationships."

sparse(fieldKey, [ fieldValues ])

"You can request a resource to only return a specific set of fields in its response. For example, to only receive a user's name and creation date: (e.g /users?fields[users]=name,createdAt)"

Example

Async/Await

  let resp = await kitsuApi
    .query('anime') // anime category
    .filter([
      {
        key: 'season',
        value: ['winter', 'spring'] // filter by winter and spring
      },
      {
        key: 'seasonYear',  // filter by year 2017
        value: ['2017']
      }
    ])
    .paginationLimit(10) // set limit
    .paginationOffset(2) // set offset
    .sort(['followersCount', 'followingCount']) // sort by follower count and following count
    .execute(); // execute the query

or

Promises

kitsuApi
  .query('anime') // anime category
  .filter([
    {
      key: 'season',
      value: ['winter', 'spring'] // filter by winter and spring
    },
    {
      key: 'seasonYear', // filter by year 2017
      value: ['2017']
    }
  ])
  .paginationLimit(10) // set limit
  .paginationOffset(2) // set offset
  .sort(['followersCount', 'followingCount']) // sort by follower count and following count
  .execute().then(resp => {
    // do something with json
  });