This is a Golang wrapper for working with TMDb API. It aims to support version 3.

Overview

Build Status Build status Coverage Status Go Report Card GoDoc GitHub tag (latest SemVer) GitHub license

This is a Golang wrapper for working with TMDb API. It aims to support version 3.

An API Key is required. To register for one, head over to themoviedb.org.

This product uses the TMDb API but is not endorsed or certified by TMDb.

Requirements

  • Go 1.13.x or higher. We aim to support the latest supported versions of go.

Installation

go get -u github.com/cyruzin/golang-tmdb

Usage

To get started, import the tmdb package and initiate the client:

import "github.com/cyruzin/golang-tmdb"

tmdbClient, err := tmdb.Init(os.GetEnv("YOUR_APIKEY"))
if err != nil {
    fmt.Println(err)
}

// OPTIONAL: Setting a custom config for the http.Client.
// The default timeout is 10 seconds. Here you can set other
// options like Timeout and Transport.
customClient := http.Client{
    Timeout: time.Second * 5,
    Transport: &http.Transport{
        MaxIdleConns: 10,
        IdleConnTimeout: 15 * time.Second,
    }
}

tmdbClient.SetClientConfig(customClient)

// OPTIONAL: Enable this option if you're going to use endpoints
// that needs session id.
//
// You can read more about how this works:
// https://developers.themoviedb.org/3/authentication/how-do-i-generate-a-session-id
tmdbClient.SetSessionID(os.GetEnv("YOUR_SESSION_ID"))

// OPTIONAL (Recommended): Enabling auto retry functionality.
// This option will retry if the previous request fail.
tmdbClient.SetClientAutoRetry()

movie, err := tmdbClient.GetMovieDetails(297802, nil)
if err != nil {
 fmt.Println(err)
}

fmt.Println(movie.Title)

With optional params:

import "github.com/cyruzin/golang-tmdb"

tmdbClient, err := tmdb.Init(os.GetEnv("YOUR_APIKEY"))
if err != nil {
    fmt.Println(err)
}

options := map[string]string{
  "language": "pt-BR",
  "append_to_response": "credits,images",
}

movie, err := tmdbClient.GetMovieDetails(297802, options)
if err != nil {
 fmt.Println(err)
}

fmt.Println(movie.Title)

Helpers:

Generate image and video URLs:

import "github.com/cyruzin/golang-tmdb"

tmdbClient, err := tmdb.Init(os.GetEnv("YOUR_APIKEY"))
if err != nil {
    fmt.Println(err)
}

options := map[string]string{
 "append_to_response": "videos",
}

movie, err := tmdbClient.GetMovieDetails(297802, options)
if err != nil {
 fmt.Println(err)
}

fmt.Println(tmdb.GetImageURL(movie.BackdropPath, tmdb.W500))
// Output: https://image.tmdb.org/t/p/w500/bOGkgRGdhrBYJSLpXaxhXVstddV.jpg
fmt.Println(tmdb.GetImageURL(movie.PosterPath, tmdb.Original))
// Ouput: https://image.tmdb.org/t/p/original/bOGkgRGdhrBYJSLpXaxhXVstddV.jpg

for _, video := range movie.MovieVideosAppend.Videos.MovieVideos.Results {
   if video.Key != "" {
	 fmt.Println(tmdb.GetVideoURL(video.Key))
     // Output: https://www.youtube.com/watch?v=6ZfuNTqbHE8
   }
}

For more examples, click here.

Performance

Getting Movie Details:

Iterations ns/op B/op allocs/op
19 60886648 60632 184

Multi Search:

Iterations ns/op B/op allocs/op
16 66596963 107109 608

Contributing

To start contributing, please check CONTRIBUTING.

Tests

For local testing, create a environment variable called "APIKey" and enter your TMDb key. Check the "tmdb_test.go" file for more details.

License

MIT

