2.18.3 โ€ข Published 4 months ago

aniwatch v2.18.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

Aniwatch

Publish Package NPM Downloads GitHub License

stars forks issues version

!IMPORTANT

  1. This package is just an unofficial package for hianime.to and is in no other way officially related to the same.
  2. The content that this package provides is not mine, nor is it hosted by me. These belong to their respective owners. This package just demonstrates how to build a package that scrapes websites and uses their content.

Table of Contents

Quick start

Installation

To use aniwatch package in your project, run:

pnpm add aniwatch
# or "yarn add aniwatch"
# or "npm install aniwatch"

Example usage

Example - getting information about an anime by providing it's unique anime id, using anime Steins;Gate with steinsgate-3 unique anime id as an example.

import { HiAnime, HiAnimeError } from "aniwatch";

const hianime = new HiAnime.Scraper();

try {
  const data: HiAnime.ScrapedAnimeAboutInfo = await hianime.getInfo(
    "steinsgate-3"
  );
  console.log(data);
} catch (err) {
  console.error(err instanceof HiAnimeError, err);
}

getHomePage

Sample Usage

import { HiAnime } from "aniwatch";

const hianime = new HiAnime.Scraper();

hianime
  .getHomePage()
  .then((data) => console.log(data))
  .catch((err) => console.error(err));

Response Schema

{
  genres: ["Action", "Cars", "Adventure", ...],
  latestEpisodeAnimes: [
    {
      id: string,
      name: string,
      poster: string,
      type: string,
      episodes: {
        sub: number,
        dub: number,
      }
    },
    {...},
  ],
  spotlightAnimes: [
    {
      id: string,
      name: string,
      jname: string,
      poster: string,
      description: string,
      rank: number,
      otherInfo: string[],
      episodes: {
        sub: number,
        dub: number,
      },
    },
    {...},
  ],
  top10Animes: {
    today: [
      {
        episodes: {
          sub: number,
          dub: number,
        },
        id: string,
        name: string,
        poster: string,
        rank: number
      },
      {...},
    ],
    month: [...],
    week: [...]
  },
  topAiringAnimes: [
    {
      id: string,
      name: string,
      jname: string,
      poster: string,
    },
    {...},
  ],
  topUpcomingAnimes: [
    {
      id: string,
      name: string,
      poster: string,
      duration: string,
      type: string,
      rating: string,
      episodes: {
        sub: number,
        dub: number,
      }
    },
    {...},
  ],
  trendingAnimes: [
    {
      id: string,
      name: string,
      poster: string,
      rank: number,
    },
    {...},
  ],
  mostPopularAnimes: [
    {
      id: string,
      name: string,
      poster: string,
      type: string,
      episodes: {
        sub: number,
        dub: number,
      }
    },
    {...},
  ],
  mostFavoriteAnimes: [
    {
      id: string,
      name: string,
      poster: string,
      type: string,
      episodes: {
        sub: number,
        dub: number,
      }
    },
    {...},
  ],
  latestCompletedAnimes: [
    {
      id: string,
      name: string,
      poster: string,
      type: string,
      episodes: {
        sub: number,
        dub: number,
      }
    },
    {...},
  ],
}

๐Ÿ”ผ Back to Top

getAZList

Parameters

ParameterTypeDescriptionRequired?Default
sortOptionstringThe az-list sort option. Possible values include: "all", "other", "0-9" and all english alphabets .Yes--
pagenumberThe page number of the result.No1

Sample Usage

import { HiAnime } from "aniwatch";

const hianime = new HiAnime.Scraper();

hianime
  .getAZList("0-9", 1)
  .then((data) => console.log(data))
  .catch((err) => console.error(err));

Response Schema

{
  sortOption: "0-9",
  animes: [
    {
      id: string,
      name: string,
      jname: string,
      poster: string,
      duration: string,
      type: string,
      rating: string,
      episodes: {
        sub: number ,
        dub: number
      }
    },
    {...}
  ],
  totalPages: 1,
  currentPage: 1,
  hasNextPage: false
}

๐Ÿ”ผ Back to Top

getQtipInfo

Parameters

ParameterTypeDescriptionRequired?Default
animeIdstringThe unique anime id (in kebab case).Yes--

Sample Usage

import { HiAnime } from "aniwatch";

const hianime = new HiAnime.Scraper();

hianime
  .getQtipInfo("one-piece-100")
  .then((data) => console.log(data))
  .catch((err) => console.error(err));

Response Schema

