npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@piigo/xivapi

v0.0.2

Published

Object-oriented XIVAPI.com Client written in Typescript

Downloads

4

Readme

XIVAPI

Object-oriented XIVAPI.com Client written in Typescript

Install

npm i @piigo/xivapi

Usage

Add XIVAPI and create a new client object using your api key:

const XIVAPI = require("@piigo/xivapi");
const api = new XIVAPI("<API KEY GOES HERE>")

You can also pass language and server as optionnal parameters (default: en / "https://xivapi.com").

From here, you will have access to any content the API has to offer, either as raw data using .getContent("<CONTENT NAME>") or as object using the provided interfaces from the client (see Interfaces).

For a list of all content available, see : https://xivapi.com/content

Interfaces

Character

Using this interface, you will be able to retieve any informations about a character, or search someone using it's name.

const character = new XIVAPI().character;

const me = character.search("John Doe"); //Use this to search accross every servers, see Wiki for more details about the SearchResult<CharacterSearch> Object.

const data = character.get(me.id); //Use this to obtain more informations about a character, see Wiki for more details about the Character Object.

search() let you specify an optional parameter's object, which allow you to restrict researchs to a specific server, or specify the first page for the results (ex: page 2 instead of page 1).

Content

Using this interface, you will be able to retieve any informations about every resources accessible from the API. Some resources have transformers, which will transform the raw API results into proper objects, but keep in mind that most of them don't have these transformers, feel free to contribute if you want to add one, or open an issue and I'll add it if I have time.

When listing all available resources for a specific content, you will obtain a SearchResult<T> object where T will either be of transformer's type or any. Be carefull when using content that has no transformer, as the client will return raw data, so properties will probably be in PascalCase instead of camelCase, etc ... To make sure that the content you want has a transformer, you can use the hasTransformer property.

Alternatively, you can add your own transformer by creating a class that will use the data returned from the API and register it in the transformers object :

import { transformers } from "xivapi/structures/content/transformers";

Object.assign(transformers, {"<API CONTENT NAME>": TransformerClass})

If you do so, please fill a pull request so that others can benefit from it.


//With transformer

const addon = new XIVAPI().getContent("Addon");
const addonList = addon.list(); //Use this to list all the resources under this content category. See wiki for more details about SearchResult<T>.
const addonData = addon.get(addonList[0].id); //Use this to obtain more informations about a resource.

//Without transformer

const content = new XIVAPI().getContent("noTransformer");
const list = content.list();
const resource = content.get(list[0].ID);

search() let you restrict the research to a certain number of results per page using the limit argument (default to 100), you can also restrict the results by providing an array of IDs.