Kitsu
![donate badge](https://img.shields.io/badge/patreon-donate-ff69b4.svg?style=flat-square)
![cc coverage badge](https://img.shields.io/codeclimate/c/wopian/kitsu.svg?style=flat-square)
A Simple and 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
Browser Support
Package | Global Usage | Chrome | Firefox | Safari | IE/Edge |
---|
Default | > 1% | 61+ | 56+ | 10+ | Edge 15+ |
Legacy | > 0.1% | 49+ | 48+ | 5.1+ | IE 8+, Edge 14+ |
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'
const Kitsu = require('kitsu')
const Kitsu = require('kitsu/lib/legacy')
const api = new Kitsu()
const api = new Kitsu({
baseURL: 'https://api.example/2'
})
const { data } = api.get('anime')
.then(res => res)
const { data } = await api.get('anime')
api.get('anime')
api.get('anime/1')
api.get('anime/1/episodes')
api.create('post', {
content: 'some content'
})
api.update('post', {
id: '1',
content: 'new content'
})
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