S
S
Shura01022021-05-28 08:41:34
API
Shura0102, 2021-05-28 08:41:34

How to get information from film search using api?

Hello! I take information about the film from the film search for such a request

function get_kinopoisk_data() {
    let kinopoisk_id = document.getElementById("glink").value;
    let xhr = new XMLHttpRequest();
    xhr.open('GET', `https://kinopoiskapiunofficial.tech/api/v2.1/films/${kinopoisk_id}?append_to_response=POSTERS`, false);
    xhr.setRequestHeader('X-API-KEY', '05e15730-5d36-4a7b-9cb8-1a9034ed276c');
  	xhr.send();
    fill_other_fields(JSON.parse(xhr.responseText));
 }

 function fill_other_fields(response) {
    console.log(response);
    document.getElementById("sfF1 title").value = response.data.nameRu ?? "";
    document.getElementById("brief").value = response.data.description ?? "";
    document.getElementById("sfF6").value = response.data.ratingAgeLimits ?? "";
    document.getElementById("slogan").value = response.data.slogan ?? "";
    document.getElementById("sfF13").value = response.data.filmLength ?? "";
    document.getElementById("sfF150").value = response.data.nameEn ?? "";
    document.getElementById("sfF14").value = response.data.actors ?? "";
    document.getElementById("sfF15").value = response.data.budget ?? "";
    document.getElementById("sfF8").value = response.data.seasons.length ?? "";
    document.getElementById("message").value = response.data.facts ?? "";
    document.getElementById("sfF7").value = response.data.premiereRu ?? "";
    document.getElementById("distributors").value = response.data.distributors ?? "";
    document.getElementById("input_extrafl10").value = response.data.premiereWorld ?? "";
    document.getElementById("input_extrafl8").value = response.data.posterUrl ?? "";
    document.getElementById("input_extrafl9").value = response.data.posterUrlPreview ?? "";
    document.getElementsByClassName("manFlFlt1").value = response.data.country;
    let year_options = Array.from(document.querySelectorAll('.manFlFlt1 option'));
    year_options.find(c => c.text == response.data.year).selected = true;

, but it is not possible to get a list of actors, director and number of episodes. Tell me what am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2021-05-28
@vabka

1. Information about directors and actors is in ​/api​/v1​/staff
2. about episodes: response.data.seasons[0].episodes Did
n't you learn to read the documentation?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question