@ruffpuff/celestia
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

Celestia

A GraphQL API for fetching Animal Crossing villager & amiibo data.

Ko-fi Donate Continuous Deployment wakatime npm


Table of Contents


Package

The package that comes with this API uses GraphQL Code Generator for full typings of the API.

Installation

Using Npm

npm install @ruffpuff/celestia

Using Yarn

yarn add @ruffpuff/celestia

Usage

Here is some example usage with the API, using the package @ruffpuff/celestia

Using Fetch

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));

Using @foxxie/fetch

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 💰

Donating helps ensure that I can keep this project going. Thank you for supporting :D

Buy Me a Coffee at ko-fi.com

Contributors

Thanks goes to these wonderful people (emoji key):


Ruff

💻 🖋 🤔 💡 💵

raindrop-droptop

🤔 💵

This project follows the all-contributors specification. Contributions of any kind welcome!

Readme

Keywords

none

Package Sidebar

Install

npm i @ruffpuff/celestia

Weekly Downloads

0

Version

1.3.0

License

MIT

Unpacked Size

75.1 kB

Total Files

9

Last publish

Collaborators

  • ruffpuff