annas_archive_api 0.3.4 annas_archive_api: ^0.3.4 copied to clipboard
Anna's archive API is an easy to use SDK for interacting with the popular Anna's Archive Service. It provides a simple interface for fetching and parsing data from the service.
import 'package:annas_archive_api/annas_archive_api.dart';
Future<void> main() async {
// Finds books from Anna's Archive.
await AnnaApi()
.find(const SearchRequest(
query: 'harry potter',
author: 'rowling',
categories: [Category.fiction],
sources: [AnnaSource.zLibrary, AnnaSource.internetArchive],
formats: [Format.epub, Format.pdf],
skip: 1,
limit: 10,
language: Language.french,
sort: SortOption.smallest,
))
.then((response) async {
for (final Book book in response.books) {
print(book.title);
}
// Get download links for a book.
await AnnaApi()
.getDownloadLinks(response.books.first.md5)
.then((downloadLinks) {
for (final String link in downloadLinks) {
print(link);
}
});
});
// Finds journals from Anna's Archive.
await AnnaApi()
.findJournal(const SearchJournalRequest(
query: '',
skip: 1,
limit: 10,
language: Language.french,
sources: [AnnaSource.libgenLi],
sort: SortOption.newest,
))
.then((response) {
for (final Book book in response.books) {
print(book.title);
}
});
// Fetches a collection of books from GoodReads.
// const collectionUrl =
// 'https://www.goodreads.com/review/list/145381477-alvyn-fasuyi?ref=nav_mybooks';
// await AnnaApi()
// .fetchCollection(const CollectionRequest(
// type: Collection.goodReads, url: collectionUrl))
// .then((response) {
// for (final Book book in response) {
// print(book.title);
// }
// });
}