{
  anime: {
    id: "one-piece-100",
    name: "One Piece",
    malscore: string,
    quality: string,
    episodes: {
      sub: number,
      dub: number
    },
    type: string,
    description: string,
    jname: string,
    synonyms: string,
    aired: string,
    status: string,
    genres: ["Action", "Adventure", "Comedy", "Drama", "Fantasy", "Shounen", "Drama", "Fantasy", "Shounen", "Fantasy", "Shounen", "Shounen", "Super Power"]
  }
}

๐Ÿ”ผ Back to Top

getAnimeAboutInfo

Parameters

ParameterTypeDescriptionRequired?Default
animeIdstringThe unique anime id (in kebab case).Yes--

Sample Usage

import { HiAnime } from "aniwatch";

const hianime = new HiAnime.Scraper();

hianime
  .getInfo("steinsgate-3")
  .then((data) => console.log(data))
  .catch((err) => console.error(err));

Response Schema

{
  anime: [
    info: {
      id: string,
      name: string,
      poster: string,
      description: string,
      stats: {
        rating: string,
        quality: string,
        episodes: {
          sub: number,
          dub: number
        },
        type: string,
        duration: string
      },
      promotionalVideos: [
        {
          title: string | undefined,
          source: string | undefined,
          thumbnail: string | undefined
        },
        {...},
      ],
      characterVoiceActor: [
        {
          character: {
            id: string,
            poster: string,
            name: string,
            cast: string
          },
          voiceActor: {
            id: string,
            poster: string,
            name: string,
            cast: string
          }
        },
        {...},
      ]
    }
    moreInfo: {
      aired: string,
      genres: ["Action", "Mystery", ...],
      status: string,
      studios: string,
      duration: string
      ...
    }
  ],
  mostPopularAnimes: [
    {
      episodes: {
        sub: number,
        dub: number,
      },
      id: string,
      jname: string,
      name: string,
      poster: string,
      type: string
    },
    {...},
  ],
  recommendedAnimes: [
    {
      id: string,
      name: string,
      poster: string,
      duration: string,
      type: string,
      rating: string,
      episodes: {
        sub: number,
        dub: number,
      }
    },
    {...},
  ],
  relatedAnimes: [
    {
      id: string,
      name: string,
      poster: string,
      duration: string,
      type: string,
      rating: string,
      episodes: {
        sub: number,
        dub: number,
      }
    },
    {...},
  ],
  seasons: [
    {
      id: string,
      name: string,
      title: string,
      poster: string,
      isCurrent: boolean
    },
    {...}
  ]
}

๐Ÿ”ผ Back to Top

getAnimeSearchResults

Parameters

ParameterTypeDescriptionRequired?Default
qstringThe search query, i.e. the title of the item you are looking for.Yes--
pagenumberThe page number of the result.No1
typestringType of the anime. eg: movieNo--
statusstringStatus of the anime. eg: finished-airingNo--
ratedstringRating of the anime. eg: r+ or pg-13No--
scorestringScore of the anime. eg: good or very-goodNo--
seasonstringSeason of the aired anime. eg: springNo--
languagestringLanguage category of the anime. eg: sub or sub-&-dubNo--
start_datestringStart date of the anime(yyyy-mm-dd). eg: 2014-10-2No--
end_datestringEnd date of the anime(yyyy-mm-dd). eg: 2010-12-4No--
sortstringOrder of sorting the anime result. eg: recently-addedNo--
genresstringGenre of the anime, separated by commas. eg: isekai,shounenNo--

!TIP

For both start_date and end_date, year must be mentioned. If you wanna omit date or month specify 0 instead. Eg: omitting date -> 2014-10-0, omitting month -> 2014-0-12, omitting both -> 2014-0-0

Sample Usage

import { HiAnime } from "aniwatch";

const hianime = new HiAnime.Scraper();

hianime
  .search("monster", 1, {
    genres: "seinen,psychological",
  })
  .then((data) => {
    console.log(data);
  })
  .catch((err) => {
    console.error(err);
  });

Response Schema

{
  animes: [
    {
      id: string,
      name: string,
      poster: string,
      duration: string,
      type: string,
      rating: string,
      episodes: {
        sub: number,
        dub: number,
      }
    },
    {...},
  ],
  mostPopularAnimes: [
    {
      episodes: {
        sub: number,
        dub: number,
      },
      id: string,
      jname: string,
      name: string,
      poster: string,
      type: string
    },
    {...},
  ],
  currentPage: 1,
  totalPages: 1,
  hasNextPage: false,
  searchQuery: string,
  searchFilters: {
    [filter_name]: [filter_value]
    ...
  }
}

๐Ÿ”ผ Back to Top

getAnimeSearchSuggestion

Parameters

