Forum Academy Marketplace Showcase Pricing Features

How to properly initialize an API with a dynamic number of objects in its response?

I’m working on a site that deals with movies and TV shows. Right now I’m trying to use https://www.themoviedb.org/ API to access JustWatch.com information so user can see where they can stream / buy the movie/tv show. JustWatch covers 46 regions/countries, but as you can imagine a title available to stream on a few services in the UK might be totally unavailable to stream for example in Brazil (this creates an issue with initializing the API due to how the response works).

Here’s an example response for the film “Love Actually” which is widely available globally:

Love Actually API RESPONSE
{
  "id": 508,
  "results.AR.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=AR",
  "results.AR.rent": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.AR.flatrate": [
    {
      "display_priority": 1,
      "logo_path": "/68MNrwlkpF7WnmNPXLah69CR5cb.jpg",
      "provider_id": 119,
      "provider_name": "Amazon Prime Video"
    }
  ],
  "results.AR.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.AT.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=AT",
  "results.AT.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.AT.rent": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.AT.flatrate": [
    {
      "display_priority": "",
      "logo_path": "/9A1JSVmSxsyaBK4SUFsYVqbAYfW.jpg",
      "provider_id": 8,
      "provider_name": "Netflix"
    }
  ],
  "results.AU.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=AU",
  "results.AU.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.AU.rent": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.AU.flatrate": [
    {
      "display_priority": 1,
      "logo_path": "/68MNrwlkpF7WnmNPXLah69CR5cb.jpg",
      "provider_id": 119,
      "provider_name": "Amazon Prime Video"
    }
  ],
  "results.BE.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=BE",
  "results.BE.flatrate": [
    {
      "display_priority": 1,
      "logo_path": "/68MNrwlkpF7WnmNPXLah69CR5cb.jpg",
      "provider_id": 119,
      "provider_name": "Amazon Prime Video"
    }
  ],
  "results.BE.buy": [
    {
      "display_priority": 3,
      "logo_path": "/p3Z12gKq2qvJaUOMeKNU2mzKVI9.jpg",
      "provider_id": 3,
      "provider_name": "Google Play Movies"
    }
  ],
  "results.BE.rent": [
    {
      "display_priority": 3,
      "logo_path": "/p3Z12gKq2qvJaUOMeKNU2mzKVI9.jpg",
      "provider_id": 3,
      "provider_name": "Google Play Movies"
    }
  ],
  "results.BR.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=BR",
  "results.BR.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.BR.flatrate": [
    {
      "display_priority": 1,
      "logo_path": "/68MNrwlkpF7WnmNPXLah69CR5cb.jpg",
      "provider_id": 119,
      "provider_name": "Amazon Prime Video"
    }
  ],
  "results.BR.rent": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.CA.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=CA",
  "results.CA.rent": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.CA.flatrate": [
    {
      "display_priority": 1,
      "logo_path": "/68MNrwlkpF7WnmNPXLah69CR5cb.jpg",
      "provider_id": 119,
      "provider_name": "Amazon Prime Video"
    }
  ],
  "results.CA.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.CH.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=CH",
  "results.CH.rent": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.CH.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.CH.flatrate": [
    {
      "display_priority": "",
      "logo_path": "/9A1JSVmSxsyaBK4SUFsYVqbAYfW.jpg",
      "provider_id": 8,
      "provider_name": "Netflix"
    }
  ],
  "results.CL.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=CL",
  "results.CL.rent": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.CL.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.CL.flatrate": [
    {
      "display_priority": 1,
      "logo_path": "/68MNrwlkpF7WnmNPXLah69CR5cb.jpg",
      "provider_id": 119,
      "provider_name": "Amazon Prime Video"
    }
  ],
  "results.CO.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=CO",
  "results.CO.flatrate": [
    {
      "display_priority": 1,
      "logo_path": "/68MNrwlkpF7WnmNPXLah69CR5cb.jpg",
      "provider_id": 119,
      "provider_name": "Amazon Prime Video"
    }
  ],
  "results.CO.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.CO.rent": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.CZ.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=CZ",
  "results.CZ.rent": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.CZ.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.CZ.flatrate": [
    {
      "display_priority": 1,
      "logo_path": "/68MNrwlkpF7WnmNPXLah69CR5cb.jpg",
      "provider_id": 119,
      "provider_name": "Amazon Prime Video"
    }
  ],
  "results.DK.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=DK",
  "results.DK.rent": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.DK.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.DK.flatrate": [
    {
      "display_priority": 1,
      "logo_path": "/68MNrwlkpF7WnmNPXLah69CR5cb.jpg",
      "provider_id": 119,
      "provider_name": "Amazon Prime Video"
    }
  ],
  "results.EC.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=EC",
  "results.EC.rent": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.EC.flatrate": [
    {
      "display_priority": 1,
      "logo_path": "/68MNrwlkpF7WnmNPXLah69CR5cb.jpg",
      "provider_id": 119,
      "provider_name": "Amazon Prime Video"
    }
  ],
  "results.EC.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.EE.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=EE",
  "results.EE.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.EE.flatrate": [
    {
      "display_priority": "",
      "logo_path": "/9A1JSVmSxsyaBK4SUFsYVqbAYfW.jpg",
      "provider_id": 8,
      "provider_name": "Netflix"
    }
  ],
  "results.EE.rent": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.ES.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=ES",
  "results.ES.flatrate": [
    {
      "display_priority": 1,
      "logo_path": "/68MNrwlkpF7WnmNPXLah69CR5cb.jpg",
      "provider_id": 119,
      "provider_name": "Amazon Prime Video"
    }
  ],
  "results.ES.rent": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.ES.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.FI.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=FI",
  "results.FI.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.FI.flatrate": [
    {
      "display_priority": 1,
      "logo_path": "/68MNrwlkpF7WnmNPXLah69CR5cb.jpg",
      "provider_id": 119,
      "provider_name": "Amazon Prime Video"
    }
  ],
  "results.FI.rent": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.FR.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=FR",
  "results.FR.flatrate": [
    {
      "display_priority": "",
      "logo_path": "/9A1JSVmSxsyaBK4SUFsYVqbAYfW.jpg",
      "provider_id": 8,
      "provider_name": "Netflix"
    }
  ],
  "results.FR.buy": [
    {
      "display_priority": 3,
      "logo_path": "/p3Z12gKq2qvJaUOMeKNU2mzKVI9.jpg",
      "provider_id": 3,
      "provider_name": "Google Play Movies"
    }
  ],
  "results.FR.rent": [
    {
      "display_priority": 3,
      "logo_path": "/p3Z12gKq2qvJaUOMeKNU2mzKVI9.jpg",
      "provider_id": 3,
      "provider_name": "Google Play Movies"
    }
  ],
  "results.GB.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=GB",
  "results.GB.flatrate": [
    {
      "display_priority": 3,
      "logo_path": "/hYrcCS72d2alfXdGS1QXNEvwYDY.jpg",
      "provider_id": 39,
      "provider_name": "Now TV"
    }
  ],
  "results.GB.rent": [
    {
      "display_priority": 11,
      "logo_path": "/vjKeS7Y9fNyqNtvp2ROCc71iu1u.jpg",
      "provider_id": 40,
      "provider_name": "Chili"
    }
  ],
  "results.GB.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.GR.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=GR",
  "results.GR.flatrate": [
    {
      "display_priority": 1,
      "logo_path": "/68MNrwlkpF7WnmNPXLah69CR5cb.jpg",
      "provider_id": 119,
      "provider_name": "Amazon Prime Video"
    }
  ],
  "results.GR.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.GR.rent": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.HU.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=HU",
  "results.HU.flatrate": [
    {
      "display_priority": 1,
      "logo_path": "/68MNrwlkpF7WnmNPXLah69CR5cb.jpg",
      "provider_id": 119,
      "provider_name": "Amazon Prime Video"
    }
  ],
  "results.HU.rent": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.HU.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.ID.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=ID",
  "results.ID.flatrate": [
    {
      "display_priority": 10,
      "logo_path": "/12w89KdhlruBTJEkHR0kMKKgLKx.jpg",
      "provider_id": 425,
      "provider_name": "HBO Go"
    }
  ],
  "results.IE.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=IE",
  "results.IE.rent": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.IE.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.IE.flatrate": [
    {
      "display_priority": 3,
      "logo_path": "/hYrcCS72d2alfXdGS1QXNEvwYDY.jpg",
      "provider_id": 39,
      "provider_name": "Now TV"
    }
  ],
  "results.IT.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=IT",
  "results.IT.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.IT.rent": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.IT.flatrate": [
    {
      "display_priority": "",
      "logo_path": "/9A1JSVmSxsyaBK4SUFsYVqbAYfW.jpg",
      "provider_id": 8,
      "provider_name": "Netflix"
    }
  ],
  "results.JP.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=JP",
  "results.JP.rent": [
    {
      "display_priority": 10,
      "logo_path": "/sVBEF7q7LqjHAWSnKwDbzmr2EMY.jpg",
      "provider_id": 10,
      "provider_name": "Amazon Video"
    }
  ],
  "results.JP.flatrate": [
    {
      "display_priority": "",
      "logo_path": "/9A1JSVmSxsyaBK4SUFsYVqbAYfW.jpg",
      "provider_id": 8,
      "provider_name": "Netflix"
    }
  ],
  "results.JP.buy": [
    {
      "display_priority": 10,
      "logo_path": "/sVBEF7q7LqjHAWSnKwDbzmr2EMY.jpg",
      "provider_id": 10,
      "provider_name": "Amazon Video"
    }
  ],
  "results.KR.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=KR",
  "results.KR.rent": [
    {
      "display_priority": 2,
      "logo_path": "/8N0DNa4BO3lH24KWv1EjJh4TxoD.jpg",
      "provider_id": 356,
      "provider_name": "wavve"
    }
  ],
  "results.KR.buy": [
    {
      "display_priority": 3,
      "logo_path": "/p3Z12gKq2qvJaUOMeKNU2mzKVI9.jpg",
      "provider_id": 3,
      "provider_name": "Google Play Movies"
    }
  ],
  "results.KR.flatrate": [
    {
      "display_priority": 2,
      "logo_path": "/8N0DNa4BO3lH24KWv1EjJh4TxoD.jpg",
      "provider_id": 356,
      "provider_name": "wavve"
    }
  ],
  "results.LT.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=LT",
  "results.LT.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.LT.flatrate": [
    {
      "display_priority": "",
      "logo_path": "/9A1JSVmSxsyaBK4SUFsYVqbAYfW.jpg",
      "provider_id": 8,
      "provider_name": "Netflix"
    }
  ],
  "results.LT.rent": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.LV.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=LV",
  "results.LV.flatrate": [
    {
      "display_priority": "",
      "logo_path": "/9A1JSVmSxsyaBK4SUFsYVqbAYfW.jpg",
      "provider_id": 8,
      "provider_name": "Netflix"
    }
  ],
  "results.MX.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=MX",
  "results.MX.rent": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.MX.flatrate": [
    {
      "display_priority": 1,
      "logo_path": "/68MNrwlkpF7WnmNPXLah69CR5cb.jpg",
      "provider_id": 119,
      "provider_name": "Amazon Prime Video"
    }
  ],
  "results.MX.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.MY.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=MY",
  "results.MY.flatrate": [
    {
      "display_priority": 10,
      "logo_path": "/12w89KdhlruBTJEkHR0kMKKgLKx.jpg",
      "provider_id": 425,
      "provider_name": "HBO Go"
    }
  ],
  "results.MY.rent": [
    {
      "display_priority": 3,
      "logo_path": "/p3Z12gKq2qvJaUOMeKNU2mzKVI9.jpg",
      "provider_id": 3,
      "provider_name": "Google Play Movies"
    }
  ],
  "results.MY.buy": [
    {
      "display_priority": 3,
      "logo_path": "/p3Z12gKq2qvJaUOMeKNU2mzKVI9.jpg",
      "provider_id": 3,
      "provider_name": "Google Play Movies"
    }
  ],
  "results.NL.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=NL",
  "results.NL.rent": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.NL.flatrate": [
    {
      "display_priority": 1,
      "logo_path": "/68MNrwlkpF7WnmNPXLah69CR5cb.jpg",
      "provider_id": 119,
      "provider_name": "Amazon Prime Video"
    }
  ],
  "results.NL.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.NO.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=NO",
  "results.NO.rent": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.NO.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.NO.flatrate": [
    {
      "display_priority": 1,
      "logo_path": "/68MNrwlkpF7WnmNPXLah69CR5cb.jpg",
      "provider_id": 119,
      "provider_name": "Amazon Prime Video"
    }
  ],
  "results.NZ.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=NZ",
  "results.NZ.flatrate": [
    {
      "display_priority": 1,
      "logo_path": "/68MNrwlkpF7WnmNPXLah69CR5cb.jpg",
      "provider_id": 119,
      "provider_name": "Amazon Prime Video"
    }
  ],
  "results.NZ.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.NZ.rent": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.PE.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=PE",
  "results.PE.rent": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.PE.flatrate": [
    {
      "display_priority": 1,
      "logo_path": "/68MNrwlkpF7WnmNPXLah69CR5cb.jpg",
      "provider_id": 119,
      "provider_name": "Amazon Prime Video"
    }
  ],
  "results.PE.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.PH.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=PH",
  "results.PH.flatrate": [
    {
      "display_priority": 10,
      "logo_path": "/12w89KdhlruBTJEkHR0kMKKgLKx.jpg",
      "provider_id": 425,
      "provider_name": "HBO Go"
    }
  ],
  "results.PL.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=PL",
  "results.PL.flatrate": [
    {
      "display_priority": 1,
      "logo_path": "/68MNrwlkpF7WnmNPXLah69CR5cb.jpg",
      "provider_id": 119,
      "provider_name": "Amazon Prime Video"
    }
  ],
  "results.PT.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=PT",
  "results.PT.flatrate": [
    {
      "display_priority": "",
      "logo_path": "/9A1JSVmSxsyaBK4SUFsYVqbAYfW.jpg",
      "provider_id": 8,
      "provider_name": "Netflix"
    }
  ],
  "results.RO.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=RO",
  "results.RO.flatrate": [
    {
      "display_priority": 1,
      "logo_path": "/68MNrwlkpF7WnmNPXLah69CR5cb.jpg",
      "provider_id": 119,
      "provider_name": "Amazon Prime Video"
    }
  ],
  "results.RU.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=RU",
  "results.RU.free": [
    {
      "display_priority": 2,
      "logo_path": "/2DpMZHxP9jzu3v70bph1UD3LLv3.jpg",
      "provider_id": 113,
      "provider_name": "Ivi"
    }
  ],
  "results.RU.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.RU.flatrate": [
    {
      "display_priority": 1,
      "logo_path": "/68MNrwlkpF7WnmNPXLah69CR5cb.jpg",
      "provider_id": 119,
      "provider_name": "Amazon Prime Video"
    }
  ],
  "results.RU.rent": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.SE.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=SE",
  "results.SE.rent": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.SE.flatrate": [
    {
      "display_priority": 1,
      "logo_path": "/68MNrwlkpF7WnmNPXLah69CR5cb.jpg",
      "provider_id": 119,
      "provider_name": "Amazon Prime Video"
    }
  ],
  "results.SE.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.SG.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=SG",
  "results.SG.flatrate": [
    {
      "display_priority": 10,
      "logo_path": "/12w89KdhlruBTJEkHR0kMKKgLKx.jpg",
      "provider_id": 425,
      "provider_name": "HBO Go"
    }
  ],
  "results.TH.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=TH",
  "results.TH.flatrate": [
    {
      "display_priority": 10,
      "logo_path": "/12w89KdhlruBTJEkHR0kMKKgLKx.jpg",
      "provider_id": 425,
      "provider_name": "HBO Go"
    }
  ],
  "results.TR.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=TR",
  "results.TR.flatrate": [
    {
      "display_priority": 1,
      "logo_path": "/68MNrwlkpF7WnmNPXLah69CR5cb.jpg",
      "provider_id": 119,
      "provider_name": "Amazon Prime Video"
    }
  ],
  "results.US.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=US",
  "results.US.rent": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.US.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.US.ads": [
    {
      "display_priority": 8,
      "logo_path": "/d9cPwjnMYUEdjsfPuX96akc807z.jpg",
      "provider_id": 386,
      "provider_name": "Peacock"
    }
  ],
  "results.VE.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=VE",
  "results.VE.rent": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.VE.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.VE.flatrate": [
    {
      "display_priority": 1,
      "logo_path": "/68MNrwlkpF7WnmNPXLah69CR5cb.jpg",
      "provider_id": 119,
      "provider_name": "Amazon Prime Video"
    }
  ],
  "results.ZA.link": "https://www.themoviedb.org/movie/508-love-actually/watch?locale=ZA",
  "results.ZA.flatrate": [
    {
      "display_priority": "",
      "logo_path": "/9A1JSVmSxsyaBK4SUFsYVqbAYfW.jpg",
      "provider_id": 8,
      "provider_name": "Netflix"
    }
  ],
  "results.ZA.buy": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ],
  "results.ZA.rent": [
    {
      "display_priority": 2,
      "logo_path": "/q6tl6Ib6X5FT80RMlcDbexIo4St.jpg",
      "provider_id": 2,
      "provider_name": "Apple iTunes"
    }
  ]
}

