Fetch, Search GIF more easily and customised manner from Tenor
This library is MIT licensed, which means you can use it anywhere without any consent from justkawal, because we believe in Open-Source
Add this to your package's pubspec.yaml
file:
dependencies:
tenor: any
You can install packages from the command line:
with pub
:
$ pub get
with Flutter
:
$ flutter packages get
Now in your Dart
code, you can use:
import 'package:tenor/tenor.dart';
Initialize Tenor library
Tenor tenor = Tenor(apiKey: 'ApiKey');
Returns response containing a list of the current global trending GIFs. The trending stream is updated regularly throughout the day.
Important: limit
: 1 <= limit <= 50
// Future<TenorResponse> requestTrendingGIF({
// int limit = 20,
// ContentFilter contentFilter = ContentFilter.off,
// GifSize size = GifSize.all,
// MediaFilter mediaFilter = MediaFilter.minimal,
// })
Tenor tenor = Tenor(apiKey: 'Tenor Api');
// fetch trending Gif
TenorResponse res = await tenor.requestTrendingGIF(limit: 5);
res?.results?.forEach((TenorResult tenorResult) {
var title = tenorResult.title;
var media = tenorResult.media;
print('$title: gif : ${media?.gif?.previewUrl?.toString()}');
});
Returns response containing a list of the searched Gif from Tenor.
Important: limit
: 1 <= limit <= 50
// Future<TenorResponse> searchGIF(
// String search, {
// int limit = 20,
// ContentFilter contentFilter = ContentFilter.off,
// GifSize size = GifSize.all,
// MediaFilter mediaFilter = MediaFilter.minimal,
// })
Tenor tenor = Tenor(apiKey: 'Tenor Api');
// search Gif
TenorResponse? res = await tenor.searchGIF('universe', limit: 5);
res?.results?.forEach((TenorResult tenorResult) {
var title = tenorResult.title;
var media = tenorResult.media;
print('$title: gif : ${media?.gif?.previewUrl?.toString()}');
});
Get a randomized list of GIFs for a given search term. This differs from the search function which returns a rank ordered list of GIFs for a given search term.
Important: limit
: 1 <= limit <= 50
// Future<TenorResponse> randomGIF(
// String search, {
// int limit = 20,
// ContentFilter contentFilter = ContentFilter.off,
// GifSize size = GifSize.all,
// MediaFilter mediaFilter = MediaFilter.minimal,
// })
Tenor tenor = Tenor(apiKey: 'Tenor Api');
// random Gif
TenorResponse res = await tenor.randomGIF('universe', limit: 5);
res?.results?.forEach((TenorResult tenorResult) {
var title = tenorResult.title;
var media = tenorResult.media;
print('$title: gif : ${media?.gif?.previewUrl?.toString()}');
});
Search suggestions helps a user narrow their search or discover related search terms to find a more precise GIF. Results are returned in order of what is most likely to drive a share for a given term, based on historic user search and share behavior.
Important: limit
: 1 <= limit <= 50
// Future<List<String>> searchSuggestions(
// String search, {
// int limit = 20,
// })
Tenor tenor = Tenor(apiKey: 'Tenor Api');
// suggestions
List<String> suggestions = await tenor.searchSuggestions('universe', limit: 5);
Returns response containing a list of the current trending search terms. The list is updated Hourly by Tenor’s AI.
Important: limit
: 1 <= limit <= 50
// Future<List<String>> trendingSearch(
// int limit = 20,
// })
Tenor tenor = Tenor(apiKey: 'Tenor Api');
// trending search results
List<String> suggestions = await tenor.trendingSearch(limit: 5);
Returns response containing a list of completed search terms given a partial search term. The list is sorted by Tenor’s AI
and the number of results will decrease as Tenor’s AI
becomes more certain.
Important: limit
: 1 <= limit <= 50
// Future<List<String>> autoComplete(
// String search, {
// int limit = 20,
// })
Tenor tenor = Tenor(apiKey: 'Tenor Api');
// auto complete results
List<String> autoCompleted = await tenor.autoComplete('un', limit: 5);
Requests Categories
from tenor
// Future<List<TenorCategories>> requestCategories({
// ContentFilter contentFilter = ContentFilter.off,
// CategoryType categoryType = CategoryType.featured,
// })
Tenor tenor = Tenor(apiKey: 'Tenor Api');
// list of categories
List<TenorCategories> categories = await tenor.requestCategories();
key | description |
---|---|
limit | eg. limit the number of GIF to be fetched. limit can vary from 1 to 50 |
contentFilter | (values: off , low , medium , high ) specify the content safety filter level. eg. contentFilter: ContentFilter.low |
mediaFilter | (values: basic , minimal ) Reduce the Number of GIF formats returned in response. minimal- (tinygif, gif, and mp4) . basic- (nanomp4, tinygif, tinymp4, gif, mp4, and nanogif) eg. mediaFilter: MediaFilter.minimal |
size | GIFs with aspect ratios that fit with in the selected range. values: (all , wide , standard ), all - no constraints, wide - 0.42 <= aspect ratio <= 2.36, standard - .56 <= aspect ratio <= 1.78 |
fetchNext()
is used to get next set of response for the current query
// Future<TenorResponse> fetchNext({int limit = 20});
// here the fetchNext function is used to call next set of GIF which is sequenced after current response
TenorResponse firstSetResponse = await tenor.randomGIF('universe', limit: 5);
TenorResponse nextSetResponse = await firstSetResponse?.fetchNext();
nextSetResponse?.results?.forEach((tenorResult) {
var title = tenorResult.title;
var media = tenorResult.media;
print('$title: gif : ${media?.gif?.previewUrl?.toString()}');
});
key | description |
---|---|
limit | eg. limit the number of GIF to be fetched. limit can vary from 1 to 50 |