ParameterTypeDescriptionRequired?Default
qstringThe search suggestion query.Yes--

Sample Usage

import { HiAnime } from "aniwatch";

const hianime = new HiAnime.Scraper();

hianime
  .searchSuggestions("one piece")
  .then((data) => console.log(data))
  .catch((err) => console.error(err));

Response Schema

{
  suggestions: [
    {
      id: string,
      name: string,
      poster: string,
      jname: string,
      moreInfo: ["Mar 4, 2000", "Movie", "50m"]
    },
    {...},
  ],
}

๐Ÿ”ผ Back to Top

getProducerAnimes

Parameters

ParameterTypeDescriptionRequired?Default
namestringThe name of anime producer (in kebab case).Yes
pagenumberThe page number of the result.No1

Sample Usage

import { HiAnime } from "aniwatch";

const hianime = new HiAnime.Scraper();

hianime
  .getProducerAnimes("toei-animation", 2)
  .then((data) => console.log(data))
  .catch((err) => console.error(err));

Response Schema

{
  producerName: "Toei Animation Anime",
  animes: [
    {
      id: string,
      name: string,
      poster: string,
      duration: string,
      type: string,
      rating: string,
      episodes: {
        sub: number,
        dub: number,
      }
    },
    {...},
  ],
  top10Animes: {
    today: [
      {
        episodes: {
          sub: number,
          dub: number,
        },
        id: string,
        name: string,
        poster: string,
        rank: number
      },
      {...},
    ],
    month: [...],
    week: [...]
  },
  topAiringAnimes: [
    {
      episodes: {
        sub: number,
        dub: number,
      },
      id: string,
      jname: string,
      name: string,
      poster: string,
      type: string
    },
    {...},
  ],
  currentPage: 2,
  totalPages: 11,
  hasNextPage: true,
}

๐Ÿ”ผ Back to Top

getGenreAnime

Parameters

ParameterTypeDescriptionRequired?Default
namestringThe name of anime genre (in kebab case).Yes--
pagenumberThe page number of the result.No1

Sample Usage

import { HiAnime } from "aniwatch";

const hianime = new HiAnime.Scraper();

hianime
  .getGenreAnime("shounen", 2)
  .then((data) => console.log(data))
  .catch((err) => console.error(err));

Response Schema

{
  genreName: "Shounen Anime",
  animes: [
    {
      id: string,
      name: string,
      poster: string,
      duration: string,
      type: string,
      rating: string,
      episodes: {
        sub: number,
        dub: number,
      }
    },
    {...},
  ],
  genres: ["Action", "Cars", "Adventure", ...],
  topAiringAnimes: [
    {
      episodes: {
        sub: number,
        dub: number,
      },
      id: string,
      jname: string,
      name: string,
      poster: string,
      type: string
    },
    {...},
  ],
  currentPage: 2,
  totalPages: 38,
  hasNextPage: true
}

๐Ÿ”ผ Back to Top

getAnimeCategory

Parameters

ParameterTypeDescriptionRequired?Default
categorystringThe category of anime.Yes--
pagenumberThe page number of the result.No1

Sample Usage

import { HiAnime } from "aniwatch";

const hianime = new HiAnime.Scraper();

hianime
  .getCategoryAnime("subbed-anime")
  .then((data) => console.log(data))
  .catch((err) => console.error(err));

// categories ->
// "most-favorite", "most-popular", "subbed-anime", "dubbed-anime",
// "recently-updated", "recently-added", "top-upcoming", "top-airing",
// "movie", "special", "ova", "ona", "tv", "completed"

Response Schema

{
  category: "TV Series Anime",
  animes: [
    {
      id: string,
      name: string,
      poster: string,
      duration: string,
      type: string,
      rating: string,
      episodes: {
        sub: number,
        dub: number,
      }
    },
    {...},
  ],
  genres: ["Action", "Cars", "Adventure", ...],
  top10Animes: {
    today: [
      {
        episodes: {
          sub: number,
          dub: number,
        },
        id: string,
        name: string,
        poster: string,
        rank: number
      },
      {...},
    ],
    month: [...],
    week: [...]
  },
  currentPage: 2,
  totalPages: 100,
  hasNextPage: true
}

๐Ÿ”ผ Back to Top

getEstimatedSchedule

Parameters

ParameterTypeDescriptionRequired?Default
date (yyyy-mm-dd)stringThe date of the desired schedule. (months & days must have 2 digits)Yes--

Sample Usage

import { HiAnime } from "aniwatch";

const hianime = new HiAnime.Scraper();

hianime
  .getEstimatedSchedule("2024-08-09")
  .then((data) => console.log(data))
  .catch((err) => console.error(err));