Comments
  • Add missing fields

    Add missing fields

    Description

    Dependencies

    Temporary fixes

    • Remove GenreIDs, ID and VoteCount from CreditsDetails and FindByID

    These fields should be converted to int64.
    Non-breaking because GetCreditDetails and GetFindByID (person) never worked to begin with.

    CertificationMovie

    • Add CA_QC, DK, HU, IT, LT, MY, NO, RU and SE (not documented)

    CertificationTV

    • Add CA_QC, ES, HU, LT, NL, PH, PT and SK (not documented)

    ConfigurationCountries

    • Add NativeName (not documented)

    CreditsDetails

    • Add Adult, OriginalTitle, ReleaseDate, Title and Video (movie only, documented here)
    • Add omitempty option to FirstAirDate, Name, OriginalName, OriginCountry, Episodes and Seasons (TV only)

    FindByID / ListDetails

    • Add FirstAirDate, Name, OriginalName and OriginCountry (TV only, documented here / not documented)
    • Add omitempty option to Adult, OriginalTitle, ReleaseDate, Title and Video (movie only)

    Type of change

    • [x] Bug fix (non-breaking change which fixes an issue)
    • [x] New feature (non-breaking change which adds functionality)

    How Has This Been Tested?

    Tested locally.

    Checklist:

    • [x] My code follows the style guidelines of this project
    • [x] I have performed a self-review of my own code
    • [x] I have commented my code, particularly in hard-to-understand areas
    • [ ] I have made corresponding changes to the documentation
    • [x] My changes generate no new warnings
    • [x] I have added tests that prove my fix is effective or that my feature works
    • [x] New and existing unit tests pass locally with my changes
    • [ ] Any dependent changes have been merged and published in downstream modules
    opened by rqphqel 6
  • [feature] remove embedded structure

    [feature] remove embedded structure

    Is your feature request related to a problem? Please describe. Most (all?) results structure are embedded and not exportable, which made impossible to merge all results from many pages to one list

    Describe the solution you'd like Export 'results' structure

    Describe alternatives you've considered I've to create a list from the parent structure and do a double 'for' to iterate over all results

    Additional context For example https://github.com/cyruzin/golang-tmdb/blob/993aeec9e091f099e2455ee10b4dd2d5c7e02a84/movies.go#L800

    enhancement 
    opened by Eraac 6
  • Fix JSON meta data of production country ISO code

    Fix JSON meta data of production country ISO code

    Description

    Fixes the typo in json metada of Iso3166_1 for ProductionCountries in MovieDetails

    Fixes #14

    Type of change

    • [x] Bug fix (non-breaking change which fixes an issue)

    How Has This Been Tested?

    Yes

    Checklist:

    • [X] My code follows the style guidelines of this project
    • [X] I have performed a self-review of my own code
    • [ ] I have commented my code, particularly in hard-to-understand areas
    • [ ] I have made corresponding changes to the documentation
    • [X] My changes generate no new warnings
    • [ ] I have added tests that prove my fix is effective or that my feature works
    • [X] New and existing unit tests pass locally with my changes
    • [ ] Any dependent changes have been merged and published in downstream modules
    bug 
    opened by cevatbarisyilmaz 4
  • function GetMovieChanges yield's weird string after marshal

    function GetMovieChanges yield's weird string after marshal

    when GetMovieChanges or append_to_resonse used with changes as one of value the changes struct after marshal always has same weird string image

    On left I'm printing value before marshal and it's fine but after marshal result is weird string doesn't matter what movie I fetch

    image Different movie same string after marshal

    opened by shamith16 2
  • Struggling to get ConfigurationCountries

    Struggling to get ConfigurationCountries

    Hey @cyruzin, I am having problems getting the ConfigurationCountries by calling GetConfigurationCountries. It seems like the return type is *ConfigurationCountries which is a pointer to a []struct. How can I iterate over that struct and extract the fields(Iso3166_1 and EnglishName)? It is also likely that this is obvious and I am just a bit dumb right know 😅

    Would be great if you can give me an example. Thanks Tim 😊

    opened by tim-koehler 2
  • Ability to modify http.Client or at least http.Client.Transport

    Ability to modify http.Client or at least http.Client.Transport

    Hello, it would be very useful if you can modify the http.Client inside the Client struct. For example for replacing http.Client.Transport to get your own response caching or rate limiting. Or changing timeouts. I did not submit a PR because there are multiple ways to do it (exporting Client.http, adding a parameter to Init(), adding a new method(s) to Client...). But the change should be trivial.

    Thank you.

    enhancement 
    opened by rkollar 2
  • Extract MovieImage struct

    Extract MovieImage struct

    Description

    Simple type name so it's easier to deal with images response

    Type of change

    Please delete options that are not relevant.

    • [x] New feature (non-breaking change which adds functionality)

    How Has This Been Tested?

    Please describe the tests that you ran to verify your changes.

    Checklist:

    • [x] My code follows the style guidelines of this project
    • [x] I have performed a self-review of my own code
    • [x] I have commented my code, particularly in hard-to-understand areas
    • [x] I have made corresponding changes to the documentation
    • [x] My changes generate no new warnings
    • [ ] I have added tests that prove my fix is effective or that my feature works
    • [x] New and existing unit tests pass locally with my changes
    • [ ] Any dependent changes have been merged and published in downstream modules
    enhancement 
    opened by tmm1 1
  • Add missing fields

    Add missing fields

    Description

    MovieCredits

    • Add Adult, KnownForDepartment, OriginalName and Popularity (documented here)

    MovieImages

    • Add Logos (not documented)

    MovieTranslations

    • Add Runtime (mentioned here)

    NetworkDetails

    • Add LogoPath (documented here)

    PersonMovieCredits

    • Add Order (not documented)

    MovieVideosResults

    • Add Official and PublishedAt (documented here)

    SearchCompaniesResults

    • Add OriginCountry (documented here)

    SearchPeopleResults

    • Add Gender and KnownForDepartment (documented here)
    • Add FirstAirDate, Name, OriginalName and OriginCountry (TV only, documented here)
    • Add omitempty option to Adult, OriginalTitle, ReleaseDate, Title and Video (movie only)

    ReviewDetails

    • Add AuthorDetails, CreatedAt and UpdatedAt (documented here)

    Documentation

    • Fix documentation for GetGenreMovieList, GetPersonTranslations and GetReviewDetails

    Type of change

    • [x] New feature (non-breaking change which adds functionality)

    How Has This Been Tested?

    Tested locally.

    Checklist:

    • [x] My code follows the style guidelines of this project
    • [x] I have performed a self-review of my own code
    • [x] I have commented my code, particularly in hard-to-understand areas
    • [ ] I have made corresponding changes to the documentation
    • [x] My changes generate no new warnings
    • [ ] I have added tests that prove my fix is effective or that my feature works
    • [x] New and existing unit tests pass locally with my changes
    • [ ] Any dependent changes have been merged and published in downstream modules
    opened by rqphqel 1
  • Add tagline to movie and tv translations

    Add tagline to movie and tv translations

    Description

    Not documented but translations for movie and tv also have the tagline field.

    Type of change

    • [X] New feature (non-breaking change which adds functionality)

    How Has This Been Tested?

    Tested locally to confirm new fields work.

    Checklist:

    • [X] My code follows the style guidelines of this project
    • [X] I have performed a self-review of my own code
    • [ ] I have commented my code, particularly in hard-to-understand areas
    • [ ] I have made corresponding changes to the documentation
    • [X] My changes generate no new warnings
    • [ ] I have added tests that prove my fix is effective or that my feature works
    • [X] New and existing unit tests pass locally with my changes
    • [ ] Any dependent changes have been merged and published in downstream modules
    opened by cevatbarisyilmaz 1
  • Add WatchProviders

    Add WatchProviders

    Description

    • Adding functions for new endpoints providing lists for watch providers and regions. https://developers.themoviedb.org/3/watch-providers

    Type of change

    • [x] New feature (non-breaking change which adds functionality)

    How Has This Been Tested?

    • Added tests to the suit

    Checklist:

    • [x] My code follows the style guidelines of this project
    • [x] I have performed a self-review of my own code
    • [x] I have commented my code, particularly in hard-to-understand areas
    • [x] I have made corresponding changes to the documentation
    • [x] My changes generate no new warnings
    • [x] I have added tests that prove my fix is effective or that my feature works
    • [x] New and existing unit tests pass locally with my changes
    • [x] Any dependent changes have been merged and published in downstream modules
    opened by tim-koehler 1
  • Watch/providers for movies and TV shows

    Watch/providers for movies and TV shows

    Description

    • Separate methods for getting watch/providers (a list of the availabilities per country by provider) for movies and TV shows
    • Ability to append watch/providers property for MovieDetails and TVDetails objects

    Type of change

    New feature (non-breaking change which adds functionality)

    How Has This Been Tested?

    You can call GetMovieWatchProviders, GetTVWatchProviders, GetMovieDetails (with watch/providers value in the append_to_response option), GetTVDetails (with watch/providers value in the append_to_response option) methods to verify my changes.

    Checklist:

    • [x] My code follows the style guidelines of this project
    • [x] I have performed a self-review of my own code
    • [x] I have commented my code, particularly in hard-to-understand areas
    • [x] I have made corresponding changes to the documentation
    • [x] My changes generate no new warnings
    • [x] I have added tests that prove my fix is effective or that my feature works
    • [x] New and existing unit tests pass locally with my changes
    • [x] Any dependent changes have been merged and published in downstream modules
    enhancement 
    opened by dimuska139 1
