Giter Site home page Giter Site logo

rexatlanti / xiv-character-cards Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xivapi/xiv-character-cards

0.0 0.0 0.0 4.69 MB

API to create fancy cards for FFXIV characters based on their Lodestone data, hosted at https://ffxiv-character-cards.herokuapp.com.

License: GNU Affero General Public License v3.0

JavaScript 100.00%

xiv-character-cards's Introduction

XIV Character Cards

API to create fancy cards for FFXIV characters based on their Lodestone data, hosted at https://ffxiv-character-cards.herokuapp.com.

Demo image

Endpoints

Getting images

https://ffxiv-character-cards.herokuapp.com/characters/id/<LODESTONE ID>.png
Get the PNG for a character by its Lodestone ID.


https://ffxiv-character-cards.herokuapp.com/characters/name/<WORLD>/<CHARACTER NAME>.png
Get the PNG for a character by its world and name.

Requesting images to be cached

If you are using this API together with an application that requires the API to respond very quickly, like Discord, you need to ask it to "prepare" the image for a character beforehand.

https://ffxiv-character-cards.herokuapp.com/prepare/id/<LODESTONE ID>
Request a character image to be cached by its Lodestone ID.


https://ffxiv-character-cards.herokuapp.com/prepare/name/<WORLD>/<CHARACTER NAME>
Request a character image to be cached by its world and name.

The API will reply with its status, and in case of success, the URL to the final image. {"status":"ok","url":"/characters/id/123456789.png"}

Using in your application

yarn add xiv-character-cards
# or
npm i xiv-character-cards

You will receive a PNG-buffer for you to use in your bot or application.
Check index.js for other usage examples.

Example

const { CardCreator } = require("xiv-character-cards");
const fs = require("fs");

const card = new CardCreator();
const lodestoneid = "13821878";

function example(cb) {
  card.ensureInit()
    .then(
      () => card.createCard(lodestoneid),
      (reason) => cb("Init failed: " + reason, null)
    )
    .then((image) =>
      cb(null, {
        binary: {
          image: image,
        },
      })
    )
    .catch((reason) => cb("createCard failed: " + reason, null));
}

example((err, response) => {
  const buffer = response.binary.image;
  fs.writeFileSync(`./${lodestoneid}.png`, response.binary.image, (err) => {
    if (err) {
      console.log(err);
    }
  });
});

xiv-character-cards's People

Contributors

arcanedisgea avatar goaaats avatar karashiiro avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.