Tenor

Pub Package License: MIT Issue Forks Stars

Donate

Donate

Fetch, Search GIF more easily and customised manner from Tenor

Table of Contents

Lets Get Started

1. Depend on it

Add this to your package's pubspec.yaml file:

dependencies:
  tenor:

2. Install it

You can install packages from the command line:

with pub:

$  pub get

with Flutter:

$  flutter packages get

3. Import it

Now in your Dart code, you can use:

import 'package:tenor/tenor.dart';

Usage

Initialize Tenor

Initialize Tenor library

var api = Tenor(apiKey: 'WVWVKIKO0J5W');

Fetch some Trending GiIF

//requestTrendingGIF({int limit = 1, String contentFilter = ContentFilter.off, String mediaFilter = MediaFilter.minimal});

// fetch trending GIF
TenorResponse res = await api.requestTrendingGIF(limit: 5);
res.results.forEach((tenorResult) {
  var title = tenorResult.title;
  var media = tenorResult.media;
  print('$title: gif      : ${media?.gif?.previewUrl?.toString()}');
});

Search for GIF

Search for the GIF

//searchGIF(String search, {int limit = 1, String contentFilter = ContentFilter.off, String mediaFilter = MediaFilter.minimal});

TenorResponse res = await api.searchGIF('subscribe mrbeast', limit: 5);
res.results.forEach((tenorResult) {
  var title = tenorResult.title;
  var media = tenorResult.media;
  print('$title: gif      : ${media?.gif?.previewUrl?.toString()}');
});
Donate

Fetching Options

keydescription
limiteg. limit the number of GIF to be fetched. limit can vary from 1 to 50
contentFilterdefault: low. (values: off, low, medium, high) specify the content safety filter level. eg. contentFilter: ContentFilter.low
mediaFilterdefault: minimal. (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

Fetch Next Set of GIF Response

fetchNext() is used to get next set of response for the current query

// fetchNext({int limit = 1});

// here the fetchNext function is used to call next set of GIF for the current response
TenorResponse nextResult = await res.fetchNext();
print('next results');
nextResult.results.forEach((tenorResult) {
  var title = tenorResult.title;
  var media = tenorResult.media;
  print('$title: gif      : ${media?.gif?.previewUrl?.toString()}');
});

Fetching Next Options

keydescription
limiteg. limit the number of GIF to be fetched. limit can vary from 1 to 50

Features coming in next version

On-going implementation for future:

  • Some more Functions
  • Fetch Categories
  • Download GIF

Libraries

tenor