Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/finkmoritz/lotr_api
This package leverages communication with The One API (https://the-one-api.dev), providing the user with data about The Lord of the Rings (books and movies).
https://github.com/finkmoritz/lotr_api
api dart lord-of-the-rings lordoftherings
Last synced: about 2 months ago
JSON representation
This package leverages communication with The One API (https://the-one-api.dev), providing the user with data about The Lord of the Rings (books and movies).
- Host: GitHub
- URL: https://github.com/finkmoritz/lotr_api
- Owner: finkmoritz
- License: bsd-3-clause
- Created: 2022-01-31T14:37:02.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-09-16T05:06:58.000Z (over 2 years ago)
- Last Synced: 2024-10-14T09:27:16.657Z (3 months ago)
- Topics: api, dart, lord-of-the-rings, lordoftherings
- Language: Dart
- Homepage:
- Size: 57.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# The Lord of the Rings API
This package facilitates communication with [The One API](https://the-one-api.dev/), providing the user with data about
*The Lord of the Rings*:* Books
* Chapters
* Characters
* Movies
* QuotesThe respective requests may be further specified by providing:
* Pagination
* Sorting
* Filters## Prerequisites
For most requests you will need an API access key which can be easily obtained here:
https://the-one-api.dev/sign-up## Objects
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.*
### Book
In order to retrieve data about all books:
```
Response response = await lotrApi.getBooks();
```The actual list of items is always stored in the ```docs``` attribute:
```
List 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,
);
```### Chapter
```
Response chapters = await lotrApi.getChapters();
```### Character
```
Response response = await lotrApi.getCharacters();
```### Movie
```
Response response = await lotrApi.getMovies();
```### Quote
```
Response quotes = await lotrApi.getQuotes();Response quotes = await lotrApi.getCharacterQuotes(
characterId: characterId, //TODO provide the character's ID
);Response quotes = await lotrApi.getMovieQuotes(
movieId: movieId, //TODO provide the movie's ID
);
```## Pagination
```
Response quotes = await lotrApi.getQuotes(
pagination: Pagination(
limit: 10,
offset: 2,
page: 2,
),
);
```## Sorting
```
Response quotes = await lotrApi.getQuotes(
sorting: QuoteSortings.byDialogAsc,
);
```## Filtering
You may also apply multiple filters for each attribute, e.g.:
```
Response 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`## Examples
Check the [example](example) folder for more examples.
## Support
If you like this project, please support by starring the
[Github repository](https://github.com/finkmoritz/lotr_api).In case you discover a bug or have a feature request, feel free to create an issue there.