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 🙏

© 2025 – Pkg Stats / Ryan Hefner

flibusta-api

v0.2.3

Published

> **Disclaimer**: This package is only created as an example of a search tool for Flibusta. If you like to read books - buy them legally.

Readme

Unofficial Flibusta API

Disclaimer: This package is only created as an example of a search tool for Flibusta. If you like to read books - buy them legally.

A TypeScript/JavaScript library for searching and downloading books from Flibusta. This unofficial API provides programmatic access to search functionality and book metadata.

Features

  • 📚 Search books by title and content
  • 👤 Search books by author
  • 📖 Get detailed book information including genres and descriptions
  • ⬇️ Download books in various formats (MOBI, EPUB, FB2, PDF)
  • 🔗 Generate download and send links
  • 📝 TypeScript support with full type definitions
  • 🧪 Comprehensive test coverage

Installation

npm install flibusta-api

Usage

Basic Book Search

import { searchBooks } from 'flibusta-api';

// Search for books by title or content
const books = await searchBooks('Harry Potter', 10);
console.log(books);
// Returns: Book[]

Search by Author

import { searchByAuthor } from 'flibusta-api';

// Search for books by a specific author
const books = await searchByAuthor('Tolkien', 5);
console.log(books);
// Returns: Book[]

Get Book Information

import { getBookInfo } from 'flibusta-api';

// Get detailed information about a specific book
const bookInfo = await getBookInfo(123456);
console.log(bookInfo);
// Returns: BookInfo | undefined

Download Books

import { downBook, getUrl } from 'flibusta-api';

// Download a book file
const bookFile = await downBook('123456', 'epub');
console.log(bookFile.fileName);

// Or just get the download URL
const downloadUrl = getUrl('123456', 'mobi');
console.log(downloadUrl);

API Reference

Types

Book

type Book = {
  id: number;
  title: string;
  author: string;
  link: string;
  sendLink: string;
};

BookInfo

type BookInfo = {
  id: number;
  title: string;
  author: string;
  genres: BookGenres[];
  description?: string;
};

BookFile

interface BookFile {
  id: string;
  file: Buffer;
  fileName: string;
  filePath?: string;
}

BookFormat

type BookFormat = 'mobi' | 'fb2' | 'pdf' | 'epub';

Methods

searchBooks(text: string, limit?: number): Promise<Book[]>

Search for books by title or content.

  • text - Search query
  • limit - Maximum number of results (default: 20)

searchByAuthor(text: string, limit?: number): Promise<Book[]>

Search for books by author name.

  • text - Author name to search for
  • limit - Maximum number of results (default: 10)

getBookInfo(id: number): Promise<BookInfo | undefined>

Get detailed information about a specific book.

  • id - Book ID

downBook(id: string, format?: BookFormat): Promise<BookFile>

Download a book file.

  • id - Book ID
  • format - File format (default: 'mobi')

getUrl(id: string, format?: BookFormat): string

Generate download URL for a book.

  • id - Book ID
  • format - File format (default: 'mobi')

Examples

Complete Example

import { 
  searchBooks, 
  searchByAuthor, 
  getBookInfo, 
  downBook 
} from 'flibusta-api';

async function example() {
  try {
    // Search for books
    const books = await searchBooks('fantasy', 5);
    
    if (books.length > 0) {
      const book = books[0];
      console.log(`Found: ${book.title} by ${book.author}`);
      
      // Get detailed info
      const info = await getBookInfo(book.id);
      if (info) {
        console.log(`Description: ${info.description}`);
        console.log(`Genres: ${info.genres.map(g => g.title).join(', ')}`);
      }
      
      // Download the book
      const file = await downBook(book.id.toString(), 'epub');
      console.log(`Downloaded: ${file.fileName}`);
    }
  } catch (error) {
    console.error('Error:', error);
  }
}

example();

Error Handling

import { downBook } from 'flibusta-api';

try {
  const file = await downBook('invalid-id', 'epub');
} catch (error) {
  if (error.message.includes('unavailable')) {
    console.log('Book is not available for download');
  } else {
    console.error('Unexpected error:', error);
  }
}

Development

Building

npm run build

Testing

npm test

Linting

npm run lint

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Legal Notice

This library is for educational and research purposes only. Please respect copyright laws and support authors by purchasing books legally. The authors of this library are not responsible for any misuse.

License

MIT © Mykyta Matsapura