DlgzRogelio / Project-1

MIT License
0 stars 1 forks source link

Documentation: API TMDB #11

Open DlgzRogelio opened 3 years ago

ca2los commented 3 years ago

DOCS

Hey team, I'm sharing with you the official documentation from The Movie Database. You'll find the API key, guides and an easy example for testing the service.

Overview: https://developers.themoviedb.org/3/getting-started/search-and-query-for-details Support: https://www.themoviedb.org/talk/category/5047958519c29526b50017d6 Wrapper: https://www.themoviedb.org/documentation/api/wrappers-libraries Library: https://github.com/cavestri/themoviedb-javascript-library/

The key for the project is public (for now)

That means our website is not the only one available to access the data, but it will change to private. Anyway, just make sure you don't share it or make use of this key with another domains.

API KEY (v3 auth): 94f0c60308f2a42f4c8a0265000556cd

EXAMPLE URL:

https://api.themoviedb.org/3/movie/550?api_key=94f0c60308f2a42f4c8a0265000556cd

TOKEN API READ ACCESS (v4 auth):

eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiI5NGYwYzYwMzA4ZjJhNDJmNGM4YTAyNjUwMDA1NTZjZCIsInN1YiI6IjYxMGIzYjAyZDRkNTA5MDAyZTQwZDM1OCIsInNjb3BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIjoxfQ.5bXMcUOSjNZYRWntzSlGBuHr8kjfacnrTWDUUXJWqOI

EXAMPLE CODE:
    function getApi() {
        var requestUrl = 'https://api.themoviedb.org/3/movie/550?api_key=94f0c60308f2a42f4c8a0265000556cd';

        fetch(requestUrl).then(function (response) {
            return response.json();
        })
        .then(function (data) {
            console.log(data);
        });
    }
    getApi();

Make sure you are testing the API and if you find something, plz let me know.

cc @DlgzRogelio @ian-dot @ltrevino

ca2los commented 3 years ago

Hello guys,

I have been testing the API to prepare ourselves to the challenge of making this program works. So, in order to understand our possibilities, I tried some examples to show you where are we, what can we do at this moment, and start thinking about future challenges.

EXAMPLE 01

The global variable api_key retrieves the API ID that I shared with you in this thread. The function is an example of how the program retrieves theinput_movie value from the user:


    // Please, try this in your browser's console

    let api_key = '94f0c60308f2a42f4c8a0265000556cd';

    function api_request_01() {

        let input_movie = 'Jack Reacher';
        let request_movie = 'https://api.themoviedb.org/3/search/movie?api_key=' + api_key + '&query=' + input_movie;

        fetch(request_movie).then(function (response) {
            return response.json();
        })
        .then(function (data) {
            console.log(data);
        });

    }
    api_request_01();
EXAMPLE 02

At this point the program already retrieved the IDs obtained by the previous function (example 01) and stored the values inside a new variable array. The whole purpose of this function is to show you how to work with IDs inside a new URL path:


    // Please, try this in your browser's console

    let api_key = '94f0c60308f2a42f4c8a0265000556cd';

    function api_movie() {

        let id_movie = ['75780','343611'];

        for (let i = 0; i < id_movie.length; i++) {
            let show_movie = 'https://api.themoviedb.org/3/movie/' + id_movie[i] + '?api_key=' + api_key;

            fetch(show_movie).then(function (response) {
                return response.json();
            })
            .then(function (data) {
                console.log(data);
            });
        }

    }
    api_movie();
EXAMPLE 03

This exercise is different, because the user initialize a search by name of the actress/actor and the function will add the value inside the path of the URL. The variable of the actor's name is input-actor and "filter_is_on" is the advanced filter activated by the user:


    // Please, try this in your browser's console

    let api_key = '94f0c60308f2a42f4c8a0265000556cd';

    function api_request_02() {

        let input_actor = 'Leonardo';
        let filter_is_on = true;

        if (filter_is_on === true) {
            let request_movie = 'https://api.themoviedb.org/3/search/person?api_key=' + api_key + '&language=en-US&query=' + input_actor + '&page=1&include_adult=false'

            fetch(request_movie).then(function (response) {
                return response.json();
            })
            .then(function (data) {
                console.log(data);
            });
        }
    }
    api_request_02();

    // This function prints a top 20 list of results and at this point the user must click at the name
    // to finally show the top movies of his selection.

Ok guys, what do you think? I hope you see this message before the class. I tried to mix more parameters from "The Movie Database" but i got a lot of errors. I had to do a lot of test.

I hope you find it useful!

cc @ltrevino @ian-dot @DlgzRogelio

DlgzRogelio commented 3 years ago

https://developer.imdb.com/documentation https://rapidapi.com/apidojo/api/imdb8