@ruffpuff/celestia
v1.3.0
Published
<div align='center'> <img src='https://cdn.ruffpuff.dev/celestia.png' width='140' height='140' /> <h1>Celestia ✨</h1> <blockquote>A GraphQL API for fetching Animal Crossing villager & amiibo data.</blockquote>
Downloads
7
Readme
Table of Contents
The package that comes with this API uses GraphQL Code Generator for full typings of the API.
npm install @ruffpuff/celestia
yarn add @ruffpuff/celestia
Here is some example usage with the API, using the package @ruffpuff/celestia
import type { Query } from '@ruffpuff/celestia';
interface AnimalCrossingResponse<K extends keyof Omit<Query, '__typename'>> {
data: Record<K, Omit<Query[K], '__typename'>>;
}
fetch('http://localhost:0617', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: `
{
getVillagerByName(villager: bob) {
key
keyJp
art
species
catchphrase
}
}
`
})
})
.then(res => res.json() as Promise<AnimalCrossingResponse<'getVillagerByName'>>)
.then(json => console.log(json.data));
import type { Query } from '@ruffpuff/celestia';
import { fetch } from '@foxxie/fetch';
interface AnimalCrossingResponse<K extends keyof Omit<Query, '__typename'>> {
data: Record<K, Omit<Query[K], '__typename'>>;
}
fetch('http://localhost:0617')
.body({
query: `
{
getVillagerByName(villager: bob) {
key
keyJp
art
species
catchphrase
}
}
`
})
.post()
.json<AnimalCrossingResponse<'getVillagerByName'>>()
.then(json => console.log(json.data));
Meta
Donating helps ensure that I can keep this project going. Thank you for supporting :D
Contributors ✨
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!