JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 21
  • Score
    100M100P100Q38640F
  • License MIT

A simplified interface for the Slothpixel API.

Package Exports

  • phoenix-slothpixel

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (phoenix-slothpixel) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

slothpixel Travis CI Build Status

A simplified interface for the Slothpixel API, adjusted for self-hosted instances.

NPM Badge

Install

npm install slothpixel

Usage

const slothpixel = require("slothpixel");

(async () => {
    const { uuid } = await slothpixel("players/Richienb", "https://api.slothpixel.me/api");

    console.log(uuid);
    //=> "56da43a4088d4a7682b6dd431535015e"
})();

API

slothpixel(endpoint, url, options?)

endpoint

Type: string

The API endpoint to call.

url

Type: string

The API URL to call, defaults to api.slothpixel.me/api.

options

Type: object

The options to pass to the API.

slothpixel.graphql(data)

Send a request to the Slothpixel Graphql API.

data

Type: object

The Graphql data to send. See https://graphql.org/learn/serving-over-http/#post-request.

const slothpixel = require("slothpixel");

(async () => {
    const query = `{
        players {
            player(player_name: "Richienb") {
                uuid
            }
        }
    }`;

    const data = await slothpixel.graphql({ query });

    console.log(data.players.player.uuid)
    //=> "56da43a4088d4a7682b6dd431535015e"
})();

slothpixel.SlothpixelError

Exposed for instanceof checks. This type of error is thrown when the API returns an error.