Part 1: The Basics


  • administrators

    The first thing you need to do to start learning the API is to watch how it works while you are browsing the Netflix site.

    When you browse Netflix using Chrome (or any browser), the information you see on the screen is actually being pulled via javascript ajax calls to the Netflix API. Simply put these are just additional urls that the browser is accessing while you are navigating around the page.

    To see this in action (Using Chrome) you can right click anywhere on the page and select 'inspect' , then on the inspect pane just click 'Network'.

    0_1501687558455_1487417064451-upload-f836cd1a-9ec9-4edb-b789-ccb004e34b12.png

    As you can see in the above screenshot, we have opened the inspect pane, clicked on 'Network' and added the string 'path' to the search box. Adding this filter string allows us to separate all the noise from the requests that we are really interested in.

    Like most modern web API's, Netflix use JSON in both their post data and the information retrieved from this POST. In order to keep things interesting Netflix periodically update the url path to their API so you can't rely on it always being the same, but you can usually get a few weeks out of it and it will always be similar to the one in the following example.

    https://www.netflix.com/api/shakti/0feb190f/pathEvaluator?withSize=true&materialize=true&model=harris
    

    As I mentioned before the way Netflix accesses their API is by posting JSON to the url listed above. As such the url doesn't change with each request, only the JSON data changes.

    Here is an example of a request header used to search for the word 'Sherlock'

    {
      "paths": [
        ["search",      "sherlock",      "titles",    {        "from": 0,        "to": 48      },
          [        "summary",        "title"      ]
        ],
        [      "search",      "sherlock",      "titles",      {        "from": 0,        "to": 48      },
          "boxarts",      "_342x192",      "webp"
        ],
        [      "search",      "sherlock",      "titles",
          [        "id",        "length",        "name",        "trackIds",        "requestId",        "referenceId"      ]
        ],
        [      "search",      "sherlock",      "person",      {        "from": 0,        "to": 20      },
          "person",      "summary"
        ],
        [      "search",      "sherlock",      "person",      {        "from": 0,        "to": 20      },
          "referenceId"
        ],
        [      "search",      "sherlock",      "person",      [        "summary",        "reference",        "trackId"      ]
        ],
        [      "search",      "sherlock",      "suggestions",      {        "from": 0,        "to": 20      },
          [        "referenceId",        "summary"      ]
        ],
        [      "search",      "sherlock",      "suggestions", 
         [        "summary",        "reference",        "trackId"      ]
        ]
      ],
      "authURL": "1487416962423.jm9vk+kBt6k1B0i+zwhY+MzdqMg="
    }
    

    I know this looks like a huge wall of information but when you break it down its fairly straight forward. Basically it requests searches for 3 different things: titles, person, and suggestions and what results to provide for each. For example on the title search it is requesting 3 different responses.

    1. 0-48 results with summary
    2. 0-48 results of the boxart in '_342x192' 'webp' format.
    3. The id, length, name, trackid, requestid, referencid for each matching title

    Looking at the rest of the information I'm sure you can work out what else the data is requesting.

    So, how does the API respond to this request? In this specific example it looks like this:

    {"value":{"$size":6317,"size":6317,"search":{"$size":6093,"size":6093,"sherlock":{"$size":6093,"size":6093,"person":{"$size":1440,"size":1440,"reference":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"9":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"person":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"12":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"person":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"2":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"person":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"20":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"person":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"19":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"person":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"5":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"person":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"6":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"person":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"16":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"person":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"13":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"person":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"3":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"person":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"8":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"person":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"11":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"person":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"0":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"person":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"14":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"person":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"17":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"person":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"10":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"person":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"7":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"person":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"15":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"person":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"1":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"person":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"4":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"person":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"18":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"person":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"trackId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"summary":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"titles":{"$size":3186,"size":3186,"0":["videos","70202589"],"referenceId":"051133bc686ebc4d1900e1373bf3e66b79baa7b6:e9dceaebe76f4cea2900ebb5d08ca19afc80ebd2","trackIds":{"trackId":13752289,"trackId_jaw":13752289,"trackId_jawEpisode":13752289,"trackId_jawTrailer":13752289,"$type":"leaf","$size":110,"size":110},"length":1,"6":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"28":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"8":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"41":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"20":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"43":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"22":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"45":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"24":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"47":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"26":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"16":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"39":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"14":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"12":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"10":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"31":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"33":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"1":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"35":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"3":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"18":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"37":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"5":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"7":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"29":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"9":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"40":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"21":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"42":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"23":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"44":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"25":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"46":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"27":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"48":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"15":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"13":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"11":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"30":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"32":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"34":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"2":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"19":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"36":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"4":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"17":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"38":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"suggestions":{"$size":1467,"size":1467,"0":{"$size":55,"size":55,"referenceId":"9aa7f98339b94848cdc1a3a5d3e5d24621063ca8:99e022ba77cd5a3b9ed801fc444dae84c711a170","summary":{"id":"Sherlock Holmes","name":"Sherlock Holmes","$type":"leaf","$size":54,"size":54}},"trackId":13752290,"summary":{"length":5,"$type":"leaf","$size":22,"size":22},"reference":"fb5778223859775935be25aed1ffe0fda79f527a:46d105db7fb6ba274e0183b7dbc30b6bafedead6","1":{"$size":93,"size":93,"summary":{"id":"Sherlock Holmes: A Game of Shadows","name":"Sherlock Holmes: A Game of Shadows","$type":"leaf","$size":92,"size":92},"referenceId":"adab71eec9cf1d0a3fc2ab40ec623ebe13e239ac:a7dd0daa70f3e672bff638735ca65ae2058e3fab"},"2":{"$size":91,"size":91,"summary":{"id":"The Adventures of Sherlock Holmes","name":"The Adventures of Sherlock Holmes","$type":"leaf","$size":90,"size":90},"referenceId":"45eff2ac6df40eb70e77ecd66364aa8cd671e715:731c1a58bd7f5a27ce9b4934e44f69cfeece7e16"},"3":{"$size":95,"size":95,"referenceId":"051c7d8f1e0d791ca18abc18f162a92fb2cf2c19:8ebcc8235efac62c3ee9b13536bda4cfc70b6b8e","summary":{"id":"Sherlock Holmes in the 22nd Century","name":"Sherlock Holmes in the 22nd Century","$type":"leaf","$size":94,"size":94}},"4":{"$size":85,"size":85,"referenceId":"fb736636e49daed154d2f0c9fdc5ccaf433dce44:492c5c9fab3c17ae8e4f6045f6d60a78babb86e2","summary":{"id":"Sherlock: The Abominable Bride","name":"Sherlock: The Abominable Bride","$type":"leaf","$size":84,"size":84}},"19":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"summary":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"6":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"summary":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"9":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"summary":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"11":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"summary":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"5":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"summary":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"16":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"summary":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"13":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"summary":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"10":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"summary":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"8":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"summary":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"14":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"summary":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"17":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"summary":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"18":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"summary":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"20":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"summary":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"7":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"summary":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"12":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"summary":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}},"15":{"$size":64,"size":64,"referenceId":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32},"summary":{"_sentinel":true,"$type":"sentinel","$size":32,"size":32}}}}},"videos":{"$size":224,"size":224,"70202589":{"$size":224,"size":224,"summary":{"id":70202589,"type":"show","isNSRE":false,"isOriginal":false,"$type":"leaf","$size":68,"size":68},"title":"Sherlock","boxarts":{"$size":155,"size":155,"_342x192":{"$size":155,"size":155,"webp":{"url":"https://art-s.nflximg.net/bcf56/70201cfe99efe756703fa02ea2406f36907bcf56.webp","image_key":"sdp,2|AD_169e35a0-43a9-11e6-8c38-22000bcc0076|en","$type":"leaf","$size":155,"size":155}}}}}},"paths":[["search","sherlock","titles",{"from":0,"to":48},["summary","title"]],["search","sherlock","titles",{"from":0,"to":48},"boxarts","_342x192","webp"],["search","sherlock","titles",["id","length","name","trackIds","requestId","referenceId"]],["search","sherlock","person",{"from":0,"to":20},"person","summary"],["search","sherlock","person",{"from":0,"to":20},"referenceId"],["search","sherlock","person",["summary","reference","trackId"]],["search","sherlock","suggestions",{"from":0,"to":20},["referenceId","summary"]],["search","sherlock","suggestions",["summary","reference","trackId"]]]}
    

    Yikes!!
    There really is a lot of noise there... but if you remove all the noise you end up with the following:

        "videos": {
          "$size": 224,
          "size": 224,
          "70202589": {
            "$size": 224,
            "size": 224,
            "summary": {
              "id": 70202589,
              "type": "show",
              "isNSRE": false,
              "isOriginal": false,
              "$type": "leaf",
              "$size": 68,
              "size": 68
            },
            "title": "Sherlock",
            "boxarts": {
              "$size": 155,
              "size": 155,
              "_342x192": {
                "$size": 155,
                "size": 155,
                "webp": {
                  "url": "https:\/\/art-s.nflximg.net\/bcf56\/70201cfe99efe756703fa02ea2406f36907bcf56.webp",
                  "image_key": "sdp,2|AD_169e35a0-43a9-11e6-8c38-22000bcc0076|en",
                  "$type": "leaf",
                  "$size": 155,
                  "size": 155
                }
              }
            }
          }
        }
    

    From this you should be able to easily parse the pertinent information from this title and using your favorite script (perl, python, node.js) you can easily pull out just the information you are looking for.

    Going back to Chrome you can see all of these requests and responses by just clicking on one of the pathEvaluator urls, then clicking on either 'Header' (and scrolling to the bottom to request paylod) or 'Response'

    0_1501687516437_1487419926076-upload-4992f5f0-842d-43fb-9e8b-f9a403389a99.png

    At a very basic level this should help you start navigating. In future posts we will cover accessing the API from a script and parsing the data so you can actually do useful stuff with it.


 

Looks like your connection to uNoGS Forum was lost, please wait while we try to reconnect.