Owner
Cyro Dubeux
Father, husband, runner and coder.
Cyro Dubeux
Authorization can be hard, and this project aims to be simple solution to general authz problems.

racl (rest access control lists) Motivation Authorization can be hard, and this project aims to be simple solution to general authz problems. Mainly,

Brent Soles 0 Nov 9, 2021
Golang API for Whatsapp API MultiDevice version

Go Whatsapp API Multi Device Version Required Mac OS: brew install vips export C

Aldino Kemal 35 Sep 25, 2022
Golang module for working with VK API

VK SDK for Golang VK SDK for Golang ready implementation of the main VK API functions for Go. Russian documentation Features Version API 5.131. API 40

Daniil Suvorov 139 Oct 1, 2022
A GoLang wrapper for Politics & War's API. Forego the hassle of accessing the API directly!

A GoLang wrapper for Politics & War's API. Forego the hassle of accessing the API directly!

null 1 Mar 5, 2022
A GO API library for working with Marathon

Go-Marathon Go-marathon is a API library for working with Marathon. It currently supports Application and group deployment Helper filters for pulling

Rohith Jayawardene 197 Sep 27, 2022
A Go client for working with the Cryptohopper API

GoGoCryptohopper A Go client for working with the Cryptohopper API Structure of the client Request/Response The definitions for request and response f

