> **Disclaimer**: This package is only created as an example of a search tool for Flibusta. If you like to read books - buy them legally.
npm install 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.
- ๐ 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
``bash`
npm install flibusta-api
`typescript
import { searchBooks } from 'flibusta-api';
// Search for books by title or content
const books = await searchBooks('Harry Potter', 10);
console.log(books);
// Returns: Book[]
`
`typescript
import { searchByAuthor } from 'flibusta-api';
// Search for books by a specific author
const books = await searchByAuthor('Tolkien', 5);
console.log(books);
// Returns: Book[]
`
`typescript
import { getBookInfo } from 'flibusta-api';
// Get detailed information about a specific book
const bookInfo = await getBookInfo(123456);
console.log(bookInfo);
// Returns: BookInfo | undefined
`
`typescript
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);
`
#### Book`typescript`
type Book = {
id: number;
title: string;
author: string;
link: string;
sendLink: string;
};
#### BookInfo`typescript`
type BookInfo = {
id: number;
title: string;
author: string;
genres: BookGenres[];
description?: string;
};
#### BookFile`typescript`
interface BookFile {
id: string;
file: Buffer;
fileName: string;
filePath?: string;
}
#### BookFormat`typescript`
type BookFormat = 'mobi' | 'fb2' | 'pdf' | 'epub';
#### searchBooks(text: string, limit?: number): Promise
Search for books by title or content.
- text - Search querylimit
- - Maximum number of results (default: 20)
#### searchByAuthor(text: string, limit?: number): Promise
Search for books by author name.
- text - Author name to search forlimit
- - Maximum number of results (default: 10)
#### getBookInfo(id: number): Promise
Get detailed information about a specific book.
- id - Book ID
#### downBook(id: string, format?: BookFormat): Promise
Download a book file.
- id - Book IDformat
- - File format (default: 'mobi')
#### getUrl(id: string, format?: BookFormat): string
Generate download URL for a book.
- id - Book IDformat
- - File format (default: 'mobi')
`typescript
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});Description: ${info.description}
// Get detailed info
const info = await getBookInfo(book.id);
if (info) {
console.log();Genres: ${info.genres.map(g => g.title).join(', ')}
console.log();Downloaded: ${file.fileName}
}
// Download the book
const file = await downBook(book.id.toString(), 'epub');
console.log();
}
} catch (error) {
console.error('Error:', error);
}
}
example();
`
`typescript
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);
}
}
`
`bash`
npm run build
`bash`
npm test
`bash`
npm run lint
1. Fork the repository
2. Create your feature branch (git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature'
3. Commit your changes ()git push origin feature/amazing-feature`)
4. Push to the branch (
5. Open a Pull Request
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.