annas_archive_api 0.0.7 annas_archive_api: ^0.0.7 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';
import 'package:annas_archive_api/src/models/search_response.dart';
Future<void> main() async {
const searchRequest = SearchRequest(
query: 'harry potter',
author: 'rowling',
categories: [Category.fiction],
formats: [Format.epub, Format.pdf],
skip: 1,
limit: 10,
language: Language.french,
sort: SortOption.smallest,
);
// Finds books from Anna's Archive.
final SearchResponse response = await AnnaApi().find(searchRequest);
for (final Book book in response.books) {
print(book.title);
}
// Get download links for a book.
final List<String> downloadLinks =
await AnnaApi().getDownloadLinks(response.books.first.md5);
for (final String link in downloadLinks) {
print(link);
}
const collectionRequest = CollectionRequest(
type: Collection.goodReads,
url:
'https://www.goodreads.com/review/list/145381477-alvyn-fasuyi?ref=nav_mybooks',
);
// Fetches a collection of books from GoodReads.
final List<Book> collection =
await AnnaApi().fetchCollection(collectionRequest);
for (final Book book in collection) {
print(book.title);
}
}