Cryptwire 0 Dec 23, 2021
The NVD API is an unofficial Go wrapper around the NVD API.

NVD API The NVD API is an unofficial Go wrapper around the NVD API. Supports: CVE CPE How to use The following shows how to basically use the wrapper

Lucas TESSON 5 Jul 20, 2022
A Wrapper Client for Google Spreadsheet API (Sheets API)

Senmai A Wrapper Client for Google Spreadsheet API (Sheets API) PREPARATION Service Account and Key File Create a service account on Google Cloud Plat

ytnobody / satoshi azuma 0 Nov 5, 2021
Simple golang airtable API wrapper

Golang Airtable API A simple #golang package to access the Airtable API. Table of contents Golang Airtable API Table of contents Installation Basic us

mehanizm 45 Sep 27, 2022
⚡️ SharePoint authentication, HTTP client & fluent API wrapper for Go (Golang)

Gosip - SharePoint authentication, HTTP client & fluent API wrapper for Go (Golang) Main features Unattended authentication using different strategies

Andrew Koltyakov 83 Sep 27, 2022
A small, fast, reliable pastemyst API wrapper written in Golang

A small, fast, reliable pastemyst API wrapper written in Golang. Official pastemyst API docs found here.

null 11 Nov 18, 2021
SpamProtection-Go is an Official golang wrapper for Intellivoid SpamProtection API

SpamProtection-Go is an Official golang wrapper for Intellivoid SpamProtection API, which is fast, secure and requires no additional packages to be installed.

Intellivoid 0 Feb 26, 2022
Unofficial Anilist.co GraphQL API wrapper for GoLang.

anilistWrapGo Unofficial Anilist.co GraphQL API wrapper for GoLang. Examples All examples are present as tests in test directory. Below are a few snip

ダンクデル (Sayan Biswas) 14 Aug 31, 2022
Pterodactyl API wrapper written in Golang

WARNING That repository isn't available for production environment. Many endpoints aren't yet implemented. Be careful if you are using that module. pt

Luiz Otávio de Farias Correa 3 Mar 28, 2022
A Wrapper of the Piston API in Golang

Go-Piston! This is a Go wrapper for working with the Piston API. It supports both the endpoints, namely runtimes and execute, mentioned here. ?? Insta

null 8 Aug 28, 2022
Golang wrapper for the FiveM natives API

Golang wrapper for the FiveM natives API

normalM 3 Jun 28, 2022
Golang API wrapper of OkEX

A complete golang wrapper for Okex V5 API. Pretty simple and easy to use. For more info about Okex V5 API read here.

Amir 33 Sep 20, 2022
Golang wrapper for the Sylviorus antispam API for telegram

Syl-Go Golang wrapper for the Sylviorus antispam API for telegram package test

Pranav Ajay 1 Jan 2, 2022
Gocaptcha - An API wrapper for popular captcha solvers such as AntiCaptcha and 2Captcha in Golang

An API wrapper for popular captcha solvers such as AntiCaptcha and 2Captcha in Golang

null 20 Sep 22, 2022