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

artifacts-api-client

v1.7.0

Published

Api client for https://artifactsmmo.com

Downloads

35

Readme

Api Client for Artifacts

npm npm

API wrapper for NodeJS and browsers with TypeScript support

Installation

npm i artifacts-api-client

Usage

artifacts-api-client fully implements official API.

import { ArtifactsApi } from 'artifacts-api-client';

// Initialization
const artifactsApi = ArtifactsApi.create({
  token: 'TOKEN'
});

// Usage
const status = await artifactsApi.getStatus();
const resources = await artifactsApi.resources.getAll({
  min_level: 1,
  max_level: 10,
})
await artifactsApi.myCharacters.fight('name');

Alternatively, you can set token later:

import { ArtifactsApi } from 'artifacts-api-client';

const artifactsApi = ArtifactsApi.create();

await artifactsApi.myCharacters.fight('name'); // <-- fail, auth required

const { token } = await artifactsApi.token.generate('username', 'password');
artifactsApi.setToken(token);

await artifactsApi.myCharacters.fight('name'); // <-- now it works

Error handling

All artifacts API errors are wrapped with ArtifactsError. Keep in mind, that the others errors like NetworkError left as they are:

import { ArtifactsApi, ArtifactsError } from 'artifacts-api-client';

const artifactsApi = ArtifactsApi.create({
  token: 'TOKEN'
});

try {
  await artifactsApi.myCharacters.fight('name');
} catch (err) {
  if (err instanceof ArtifactsError) {
    console.error('Artifacts error', e.message, e.code, e.data);
  } else {
    throw e;
  }
}

Type bindings

If package being used with TypeScript you'll probably need methods' types. They are available to import:

import { ArtifactsApi, GetAllMapsApiResult, GetAllMapsApiQuery } from 'artifacts-api-client';

const artifactsApi = ArtifactsApi.create({
  token: 'TOKEN'
});

function getMaps(params: GetAllMapsApiQuery): Promise<GetAllMapsApiResult> {
  // ... custom logic ...
  return artifactsApi.maps.getAll(params);
};

Develop

Refer to DEVELOPMENT.md.