Encapsulates the MCU REST API for easy integration with your Flutter App
Features
- simple authentication, the TS value is calculated in the Interceptor based on the API keys
- All endpoints including their relations are managed in endpoint objects
- Query parameters can be easily passed as a map
- All existing image variations are available as an enumeration
Getting started
First of all you need the API keys, you can get them on the developer page. Please note and consider the terms of use of the Marvel API.
Usage
Get a list of characters
// prepare
McuApi api = McuApi(
publicApiKey: 'YOUR PUBLIC API KEY',
privateApiKey: 'YOUR PRIVATE API KEY'
);
...
// get hte the first 20 characters
final ApiResponse<CharacterDataContainer> response = await api.characters.fetch();
// get the next 20 characters with query parameter
final ApiResponse<CharacterDataContainer> response = await api.characters.fetch(args: { 'offset': 20 });
// get a character based on the Id
final ApiResponse<CharacterDataContainer> response = await api.characters.fetch(id: 4711);
Get Relations from Character
// get a comic list by character
final ApiResponse<CharacterDataContainer> response = await api.characters.comics(4711);
// get a event list from character
final ApiResponse<CharacterDataContainer> response = await api.characters.events(4711);
...
The available relations are mapped in the respective endpoints.
get image variation
final imageUrl = response.thumbnail?.getImageVariant(ImageSizes.standard_large);
Additional information
It's worth taking a look at the API How-Tos and the Interactive Documentation of the Marvel API.