XIV-Character-Cards/index.html
Documentation 0cd5a07962 Updates
2021-05-30 14:07:33 +00:00

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/&lt;LODESTONE ID&gt;.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/&lt;WORLD&gt;/&lt;CHARACTER NAME&gt;.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 &quot;prepare&quot; the image for a character beforehand.</p>
<p><code>https://ffxiv-character-cards.herokuapp.com/prepare/id/&lt;LODESTONE ID&gt;</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/&lt;WORLD&gt;/&lt;CHARACTER NAME&gt;</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>{&quot;status&quot;:&quot;ok&quot;,&quot;url&quot;:&quot;/characters/id/123456789.png&quot;}</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(&quot;xiv-character-cards&quot;);
const fs = require(&quot;fs&quot;);
const card = new CardCreator();
const lodestoneid = &quot;13821878&quot;;
function example(cb) {
card.ensureInit()
.then(
() => card.createCard(lodestoneid),
(reason) => cb(&quot;Init failed: &quot; + reason, null)
)
.then((image) =>
cb(null, {
binary: {
image: image,
},
})
)
.catch((reason) => cb(&quot;createCard failed: &quot; + 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:07:32 GMT+0000 (Coordinated Universal Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>