Skip to content

Latest commit

 

History

History
81 lines (66 loc) · 2.56 KB

getting-started.md

File metadata and controls

81 lines (66 loc) · 2.56 KB

consumet.ts

Getting Started

Hello! Thank you for checking out consumet.ts!

This document aims to be a gentle introduction to the library and its usage.

Let's start!

Installation

Install with npm:

npm i @consumet/extensions

Install with yarn:

yarn add @consumet/extensions

Usage

Example - searching for a book using the libgen provider.

// ESM
import { BOOKS } from "@consumet/extensions"
// CommonJS
const { BOOKS } = require("@consumet/extensions");

const main = async () => {
  // Create a new instance of the Libgen provider
  const books = new BOOKS.Libgen();
  // Search for a book. In this case, "Pride and Prejudice"
  const results = await books.search('pride and prejudice');
  // Print the results
  console.log(results);
  // Get the first book info
  const firstBook = results[0];
  const bookInfo = await books.scrapePage(firstBook.link);
  // Print the info
  console.log(bookInfo);
};

main();

see also BOOKS documentation for more information.
Example - searching for anime using the gogoanime provider.

// ESM
import { ANIME } from "@consumet/extensions"
// CommonJS
const { ANIME } = require("@consumet/extensions");

const main = async () => {
  // Create a new instance of the Gogoanime provider
  const gogoanime = new ANIME.Gogoanime();
  // Search for a anime. In this case, "One Piece"
  const results = await gogoanime.search("One Piece");
  // Print the results
  console.log(results);
  // Get the first anime info
  const firstAnime = results.results[0];
  const animeInfo = await gogoanime.fetchAnimeInfo(firstAnime.id);
  // Print the info
  console.log(animeInfo);
  // get the first episode stream link. By default, it chooses goload server.
  const episodes = await gogoanime.fetchEpisodeSources(animeInfo.episodes[0].id);
  // get the available streaming servers for the first episode
  const streamingServers = await gogoanime.fetchEpisodeServers(animeInfo.episodes[0].id);
}

see also ANIME documentation for more information.
Awesome, that was easy.

if you want to use different providers, you can check the providers list here or in json format.

if you have any questions, please join the discord server or open an issue.

(back to table of contents)