So there are about 5 or 6 possible objects for each region: flatrate (streaming), buy, and rent, free, etc. But when initialising the API, not every country will have an object for say “free” or “flaterate” aka streaming services. So this means after initializing I’m not able to ever query the “free” or “flatrate” for other films when searching for that region, simply because god damn love actually wasn’t available there at the time of initializing.

So, I don’t think there is a single movie/film on JustWatch that I could use to initialise this API correctly, as it would require that movie to be available for purchase, streaming/‘flatrate’, rent, ‘free’, etc accross all 46 JustWatch regions.

But I can initialise the API and get it to display streaming options for titles in Australia easily, since Love actually currently has streaming options in Australia. However I won’t be able to even query the API for the US for any film, since that country didn’t appear as an option when I initialised the API using Love Actually.

If anyone could help me to be able to initialise this call so that it would encompass all possible viewing options in all of the 46 reasons, I will love you, actually.


image

This is one way …

  1. Create an API workflow endpoint, that has one text parameter and returns it as text.
  2. Edit the API Connector call to point to the new endpoint, add a form parameter for long text, in the value put in your manually revised JSON.
  3. Reinitialize call to capture fields to match the structure you sent.

Next either of …

  1. Restore the API Connector call to its original form.

Or

  1. Create a new API Connector call to the external service, have it return type Text so as not to parse the JSON into fields.
  2. A workflow can now call the external API, manipulate the JSON text, then call the app endpoint to parse it into fields.

