127 lines
No EOL
3.8 KiB
HTML
127 lines
No EOL
3.8 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>JSDoc: Home</title>
|
|
|
|
<script src="scripts/prettify/prettify.js"> </script>
|
|
<script src="scripts/prettify/lang-css.js"> </script>
|
|
<!--[if lt IE 9]>
|
|
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
<![endif]-->
|
|
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
|
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="main">
|
|
|
|
<h1 class="page-title">Home</h1>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h3> </h3>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<section>
|
|
<article><h1>XIV Character Cards</h1>
|
|
<p><img src="https://img.shields.io/npm/v/xiv-character-cards" alt="npm Version">
|
|
<a href="https://xivapi.github.io/XIV-Character-Cards/"><img src="https://img.shields.io/badge/docs-JSDoc-orange" alt="Documentation"></a></p>
|
|
<p>API to create fancy cards for FFXIV characters based on their Lodestone data, hosted at https://ffxiv-character-cards.herokuapp.com.</p>
|
|
<p><img src="https://ffxiv-character-cards.herokuapp.com/characters/id/9575452.png" alt="Demo image"></p>
|
|
<h2>Endpoints</h2>
|
|
<h3>Getting images</h3>
|
|
<p><code>https://ffxiv-character-cards.herokuapp.com/characters/id/<LODESTONE ID>.png</code>
|
|
<br>Get the PNG for a character by its Lodestone ID.</p>
|
|
<br>
|
|
<p><code>https://ffxiv-character-cards.herokuapp.com/characters/name/<WORLD>/<CHARACTER NAME>.png</code>
|
|
<br>Get the PNG for a character by its world and name.</p>
|
|
<h3>Requesting images to be cached</h3>
|
|
<p>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.</p>
|
|
<p><code>https://ffxiv-character-cards.herokuapp.com/prepare/id/<LODESTONE ID></code>
|
|
<br>Request a character image to be cached by its Lodestone ID.</p>
|
|
<br>
|
|
<p><code>https://ffxiv-character-cards.herokuapp.com/prepare/name/<WORLD>/<CHARACTER NAME></code>
|
|
<br>Request a character image to be cached by its world and name.</p>
|
|
<p>The API will reply with its status, and in case of success, the URL to the final image.
|
|
<code>{"status":"ok","url":"/characters/id/123456789.png"}</code></p>
|
|
<h2>Using in your application</h2>
|
|
<pre class="prettyprint source"><code>yarn add xiv-character-cards
|
|
# or
|
|
npm i xiv-character-cards
|
|
</code></pre>
|
|
<p>You will receive a PNG-buffer for you to use in your bot or application.<br>Check <code>index.js</code> for other usage examples.</p>
|
|
<h3>Example</h3>
|
|
<pre class="prettyprint source lang-js"><code>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);
|
|
}
|
|
});
|
|
});
|
|
</code></pre></article>
|
|
</section>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<nav>
|
|
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="CardCreator.html">CardCreator</a></li></ul>
|
|
</nav>
|
|
|
|
<br class="clear">
|
|
|
|
<footer>
|
|
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.7</a> on Sun May 30 2021 14:00:10 GMT+0000 (Coordinated Universal Time)
|
|
</footer>
|
|
|
|
<script> prettyPrint(); </script>
|
|
<script src="scripts/linenumber.js"> </script>
|
|
</body>
|
|
</html> |