Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ratakondalaarun/tmdb_api

Dart client library for themoviedb.org(TMDB) API
https://github.com/ratakondalaarun/tmdb_api

dart dart-package dartlang flutter hacktoberfest movie-api pub themoviedb tmdb tmdb-api tmdb-client-library tv-api

Last synced: about 1 month ago
JSON representation

Dart client library for themoviedb.org(TMDB) API

Awesome Lists containing this project

README

        

# tmdb_api

[![Dart Code Analysis](https://github.com/RatakondalaArun/tmdb_api/actions/workflows/analysis.yml/badge.svg)](https://github.com/RatakondalaArun/tmdb_api/actions/workflows/analysis.yml)
[![CI](https://github.com/RatakondalaArun/tmdb_api/actions/workflows/ci.yml/badge.svg)](https://github.com/RatakondalaArun/tmdb_api/actions/workflows/ci.yml)
[![pub package](https://img.shields.io/pub/v/tmdb_api?color=dark%20green&include_prereleases&label=pub%20package&logo=dart)](https://pub.dartlang.org/packages/tmdb_api)
[![style: lint](https://img.shields.io/badge/style-lint-4BC0F5.svg)](https://pub.dev/packages/lint)



A TheMovieDatabase client library for dart.
To know more about TMDB visit [*offical site*](https://www.themoviedb.org/)

## Getting started

1) **Adding as dependencies**

[Pub.dev's installation guide](https://pub.dev/packages/tmdb_api#-installing-tab-)

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

```yaml
dependencies:
tmdb_api: latest //visit tmdb for latest version number
```

2) **Import it**

Now in your Dart code, you can use:

```dart
import 'package:tmdb_api/tmdb_api.dart';
```

3) **Create Instance**

Now you need to create instance for `TMDB` and `ApiKeys` with your api keys.

```dart
final tmdbWithCustomLogs = TMDB( //TMDB instance
ApiKeys('Your API KEY', 'apiReadAccessTokenv4'),//ApiKeys instance with your keys,
);
```

4) **Configuring console logs**

There are 3 logconfigs presets avaliable.

- `ConfigLogger.showAll()`: development use.
- `ConfigLogger.showRecommended()`: development use.
- `ConfigLogger.showNone()`: production use.

You can add any off this presets to `logConfig` named parameter of `TMDB` instance
**Custom Logs**

```dart
final tmdbWithCustomLogs = TMDB(
ApiKeys('Your API KEY', 'apiReadAccessTokenv4'),
logConfig: ConfigLogger(
showLogs: true,//must be true than only all other logs will be shown
showErrorLogs: true,
),
);
```

## Example

For getting Trending movies

```dart
Map result = await tmdb.v3.trending.getTrending(mediaType = MediaType.all,timeWindow = TimeWindow.day);
```

### Custom Dio instance

```dart
final tmdbWithCustomLogs = TMDB(
ApiKeys('Your API KEY', 'apiReadAccessTokenv4'),
dio:Dio()// your own dio instance
);
```

### Setting Default api data language

```dart
final tmdbWithCustomLogs = TMDB(
ApiKeys('Your API KEY', 'apiReadAccessTokenv4'),
defaultLanguage:'en-US'// sets default language for all supported endpoints
);
```

### Adding Interceptors

```dart
final tmdbWithCustomLogs = TMDB(
ApiKeys('Your API KEY', 'apiReadAccessTokenv4'),
interceptors:Interceptors()..add(/*your interceptor*/)
);
```

or

```dart
final customDio = Dio();
customDio.interceptors.add(/*your interceptor*/)

final tmdbWithCustomLogs = TMDB(
ApiKeys('Your API KEY', 'apiReadAccessTokenv4'),
dio:dio
);
```

note:*Use interceptors only when you are not using a custom `Dio` instance*.

## For more API documentation

visit [offical API documentation](https://developers.themoviedb.org/3/getting-started/introduction)