If you keep the endpoint in production, ensure it is authenticated.

I can help with the steps if you send me a PM. :slight_smile:

1 Like

For me this is the kind of stuff that make me say that an API response is not well formatted. (But this is my opinion).
Solution A) Use the schema template available in the API.


Look there, there’s an example of response. Use it and use “Manually enter API Response”. Save.
But now to display, this mean a condition for each country.
Solution B) Create a plugin that will transform the json in a structure that you will be able to dynamically select the country
1 Like

Thanks @Jici, I had been questioning whether I was missing something, or whether the API’s design has traded smaller responses (effiency) for more verbose outputs that would have all possible objects for each country even if they are empty (the more programmer friendly alternative).

The example response for Fight Club they provide does have the same issue as Love Actually though - not all countries return objects with (for example) the the “ads” object aka free streaming services supported by ads. Another example is that the response for fight club currently returns a streaming “flatrate” object, but Love Actually instead only has a “ads” object - in the future these will change and Love Actually might come to Netflix in the US, and so a Flatrate object for streaming will be returned to the API but Bubble wasn’t initialised with it.

I did go ahead and write a bash script which artifically wrote out a “perfect” response which is all 46 countries and returns the 3 objects I want for all of them - but I didn’t manage to get the Manually Enter API Response approach to work properly - I assume after exerting all that time writing Bash script at 2 am I lost my mind and missed something very obvious.

Here's the JSON I artificially created if you're interested, it has all 46 regions and includes the three objects I'm most interested in "flatrate", "rent" and "buy":

https://gist.githubusercontent.com/illegalbyte/9cd48bc0ee3393a9961a22b23a960420/raw/d884a0ff35e59256c3be0713a21a441d8d4256a3/Bubble-JustWatch.json

@Jici Creating a plugin sounds like a promising and robust way to tackle the issue. It could also help out other bubble devs in the future with JustWatch integration if I make it public. Do you have any advice on how I would go about writing the plugin?

This topic was automatically closed after 70 days. New replies are no longer allowed.