This package facilitates communication with The One API, providing the user with data about The Lord of the Rings:
- Books
- Chapters
- Characters
- Movies
- Quotes
The respective requests may be further specified by providing:
- Pagination
- Sorting
- Filters
For most requests you will need an API access key which can be easily obtained here: https://the-one-api.dev/sign-up
Before making any requests create an instance of LotrApi
using your API access key:
var lotrApi = LotrApi(
apiKey: 'INSERT_YOUR_API_ACCESS_KEY_HERE',
);
If you do not provide an API access key then you will only be able to call the /book endpoint.
In order to retrieve data about all books:
Response<Book> response = await lotrApi.getBooks();
The actual list of items is always stored in the docs
attribute:
List<Book> books = response.docs;
The Response holds additional information such as the total number of items.
You can also directly get a specific book by providing its ID:
String firstBookId = books.first.id;
Book? firstBook = await lotrApi.getBook(
id: firstBookId,
);
Response<Chapter> chapters = await lotrApi.getChapters();
Response<Character> response = await lotrApi.getCharacters();
Response<Movie> response = await lotrApi.getMovies();
Response<Quote> quotes = await lotrApi.getQuotes();
Response<Quote> quotes = await lotrApi.getCharacterQuotes(
characterId: characterId, //TODO provide the character's ID
);
Response<Quote> quotes = await lotrApi.getMovieQuotes(
movieId: movieId, //TODO provide the movie's ID
);
Response<Quote> quotes = await lotrApi.getQuotes(
pagination: Pagination(
limit: 10,
offset: 2,
page: 2,
),
);
Response<Quote> quotes = await lotrApi.getQuotes(
sorting: QuoteSortings.byDialogAsc,
);
You may also apply multiple filters for each attribute, e.g.:
Response<Movie> response = await lotrApi.getMovies(
nameFilters: [
Exists(),
],
budgetInMillionsFilters: [
GreaterThanOrEquals(100),
LessThan(250),
],
);
Available filters are:
Matches
/NotMatches
Includes
/Excludes
Exists
/NotExists
MatchesRegex
/NotMatchesRegex
Equals
/NotEquals
LessThan
/GreaterThan
LessThanOrEquals
/GreaterThanOrEquals
Check the example folder for more examples.
If you like this project, please support by starring the Github repository.
In case you discover a bug or have a feature request, feel free to create an issue there.