themoviedb


Namethemoviedb JSON
Version 1.0.2 PyPI version JSON
download
home_pagehttps://github.com/leandcesar/themoviedb
SummaryA modern and easy to use API wrapper for The Movie Database (TMDb) API v3 written in Python
upload_time2024-07-23 02:08:50
maintainerNone
docs_urlNone
authorLeandro César
requires_python>=3.8
licenseMIT
keywords tmdb tmdb3 aiotmdb aiotmdb3 themoviedb themoviedb3 movie movies tv tv show tv shows
VCS
bugtrack_url
requirements aiohttp dacite requests
Travis-CI No Travis.
coveralls test coverage No coveralls.
            |Code Coverage| |PyPI Version| |Code style: black| |PyPI License|

themoviedb
==========

A modern and easy to use API wrapper for The Movie Database (TMDb) API v3
written in Python. Supports sync and async requests!

.. image:: https://github.com/leandcesar/themoviedb/blob/master/docs/assets/themoviedb.gif?raw=true
   :target: https://github.com/leandcesar/themoviedb
   :alt: themoviedb

Overview
========

The **themoviedb** is a synchronous and asynchronous wrapper, written in Python,
for The Movie Database (TMDb) API v3.

`The Movie Database (TMDb) <https://www.themoviedb.org>`__ is a
community built movie and TV database.

The `TMDb API <https://www.themoviedb.org/documentation/api>`__ service
is for those of you interested in using our movie, TV show or actor
images and/or data in your application.

A `TMDb user account <https://www.themoviedb.org/account/signup>`__ is
required to request an API key.

Getting started
===============

Requirements
------------

-  ``python`` (Python >=3.8)
-  ``pip`` (Python package manager)

Install
-------

The easiest way to install **themoviedb** is via ``pip``.

.. code-block:: shell

    pip install themoviedb[full]

Or only the sync version (with ``requests``).

.. code-block:: shell

    pip install themoviedb[sync]

Or only the async version (with ``aiohttp``).

.. code-block:: shell

    pip install themoviedb[async]

API Key
-------

You will need an API key to The Movie Database to access the API. To
obtain a key, follow these steps:

1. `Register <https://www.themoviedb.org/account/signup>`__ for and
   verify an account.
2. `Log <https://www.themoviedb.org/login>`__ into your account.
3. Select the `API section <https://www.themoviedb.org/settings/api>`__
   on left side of your account page.
4. Click on the link to generate a new API key and follow the
   instructions.

Usage
=====

Sync mode
---------

.. code:: python

    from themoviedb import TMDb

Async mode
----------

.. code:: python

    from themoviedb import aioTMDb

Configuration
-------------

Initialize a TMDb object and set your API Key, language and region.

.. code:: python

    tmdb = TMDb(key="YOUR_API_KEY", language="pt-BR", region="BR")
    # or: tmdb = aioTMDb(key="YOUR_API_KEY", language="pt-BR", region="BR")

Alternatively, set after initialize.

.. code:: python

    tmdb = TMDb()
    # or: tmdb = aioTMDb()
    tmdb.key = "YOUR_API_KEY"
    tmdb.language = "pt-BR"     # default: en-US
    tmdb.region = "BR"          # default: US

Alternatively too, you can export your API key, language and region
logger as an environment variable.

.. code:: bash

    $ export TMDB_KEY="YOUR_API_KEY"
    $ export TMDB_LANGUAGE="pt-BR"  # ISO 639-1
    $ export TMDB_REGION="BR"       # ISO-3166-1

And then you will no longer need to set your API key, language and region.

.. code:: python

    tmdb = TMDb()   # from env: TMDB_KEY="YOUR_API_KEY", TMDB_LANGUAGE="pt-BR", TMDB_REGION="BR"
    # or: tmdb = aioTMDb()

Examples
--------

Get the list of top rated movies (sync mode).

.. code:: python

    from themoviedb import TMDb

    tmdb = TMDb()
    movies = tmdb.movies().top_rated()
    for movie in movies:
        print(movie)

Get the list of popular TV shows (async mode).

.. code:: python

    import asyncio
    from themoviedb import aioTMDb

    async def main():
        tmdb = aioTMDb()
        movies = await tmdb.tvs().popular()
        for movie in movies:
            print(movie)

    asyncio.run(main())

Discover movies by different types of data.

.. code:: python

    from themoviedb import TMDb

    tmdb = TMDb()
    movies = tmdb.discover().movie(
        sort_by="vote_average.desc",
        primary_release_date__gte="1997-08-15",
        vote_count__gte=10000,
        vote_average__gte=6.0,
    )
    for movie in movies:
        print(movie)

Get the details of movie for a search.

.. code:: python

    import asyncio
    from themoviedb import aioTMDb

    async def main():
        tmdb = aioTMDb()
        movies = await tmdb.search().movies("fight club")
        movie_id = movies[0].id  # get first result
        movie = await tmdb.movie(movie_id).details(append_to_response="credits,external_ids,images,videos")
        print(movie.title, movie.year)
        print(movie.tagline)
        print(movie.poster_url)
        print(movie.external_ids.imdb_url)
        for person in movie.credits.cast:
            print(person.name, person.character)

    asyncio.run(main())

