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

kitsu

Package Overview
Dependencies
Maintainers
1
Versions
173
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kitsu

Simple & lightweight JSON-API client for Kitsu and other compliant APIs

  • 4.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5K
decreased by-8.5%
Maintainers
1
Weekly downloads
 
Created
Source

Kitsu

npm badge npm install badge david badge contributors badge donate badge

travis badge appveyor badge david dev badge cc maintainability badge cc coverage badge

A simple, lightweight & framework agnostic JSON:API client for Kitsu.io and other APIs

Check out the Migration Guide for breaking changes and new features in 4.x

Features

  • JSON-API 1.0 compliant
  • Automatically links relationships to data
  • Works in Node and on the web
  • Uses the Promise API
  • Configurable timeout handling

Install

yarn add kitsu
npm install kitsu

Node / Browser Support

PackagePackage
Size
NodeChromeFirefoxSafariEdgeIE
Default17.8 kb6+49+57+10.1+15+
Legacy19.8 kb6+4+3+3.1+12+8+
Node14.0 kb6+

Response Comparison

A GET response by a JSON:API server returns:

{
  data: {
    id: '1'
    type: 'articles'
    attributes: {
      title: 'JSON API paints my bikeshed'
    }
    relationships: {
      author: {
        data: {
          id: '42'
          type: 'people'
        }
      }
    }
  }
  included: [
    {
      id: '42'
      type: 'people'
      attributes: {
        name: 'John'
      }
    }
  ]
}

A GET request with kitsu returns:

{
  data: {
    id: '1'
    type: 'articles'
    title: 'JSON API paints my bikeshed'
    author: {
      id: '42',
      type: 'people'
      name: 'John'
    }
  }
}

Usage

import Kitsu from 'kitsu'                 // ES Modules and Babel
const Kitsu = require('kitsu')            // CommonJS and Browserify
const Kitsu = require('kitsu/lib/legacy') // Legacy IE8+ support
const Kitsu = require('kitsu/lib/node')   // Lighter node-only package

const api = new Kitsu()                   // For kitsu.io developers

const api = new Kitsu({                   // For other JSON:API servers
  baseURL: 'https://api.example/2'        // e.g https://api.example/2
})

const { data } = await api.get('anime')   // Using with async/await

api.get('anime')                          // Using with Promises
  .then(({ data }) => { ... })
  .catch(err => throw err)

// Fetching resources with get() or fetch()
api.get('anime', { params }, { headers }) // Collection of resources
api.get('anime/1')                        // Single resource
api.get('anime/1/episodes')               // Single resource's relationship

// Creating resources with post() or create()
api.create('post', {
  content: 'some content'
})

// Updating resources with patch() or update()
api.update('post', {
  id: '1',
  content: 'new content'
})

// Deleting resources
api.remove('post', 1)

Read the Documentation

More Examples

If you're working with Kitsu.io's API, their API docs lists all available resources with their attributes and relationships

Contributing

See CONTRIBUTING

Releases

See CHANGELOG

License

All code released under MIT

Keywords

FAQs

Package last updated on 16 Jan 2018

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