tmdb 0.0.2-alpha.1

  • Installing
  • Versions
  • 39


A (TMDB) library for Dart.


  • Access to all API methods
  • Support for both console (dart:io) and web (dart:html) applications
  • User authentication, either with a username and password (obtains new session ID) or with a previously obtained session ID
  • You need to provide your own API key


See the full documentation.


First import the proper library for the platform.

If your code is running on the Dart VM (where you'd use dart:io) then:

import 'package:tmdb/io.dart';

If your code runs on the browser (where you'd use dart:html) then:

import 'package:tmdb/html.dart';

With the library imported you can just create a new instance (providing your API key) and access all of its methods.

For example, a simple console application to get the top rated movies would look like this:

// Import the proper library
import 'package:tmdb/io.dart';

main() async {
  // Create a new TMDBApi instance
  TMDBApi tmdb = new TMDBApi('YOUR_API_KEY_HERE');

  // Get the top rated movies
  Map topRated = await tmdb.movies.getTopRated();

  // Loop through the results and print the title, year, and rating
  topRated['results'].forEach((v) {
    var title = v['title'];
    var year = DateTime.parse(v['release_date']).year;
    var rating = v['vote_average'].toStringAsFixed(1);
    print("$title ($year) * $rating/10");


If you already have a valid session ID for the user, you can just feed it to the library and start using any method that requires authentication:

// Create instance
TMDBApi tmdb = new TMDBApi('YOUR_API_KEY_HERE');

// Set the session ID
tmdb.authentication.sessionId = 'SESSION_ID_HERE';

// Get the user's information
var info = await tmdb.account.getInfo();

If you don't have a session ID for the user you want to authenticate you can easily obtain one using the login method.

// Create instance
TMDBApi tmdb = new TMDBApi('YOUR_API_KEY_HERE');

// Log in with a username and password
await tmdb.authentication.login('USERNAME_HERE', 'PASSWORD_HERE');

// The session ID is now stored in tmdb.authentication.sessionId
// so you can start using any API method.

// Get the user's information
var info = await tmdb.account.getInfo();

IMPORTANT: You should only use the login method once for each user because the API will generate a new session ID every time you do so. Once you have obtained it you should save it somewhere safe and feed it to the library whenever you need to (which is usually right after calling new TMDBApi()).

Futures vs async/await

The easiest way to call the API methods is using the async/await syntax provided by Dart, like on the examples above.

To use it you just need to add the async modifier to the function that will be calling the asynchronous methods from this library. Then, prefix the actual call with await.

printMovieInfo(id) async {
  var info = await tmdb.movies.getInfo(id);

Or even

printMovieInfo(id) async {
  print(await tmdb.movies.getInfo(id));

If for any reason you can't or don't want to use async/await, you can just use the Futures directly:

printMovieInfo(id) {
  tmdb.movies.getInfo(id).then((info) {

Features and bugs

Please file feature requests and bugs at the issue tracker.

Change Log

All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.


0.0.2-alpha.1 - 2015-12-18


  • CHANGELOG links.


  • Bump version number. Again. Because I screwed up earlier.

0.0.1-alpha.3 - 2015-12-18


  • Version format.

0.0.1-alpha2 - 2015-12-18


  • README formatting.

0.0.1-alpha1 - 2015-12-18


  • All API methods implemented but untested. Highly unstable.

1. Depend on it

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

  tmdb: "^0.0.2-alpha.1"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:tmdb/core.dart';

import 'package:tmdb/html.dart';

import 'package:tmdb/io.dart';
Version Uploaded Documentation Archive
0.0.2-alpha.1 Dec 18, 2015 Go to the documentation of tmdb 0.0.2-alpha.1 Download tmdb 0.0.2-alpha.1 archive
0.0.1-alpha2 Dec 18, 2015 Go to the documentation of tmdb 0.0.1-alpha2 Download tmdb 0.0.1-alpha2 archive
0.0.1-alpha1 Dec 18, 2015 Go to the documentation of tmdb 0.0.1-alpha1 Download tmdb 0.0.1-alpha1 archive
0.0.1-alpha.3 Dec 18, 2015 Go to the documentation of tmdb 0.0.1-alpha.3 Download tmdb 0.0.1-alpha.3 archive


This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • tool failures on Jan 21, 2018
  • Dart: 2.0.0-dev.15.0
  • pana: 0.10.0


Describes how popular the package is relative to other packages. [more]
19 / 100
Code health derived from static analysis. [more]
96 / 100
Reflects how tidy and up-to-date the package is. [more]
0 / 100
Overall score:
Weighted score of the above. [more]


Detected platforms: web

Multiple platform identified in libraries.


  • Fix lib/html.dart.

    Strong-mode analysis of lib/html.dart failed with the following error:

    line: 18 col: 13
    Invalid override. The type of 'TMDBApi.handleRequest' ('(Request) → Future<String>') isn't a subtype of 'TMDBApiCore.handleRequest' ('(dynamic) → Future<String>').

  • Fix lib/src/params.dart.

    Strong-mode analysis of lib/src/params.dart failed with the following error:

    line: 22 col: 3
    Invalid override. The type of '_Params.[]' ('(String) → dynamic') isn't a subtype of 'Map<dynamic, dynamic>.[]' ('(Object) → dynamic').

  • Fix further 1 Dart files.

    Similar analysis of the following files failed:

    • lib/io.dart
  • Fix issues reported by dartanalyzer.

    dartanalyzer reported 3 error(s) and 0 warning(s).

  • Package is pre-release.

    Pre-release versions should be used with caution, their API may change in breaking ways.

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.0.0 <2.0.0
http >=0.11.0 <0.12.0 0.11.3+16
Transitive dependencies
async 2.0.3
charcode 1.1.1
collection 1.14.5
http_parser 3.1.1
path 1.5.1
source_span 1.4.0
string_scanner 1.0.2
typed_data 1.1.5