Giter VIP home page Giter VIP logo

youtube_api's Introduction

YouTube API Client (youtube_api_client)

Forked (all restructured and improved) from youtube_api

A Flutter plugin for fetching interacting with YouTube Server to fetch data using API. Supports iOS and Android.

Features:

  • Search Video, Playlist, Channel on YouTube (query by keywords or by ID)
  • Get Trending Videos based on region code.

Usage

To use this plugin, add youtube_api_client as a dependency in your pubspec.yaml file.

Complete Example Code

Example

static String key = "YOUR_API_KEY";
final youtube = YoutubeApi(_key);
List<ApiResult> result = [];

Search for videos, channels and playlists

String query = "Flutter";
result = await youtube.search(query);
// data which are available in result is typed as in the example shown below

By default the search options are like the following:

SearchOptions options = const SearchOptions(
      type: ResultType.values,
      order: Order.relevance,
      videoDuration: VideoDuration.any,
    )

But you can customize them changing the parameter options. For example, if you want to get only results for channels, you can specify like so:

SearchOptions(type: ResultType.channel)

To get Trending videos in your Country-

regionCode='YOUR_COUNTRY_REGION_CODE(apha-2)';
result = await youtube.getTrends(regionCode);
//make sure you assign alpha-2 region code

To get results by id use searchVideosById, searchChannelsById, and searchPlaylistsById.

result = await youtube.searchVideosById(idList);

You can find your Country Region Code here

By default, it retrieves only the "snippet" data, which has enough information for most of the cases.

For example the snippet for a video contains:

  1. title (String)
  2. description (String)
  3. publish date (DateTime)
  4. channel ID (String)
  5. channel title (String)
  6. thumbnails (Map<ThumbnailResolution, Thumbnail> - custom classes)
  7. video category (Category - enum)
  8. tags (List)
  9. default language (String)
  10. defaultAudioLanguage (String)
  11. live broadcast content (LiveBroadcastContent - enum)

If you need more information from the API, you can add other parts in the query. For now it has only the part "snippet" and "content details" (containing: duration, dimension, definition, caption, licensed content, and projection). The original API has lots more of information, so you are welcome to help implementing those making pull requests.

Motivation

The original package seems to be abandoned. I improved a lot its code, making it more typed, and added more features.

youtube_api's People

Contributors

nitishk72 avatar hyungtaecf avatar cvadityaflipkart avatar apanjwani0 avatar brammittendorff avatar kaushikb1996 avatar rajshreeyoga avatar sahilkr24 avatar udiedrichsen avatar solid-vovabeloded avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.