Card image cap
Integrations/ May 29, 2021 ()

OpenGraphr + Netflix: Extract movie information from Netflix using our Open Graph API

A new year brings new changes, and we are glad to announce that we are improving our robots to provide you with even better metadata information from Netflix!

Extracting information from a Netflix link

First of all, enter your profile and copy your token. You will need it for the following steps :-)

We will be making a GET request to the following API endpoint: https://api.opengraphr.com/v1/og.

To make a request, you will need to include your api_token and the requested url:

GET https://api.opengraphr.com/v1/og?api_token={YOUR_API_TOKEN}&url={YOUR_URL}.

By default, our API will cache results for a month, but you can refresh the cache by sending the force=1 parameter:

GET https://api.opengraphr.com/v1/og?api_token={YOUR_API_TOKEN}&url={YOUR_URL}&force=1.

Using our API to extract Netflix metadata

Once the GET request is sent, you will get a response like this from our API. In this case, we are requesting the following URL: https://www.netflix.com/es-en/title/81036936

{
    "title": "The Innocent | Netflix Official Site",
    "description": "An accidental killing leads a man down a dark hole of intrigue and murder. Just as he finds love and freedom, one phone call brings back the nightmare.",
    "image": "https:\/\/occ-0-1168-299.1.nflxso.net\/dnm\/api\/v6\/E8vDc_W8CLv7-yMQu8KMEC7Rrr8\/AAAABTPh9133CVfQYvfNjQnOGb0gC14eybyk11NHKHBhKehDSuCh1KMmT51CgY0AlqB4K56PU7liG7Oqh9JI5I8ROChho6GE.jpg?r=d92",
    "url": "https:\/\/www.netflix.com\/gb\/title\/81036936",
    "raw": {
        "title": "The Innocent | Netflix Official Site",
        "metadescription": "An accidental killing leads a man down a dark hole of intrigue and murder. Just as he finds love and freedom, one phone call brings back the nightmare. Watch trailers & learn more.",
        "og_title": "The Innocent | Netflix Official Site",
        "og_description": "An accidental killing leads a man down a dark hole of intrigue and murder. Just as he finds love and freedom, one phone call brings back the nightmare.",
        "og_url": "https:\/\/www.netflix.com\/gb\/title\/81036936",
        "og_image": "https:\/\/occ-0-1168-299.1.nflxso.net\/dnm\/api\/v6\/E8vDc_W8CLv7-yMQu8KMEC7Rrr8\/AAAABTPh9133CVfQYvfNjQnOGb0gC14eybyk11NHKHBhKehDSuCh1KMmT51CgY0AlqB4K56PU7liG7Oqh9JI5I8ROChho6GE.jpg?r=d92",
        "og_video": "https:\/\/occ-0-1168-299.1.nflxso.net\/so\/soa3\/364\/b6a67a13bfd8beb131584c9adde81c67.mp4?v=1",
        "og_video_secure_url": "https:\/\/occ-0-1168-299.1.nflxso.net\/so\/soa3\/364\/b6a67a13bfd8beb131584c9adde81c67.mp4?v=1",
        "og_video_type": "video\/mp4",
        "twitter_card": "summary_large_image",
        "twitter_site": "@netflix"
    }
}

And that's it! Easy, right? Now let's see some examples of how to implement this using actual code!

Extract Netflix information using PHP

You can easily get the Open Graph information of a given Netflix link by using the following script in PHP:

$token = 'YOUR_TOKEN';
$url = 'https://www.netflix.com/es-en/title/81036936';

$requestUrl = 'https://api.opengraphr.com/v1/og?api_token=' . $token . '&url=' . urlencode($url);
$response = json_decode(file_get_contents($requestUrl), true);

var_dump($response);

Extract Netflix information using JavaScript

You can easily get the Open Graph information of a given Netflix URL by using the following script in plain JS:

const token = 'YOUR_TOKEN'
const url = 'https://www.netflix.com/es-en/title/81036936'

const requestUrl = `https://api.opengraphr.com/v1/og?api_token=${token}&url=${encodeURIComponent(url)}`
fetch(requestUrl)
    .then(response => response.json())
    .then(og => {
        console.table(og)
    })

Extract Netflix information using NodeJS

You can easily get the Open Graph information of a given Netflix URL by using the following script in NodeJS:

const axios = require('axios')
const express = require('express')
const app = express()
const token = 'YOUR_TOKEN'

app.get('/site/info', async (req, res) => {
    const { url } = req.query
    const requestUrl = 'https://www.netflix.com/es-en/title/81036936'

    const response = await axios.get(requestUrl, {
        params: {
            url,
            api_token: token,
            // force: 1,
        },
    })
    const og = response.data
    res.json(og)
})

app.listen(3000, function () {
    console.log('Example app listening on port 3000!')
})

Extract Netflix information using C-Sharp

You can easily get the Open Graph information of a given Netflix URL by using the following script in C#:

using System;
using System.Net;
using System.IO;
using Newtonsoft.Json;

namespace CSharpDemo
{
    class MainClass
    {
        public static void Main (string[] args)
        {
            var token = 'YOUR_TOKEN';
            var url = 'https://www.netflix.com/es-en/title/81036936';
            var urlEncoded = Uri.EscapeDataString(url);

            var requestUrl = "https://api.opengraphr.com/api/og?api_token=" + token + "&url=" + urlEncoded;

            var request = WebRequest.Create(requestUrl);
            request.ContentType = "application/json;";

            string text;

            var response = (HttpWebResponse)request.GetResponse();

            using (var sr = new StreamReader(response.GetResponseStream()))
            {
                text = sr.ReadToEnd();

                dynamic og = JsonConvert.DeserializeObject(text);

                Console.WriteLine("Title\t\t" + og.title);
                Console.WriteLine("Description\t" + og.description);
                Console.WriteLine("Image\t\t" + og.image);
            }
        }
    }
}

Extract Netflix information using Python

You can easily get the Open Graph information of a given Netflix URL by using the following script in Python:

import requests

TOKEN = 'YOUR_TOKEN'
url = 'https://www.netflix.com/es-en/title/81036936'

endpoint = 'https://api.opengraphr.com/api/og'
response = requests.get(endpoint, params={ 'url': url, 'api_token': TOKEN }).json()
print(response)