An opinionated {json:api} client for Elide based APIs
There are already a number of client libraries for working with JSON API, however this library is specifically designed for interacting with Elide based APIs, which has a few of it's own unique characteristics.
- Built with Typescript!
- Built on top of axios as a peer dependency
- Supports
Promises
andasync/await
- JSON API response normalization
- Flatter structure
- Merges included relationship data
- Serializes normalized resources back to a JSON API structure
- Dates are converted to Unix epoch time for Elide
- Protected fields can be omitted from being sent to the API
- Supports JSON Patch Extension for bulk writes and complex mutations
- Parameter serialization
- Fields, filter, include, sort
- Pagination:
size
&number
ORoffset
&limit
- Request caching and throttling
import ApiClient from 'elide-jsonapi-client'
// Initialize a new client
const api = new ApiClient({
baseURL: 'http://localhost/api',
})
// Fetch a resource collection
const res = await api.fetch('articles')
// Create a resource
api.create('articles', {
type: 'articles',
title: 'Hello World',
})
// Update a resource
api.update('articles/1', {
id: '1',
type: 'articles',
title: 'Hello World!!!',
})
// Remove a resource
api.remove('articles', 1)
Request caching is not working with axios v0.19.0 due to a custom config bug.
See CHANGELOG
See TODO
See CONTRIBUTING
Bootstrapped with TypeScript library starter
Inspired by Kitsu