Response Schema

{
  scheduledAnimes: [
    {
      id: string,
      time: string, // 24 hours format
      name: string,
      jname: string,
      airingTimestamp: number,
      secondsUntilAiring: number
    },
    {...}
  ]
}

๐Ÿ”ผ Back to Top

getAnimeEpisodes

Parameters

ParameterTypeDescriptionRequired?Default
animeIdstringThe unique anime id.Yes--

Sample Usage

import { HiAnime } from "aniwatch";

const hianime = new HiAnime.Scraper();

hianime
  .getEpisodes("steinsgate-3")
  .then((data) => console.log(data))
  .catch((err) => console.error(err));

Response Schema

{
  totalEpisodes: 24,
  episodes: [
    {
      number: 1,
      isFiller: false,
      title: "Turning Point",
      episodeId: "steinsgate-3?ep=213"
    },
    {...}
  ]
}

๐Ÿ”ผ Back to Top

getEpisodeServers

Parameters

ParameterTypeDescriptionRequired?Default
episodeIdstringThe unique episode id.Yes--

Request sample

import { HiAnime } from "aniwatch";

const hianime = new HiAnime.Scraper();

hianime
  .getEpisodeServers("steinsgate-0-92?ep=2055")
  .then((data) => console.log(data))
  .catch((err) => console.error(err));

Response Schema

{
  episodeId: "steinsgate-0-92?ep=2055",
  episodeNo: 5,
  sub: [
    {
      serverId: 4,
      serverName: "vidstreaming",
    },
    {...}
  ],
  dub: [
    {
      serverId: 1,
      serverName: "megacloud",
    },
    {...}
  ],
  raw: [
    {
      serverId: 1,
      serverName: "megacloud",
    },
    {...}
  ],
}

๐Ÿ”ผ Back to Top

getAnimeEpisodeSources

Parameters

ParameterTypeDescriptionRequired?Default
idstringThe id of the episode.Yes--
serverstringThe name of the server.No"vidstreaming"
categorystringThe category of the episode ('sub', 'dub' or 'raw').No"sub"

Request sample

import { HiAnime } from "aniwatch";

const hianime = new HiAnime.Scraper();

hianime
  .getEpisodeSources("steinsgate-3?ep=230", "hd-1", "sub")
  .then((data) => console.log(data))
  .catch((err) => console.error(err));

Response Schema

{
  headers: {
    Referer: string,
    "User-Agent": string,
    ...
  },
  sources: [
    {
      url: string, // .m3u8 hls streaming file
      isM3U8: boolean,
      quality?: string,
    },
    {...}
  ],
  subtitles: [
    {
      lang: "English",
      url: string, // .vtt subtitle file
    },
    {...}
  ],
  anilistID: number | null,
  malID: number | null,
}

๐Ÿ”ผ Back to Top

Development

Pull requests are always welcome. If you encounter any bug or want to add a new feature to this package, consider creating a new issue. If you wish to contribute to this project, read the CONTRIBUTING.md file.

Thanks

Support

Don't forget to leave a star ๐ŸŒŸ. You can also follow me on X (Twitter) @riteshgsh.

License

This project is licensed under the MIT License - see the LICENSE file for more details.

Star History

2.18.3

4 months ago

2.18.2

6 months ago

2.18.1

7 months ago

2.18.0

7 months ago

2.11.0

7 months ago

2.12.0

7 months ago

2.11.1

7 months ago

2.5.0

7 months ago

2.10.0

7 months ago

2.7.0

7 months ago

2.9.0

7 months ago

2.8.0

7 months ago

2.17.0

7 months ago

2.15.2

7 months ago

2.14.3

7 months ago

2.15.0

7 months ago

2.14.1

7 months ago

2.16.0

7 months ago

2.15.1

7 months ago

2.12.1

7 months ago

2.14.0

7 months ago

2.13.1

7 months ago

2.12.2

7 months ago

2.3.0

9 months ago

2.2.1

9 months ago

2.2.0

9 months ago

2.1.1

9 months ago

2.4.1

9 months ago

2.4.0

9 months ago

2.1.0

9 months ago

2.0.1

9 months ago

1.2.3

10 months ago

1.2.2

10 months ago

1.2.1

11 months ago

1.1.1

11 months ago

1.1.0

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago

0.3.2

11 months ago

0.3.1

11 months ago

0.3.0

11 months ago

0.2.3

11 months ago

0.2.2

11 months ago

0.2.1

11 months ago

0.2.0

11 months ago

0.1.0

11 months ago

2.0.0

2 years ago