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

node-shikimori-api

v1.1.3

Published

Lightweight and easy to use wrapper for shikimori api

Downloads

12

Readme

node-shikimori-api - Why? Because.

Документация на русском

Installing

Using npm

npm i node-shikimori-api

Using yarn

yarn add node-shikimori-api

Common Usage

Basics:

const Shikimori = require("node-shikimori-api");
const shiki = new Shikimori();

shiki.api.users({ // request to https://shikimori.org/api/users/Syleront
  user_id: "Syleront"
}).then((res) => {
  // some code
});

Authorizing with OAuth2

const Shikimori = require("node-shikimori-api");
const shiki = new Shikimori();

shiki.auth.login({
  nickname: "zerotwo",
  password: "qwerty123"
}).then(() => {
  shiki.api.users({ // request to https://shikimori.org/api/users/whoami
    section: "whoami"
  }).then((res) => {
    // returns logged user info
  });
}).catch((err) => {
  // handle errors
});

Address paths

Shikimori uses some parts of the address as parameters (for example, user id) How to transfer them? Suppose we need to make a request to ../api/users/zerotwo/history, where zerotwo is the user id (https://shikimori.org/api/doc/1.0/users/history) To do this, do the following:

shiki.api.users({
  section: "history",
  user_id: "zerotwo" // You can also use anime_id or id instead of user_id
}).then((res) => {
  // some code
});

Also, if the method should be sent POST request instead of GET (for example, to send a message) To do this, use the parameter "method"

shiki.api.messages({
  method: "post",
  message: { // parameters for post request
    body: "Hello!",
    from_id: 123,
    to_id: 456,
    kind: "private"
  }
}).then((res) => {
  // some code
});

V2 api support

shiki.api.user_rates({
  v: 2, // set this parameter for v2 api
  id: 59278511,
  method: "patch",
  user_rate: {
    episodes: 1
  }
}).then((r) => {
  // some code
});

Parameters for request is merged with wrapper parameters In deep, he's get next parameters if exists: method, user_id, anime_id, id, v And removes it from request parameters

Custom methods

The module has some of its methods that were implemented by parsing and sniffing traffic to the site

Search

shiki.utils.search({
  query: "k-on",
  type: "animes" // sets by default
}).then((res) => {
  // return a list of animes by this name
});

Available types: animes, mangas, ranobe, characters, people, users Also, "people" type may take kind params: seyu, producer, mangaka

Example:
shiki.utils.search({
  query: "hayao",
  type: "people",
  kind: "producer"
}).then((res) => {
  // return a list of producers by query
});

Mark history by days

By default, the site's api does not sort the user history, but a function was written that marks array elements by day This will help you filter/sort the array.

Usage:
shiki.api.users({
  section: "history",
  user_id: "Syleront",
  limit: 100
}).then(shiki.utils.markHistory).then((r) => {
  // some code
})
Default response:
{
  id: 136013914,
  created_at: "2019-03-12T18:37:35.621+03:00",
  description: "Просмотрены 2-й и 3-й эпизоды",
  target: {} //...
}
Marked response:
{
  id: 136013914,
  created_at: "2019-03-12T18:37:35.621+03:00",
  day_mark: "today", // this one
  day_mark_ru: "Сегодня", // and this
  description: "Просмотрены 2-й и 3-й эпизоды",
  target: {} //...
}

day_mark may have next values: today, yesterday, weekly, other