.. |Code Coverage| image:: https://codecov.io/gh/leandcesar/themoviedb/branch/master/graph/badge.svg?token=OOILIE0RTS
   :target: https://codecov.io/gh/leandcesar/themoviedb
.. |Code style: black| image:: https://img.shields.io/badge/code%20style-black-000000.svg
   :target: https://github.com/psf/black
.. |PyPI Version| image:: https://img.shields.io/pypi/v/themoviedb?color=blue
   :target: https://pypi.org/project/themoviedb/
.. |PyPI License| image:: https://img.shields.io/pypi/l/themoviedb.svg
   :target: https://img.shields.io/pypi/l/themoviedb.svg



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/leandcesar/themoviedb",
    "name": "themoviedb",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "tmdb, tmdb3, aiotmdb, aiotmdb3, themoviedb, themoviedb3, movie, movies, tv, tv show, tv shows",
    "author": "Leandro C\u00e9sar",
    "author_email": "ccleandroc@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/04/10/2a2350ac3d24e5be074b853fc6ce50a5072776ec44ccf00317a0de6fc446/themoviedb-1.0.2.tar.gz",
    "platform": null,
    "description": "|Code Coverage| |PyPI Version| |Code style: black| |PyPI License|\n\nthemoviedb\n==========\n\nA modern and easy to use API wrapper for The Movie Database (TMDb) API v3\nwritten in Python. Supports sync and async requests!\n\n.. image:: https://github.com/leandcesar/themoviedb/blob/master/docs/assets/themoviedb.gif?raw=true\n   :target: https://github.com/leandcesar/themoviedb\n   :alt: themoviedb\n\nOverview\n========\n\nThe **themoviedb** is a synchronous and asynchronous wrapper, written in Python,\nfor The Movie Database (TMDb) API v3.\n\n`The Movie Database (TMDb) <https://www.themoviedb.org>`__ is a\ncommunity built movie and TV database.\n\nThe `TMDb API <https://www.themoviedb.org/documentation/api>`__ service\nis for those of you interested in using our movie, TV show or actor\nimages and/or data in your application.\n\nA `TMDb user account <https://www.themoviedb.org/account/signup>`__ is\nrequired to request an API key.\n\nGetting started\n===============\n\nRequirements\n------------\n\n-  ``python`` (Python >=3.8)\n-  ``pip`` (Python package manager)\n\nInstall\n-------\n\nThe easiest way to install **themoviedb** is via ``pip``.\n\n.. code-block:: shell\n\n    pip install themoviedb[full]\n\nOr only the sync version (with ``requests``).\n\n.. code-block:: shell\n\n    pip install themoviedb[sync]\n\nOr only the async version (with ``aiohttp``).\n\n.. code-block:: shell\n\n    pip install themoviedb[async]\n\nAPI Key\n-------\n\nYou will need an API key to The Movie Database to access the API. To\nobtain a key, follow these steps:\n\n1. `Register <https://www.themoviedb.org/account/signup>`__ for and\n   verify an account.\n2. `Log <https://www.themoviedb.org/login>`__ into your account.\n3. Select the `API section <https://www.themoviedb.org/settings/api>`__\n   on left side of your account page.\n4. Click on the link to generate a new API key and follow the\n   instructions.\n\nUsage\n=====\n\nSync mode\n---------\n\n.. code:: python\n\n    from themoviedb import TMDb\n\nAsync mode\n----------\n\n.. code:: python\n\n    from themoviedb import aioTMDb\n\nConfiguration\n-------------\n\nInitialize a TMDb object and set your API Key, language and region.\n\n.. code:: python\n\n    tmdb = TMDb(key=\"YOUR_API_KEY\", language=\"pt-BR\", region=\"BR\")\n    # or: tmdb = aioTMDb(key=\"YOUR_API_KEY\", language=\"pt-BR\", region=\"BR\")\n\nAlternatively, set after initialize.\n\n.. code:: python\n\n    tmdb = TMDb()\n    # or: tmdb = aioTMDb()\n    tmdb.key = \"YOUR_API_KEY\"\n    tmdb.language = \"pt-BR\"     # default: en-US\n    tmdb.region = \"BR\"          # default: US\n\nAlternatively too, you can export your API key, language and region\nlogger as an environment variable.\n\n.. code:: bash\n\n    $ export TMDB_KEY=\"YOUR_API_KEY\"\n    $ export TMDB_LANGUAGE=\"pt-BR\"  # ISO 639-1\n    $ export TMDB_REGION=\"BR\"       # ISO-3166-1\n\nAnd then you will no longer need to set your API key, language and region.\n\n.. code:: python\n\n    tmdb = TMDb()   # from env: TMDB_KEY=\"YOUR_API_KEY\", TMDB_LANGUAGE=\"pt-BR\", TMDB_REGION=\"BR\"\n    # or: tmdb = aioTMDb()\n\nExamples\n--------\n\nGet the list of top rated movies (sync mode).\n\n.. code:: python\n\n    from themoviedb import TMDb\n\n    tmdb = TMDb()\n    movies = tmdb.movies().top_rated()\n    for movie in movies:\n        print(movie)\n\nGet the list of popular TV shows (async mode).\n\n.. code:: python\n\n    import asyncio\n    from themoviedb import aioTMDb\n\n    async def main():\n        tmdb = aioTMDb()\n        movies = await tmdb.tvs().popular()\n        for movie in movies:\n            print(movie)\n\n    asyncio.run(main())\n\nDiscover movies by different types of data.\n\n.. code:: python\n\n    from themoviedb import TMDb\n\n    tmdb = TMDb()\n    movies = tmdb.discover().movie(\n        sort_by=\"vote_average.desc\",\n        primary_release_date__gte=\"1997-08-15\",\n        vote_count__gte=10000,\n        vote_average__gte=6.0,\n    )\n    for movie in movies:\n        print(movie)\n\nGet the details of movie for a search.\n\n.. code:: python\n\n    import asyncio\n    from themoviedb import aioTMDb\n\n    async def main():\n        tmdb = aioTMDb()\n        movies = await tmdb.search().movies(\"fight club\")\n        movie_id = movies[0].id  # get first result\n        movie = await tmdb.movie(movie_id).details(append_to_response=\"credits,external_ids,images,videos\")\n        print(movie.title, movie.year)\n        print(movie.tagline)\n        print(movie.poster_url)\n        print(movie.external_ids.imdb_url)\n        for person in movie.credits.cast:\n            print(person.name, person.character)\n\n    asyncio.run(main())\n\n.. |Code Coverage| image:: https://codecov.io/gh/leandcesar/themoviedb/branch/master/graph/badge.svg?token=OOILIE0RTS\n   :target: https://codecov.io/gh/leandcesar/themoviedb\n.. |Code style: black| image:: https://img.shields.io/badge/code%20style-black-000000.svg\n   :target: https://github.com/psf/black\n.. |PyPI Version| image:: https://img.shields.io/pypi/v/themoviedb?color=blue\n   :target: https://pypi.org/project/themoviedb/\n.. |PyPI License| image:: https://img.shields.io/pypi/l/themoviedb.svg\n   :target: https://img.shields.io/pypi/l/themoviedb.svg\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A modern and easy to use API wrapper for The Movie Database (TMDb) API v3 written in Python",
    "version": "1.0.2",
    "project_urls": {
        "Homepage": "https://github.com/leandcesar/themoviedb"
    },
    "split_keywords": [
        "tmdb",
        " tmdb3",
        " aiotmdb",
        " aiotmdb3",
        " themoviedb",
        " themoviedb3",
        " movie",
        " movies",
        " tv",
        " tv show",
        " tv shows"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4ddb8ec611895d2007c67d481b18c9ad38ef13bbb344b05bdcb96fc821556097",
                "md5": "fc3da44317e858820abd7166a734bafb",
                "sha256": "badf85e91010c7085509f40270bf2a40ea30ee5ef3ed6fb3ec332c5e50adb576"
            },
            "downloads": -1,
            "filename": "themoviedb-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fc3da44317e858820abd7166a734bafb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 61438,
            "upload_time": "2024-07-23T02:08:49",
            "upload_time_iso_8601": "2024-07-23T02:08:49.154128Z",
            "url": "https://files.pythonhosted.org/packages/4d/db/8ec611895d2007c67d481b18c9ad38ef13bbb344b05bdcb96fc821556097/themoviedb-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "04102a2350ac3d24e5be074b853fc6ce50a5072776ec44ccf00317a0de6fc446",
                "md5": "1d67c558351ad675bb87a2755154fab4",
                "sha256": "7835615142a44e7ca25e48645a3a3c5e06b382e8c518c38c3537effa9a2596ce"
            },
            "downloads": -1,
            "filename": "themoviedb-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "1d67c558351ad675bb87a2755154fab4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 31908,
            "upload_time": "2024-07-23T02:08:50",
            "upload_time_iso_8601": "2024-07-23T02:08:50.754563Z",
            "url": "https://files.pythonhosted.org/packages/04/10/2a2350ac3d24e5be074b853fc6ce50a5072776ec44ccf00317a0de6fc446/themoviedb-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-23 02:08:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "leandcesar",
    "github_project": "themoviedb",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "aiohttp",
            "specs": [
                [
                    ">=",
                    "3.8.4"
                ]
            ]
        },
        {
            "name": "dacite",
            "specs": [
                [
                    ">=",
                    "1.8.0"
                ]
            ]
        },
        {
            "name": "requests",
            "specs": [
                [
                    ">=",
                    "2.31.0"
                ]
            ]
        }
    ],
    "lcname": "themoviedb"
}
        
Elapsed time: 2.58114s