Using Python to access the EIDR registry with the new JSON EIDR Rest Api

Hitesh Pau
12 min readDec 6, 2020

At a recent Media & Entertainment Day event, Richard Kroon, director of technical operations for the Entertainment ID Registry (EIDR), and Reshuffle CEO Avner Braverman shared how they expanded the EIDR API with Reshuffle to deliver new features (and fast to meet clients’ needs). In a short time, EIDR has delivered Resolve, Pass-Through (XPath) Query, and JSON Query APIs, integration with the EIDR Content ID, Video Service, and Party registries, support for all EIDR resolution types along with JSON and TSV return options via type parameter/accept header via the same API.

EIDR aims to integrate the new APIs into its own operations, add new resolution types and formats (EN 15907, RDF, ISAN), and transition EIDR from linked-data friendly to linked-data native support.

Click here to access the presentation slide deck.

In this article we will use Python to get EIDR data in JSON format using the new EIDR Apis.

Before you start reading this article, please read my previous article Using Python to access the EIDR registry with EIDR REST APIs.

Pre-requisites

  1. You have Python installed. For this tutorial, we are using Python version 3.7.4. If not, you can download Python from https://www.python.org/ Please refer to Python documentation to install Python on your machine.
  2. You have a Text editor installed on your machine. There are many python friendly editor, which helps writing Python code easier.

For Mac, you can use SublimeText, Atom, TextWrangler

For Windows, you can use Notepad, Notepad++, SublimeText, Atom

3. You can also install Jupyter, which is a web-based interactive Python development environment. You can download from https://jupyter.org/

Assumption

  1. You know basic Python programming.
  2. You are a member of EIDR and have credentials to access EIDR Registry

EIDR Rest APIs

The EIDR system provides various services using a REST based interface in combination with HTTP 1.1 (see RFC 2616).

Here is the link to the EIDR Rest API document

Note: Public services do not necessarily mean open access. Ingesting or registering data into EIDR is controlled, while reading data from EIDR is generally not restricted.

Additional technical documents available at https://www.eidr.org/technical-documentation/

Refer to Using Python to access the EIDR registry with EIDR REST APIs to do the following -

To get started…

Refer to Using Python to access the EIDR registry with EIDR REST APIs to do the following -

  1. Install the required python packages
  2. Authenticate and authorize to access EIDR Rest APIs
  3. There are three key changes to access the new EIDR Apis
  • We do not need the BeautifulSoup package anymore. Instead we will use the Python JSON package.
  • The EIDR API url has changed to https://proxy.eidr.org/ to point to the new EIDR JSON API
  • The Header parameters now processes data using JSON and not XML. We need to update the ‘Accept’ and ‘Content-Type’ arguments

The rest of the authentication process is the same.

import requests, base64, hashlib
import json
import pandas as pd
UserID = '10.5238/xxxxxxxx'. # enter your EIDR User Id
Pwd = '************' # enter your EIDR password
PartyID = '10.5237/xxxxxxxxx' # enter your EIDR party ID
url = 'https://proxy.eidr.org/' # New EIDR API URL

#Encrypt the credentials
PasswordShadow = base64.b64encode(hashlib.md5(pwd.encode('utf-8')).digest()).decode('utf8')auth_str = '%s:%s:%s' % (UserID, PartyID, PasswordShadow)headers = {'Authorization' : 'Eidr {}'.format(auth_str), 'Accept': 'application/vnd.eidr.doikernel+json', 'Content-Type': 'application/json'}

Now we write two function to get EIDR Data.

The first function is to get the EIDR data for a single EIDR ID. Here we pass 3 parameters -

  1. id: the requested EIDR ID
  2. type: the return type indicates the details required in the response. The possible values are -
  • Full — The full EIDR metadata record
  • Simple — A record summary, suitable for compact lists
  • DOIKernel — The full EIDR record cast as a DOI Kernel record
  • SelfDefined — Metadata unique to the record (excludes inherited values)
  • Provenance — Basic administrative data regarding the record, limited by the user’s credentials
  • AlternateIDs — A list of all of the Alternate Identifies associated with an EIDR record.
  • LinkedAlternateIDs — A list of all of the Alternate Identifies associated with an EIDR record and the URLs to resolve those third-party identifiers that are publicly resolvable

The default type is Full

3. format: The data may be returned in two different data formats, which can be passed as a format parameter. The possible values are -

  • JSON
  • TSV (tab-separated values; a.k.a, flat file)

The default value is JSON

def getEIDRData(id,type='Full',format='json'):
req = url + 'resolve/' + id + '?type=' + type + '&format=' + format
resp = requests.get(req, headers=headers)
return resp.content

The second function is to get EIDR data for multiple EIDR Ids in one call. This is a post call and the payload is a JSON with the list of EIDR IDs

def getMultipleEIDRData(request_ids):
req = url + 'resolve/?type=Full'
resp = requests.post(req, headers=headers, data=request_ids)
return resp.content

Let’s test the first function by passing a single EIDR ID and getting the EIDR response

eidr_resp = getEIDRData('10.5240/0EF3-54F9-2642-0B49-6829-R')

To view the EIDR response in a readable format, we use the JSON package to load the EIDR response and then format it for display

json_response = json.loads(eidr_resp)
print(json.dumps(json_response, indent=4, sort_keys=True))

The JSON response should look as below

[
{
"Administrators": {
"Registrant": "10.5237/superparty"
},
"AlternateID": [
{
"_domain": "commonsense.org/nid",
"_type": "Proprietary",
"value": "1262009"
},
{
"_domain": "commonsense.org/uuid",
"_type": "Proprietary",
"value": "3043640c-0c61-472f-9912-07464a04a8c5"
},
{
"_type": "Baseline",
"value": "4755659"
},
{
"_type": "IVA",
"value": "768340"
},
{
"_relation": "IsSameAs",
"_type": "IMDB",
"value": "tt1375666"
},
{
"_domain": "amazon.com",
"_type": "Proprietary",
"value": "B0047WJ11G"
},
{
"_domain": "flixster.com",
"_type": "Proprietary",
"value": "770805418"
},
{
"_domain": "netflix.com",
"_type": "Proprietary",
"value": "70131314"
},
{
"_domain": "thecinemasource.com",
"_type": "Proprietary",
"value": "72226"
},
{
"_domain": "warnerbros.com/MPM",
"_type": "Proprietary",
"value": "2051258"
},
{
"_domain": "veronicamagazine.nl",
"_type": "Proprietary",
"value": "846994"
},
{
"_domain": "redbeemedia.com",
"_type": "Proprietary",
"value": "30392576"
},
{
"_domain": "bfi.org.uk",
"_type": "Proprietary",
"value": "150763981"
},
{
"_domain": "comcast.com",
"_type": "Proprietary",
"value": "8368357466401273112"
},
{
"_domain": "spe.sony.com/ProductID",
"_type": "Proprietary",
"value": "924756"
},
{
"_domain": "lumiere.obs.coe.int",
"_type": "Proprietary",
"value": "34895"
},
{
"_domain": "webedia-group.com",
"_type": "Proprietary",
"value": "143692"
},
{
"_domain": "itv.com",
"_type": "Proprietary",
"value": "2/4944/0001"
},
{
"_type": "ISAN",
"value": "0000-0002-B3C8-0000-3-0000-0000-S"
},
{
"_domain": "tivo.com",
"_relation": "Other",
"_type": "Proprietary",
"value": "See-TiVo"
},
{
"_domain": "boxofficemojo.com",
"_type": "Proprietary",
"value": "inception"
},
{
"_domain": "wikidata.org",
"_type": "Proprietary",
"value": "Q25188"
},
{
"_domain": "citwf.com",
"_type": "Proprietary",
"value": "464713"
},
{
"_domain": "dfi.dk/movie",
"_type": "Proprietary",
"value": "66644"
},
{
"_domain": "sfi.se",
"_type": "Proprietary",
"value": "71224"
},
{
"_domain": "afidb.com",
"_type": "Proprietary",
"value": "66167"
},
{
"_domain": "tcm.com",
"_type": "Proprietary",
"value": "774971"
},
{
"_domain": "opusdata.com/movie",
"_type": "Proprietary",
"value": "105240100"
},
{
"_domain": "the-numbers.com/movie",
"_type": "Proprietary",
"value": "Inception"
},
{
"_domain": "themoviedb.org/movie",
"_type": "Proprietary",
"value": "27205"
},
{
"_domain": "cinematheque.qc.ca",
"_type": "Proprietary",
"value": "94467"
},
{
"_domain": "moviemeter.nl",
"_type": "Proprietary",
"value": "59666"
},
{
"_domain": "movie.douban.com",
"_type": "Proprietary",
"value": "3541415"
},
{
"_domain": "port.hu",
"_type": "Proprietary",
"value": "105025"
},
{
"_domain": "cinemagia.ro",
"_type": "Proprietary",
"value": "34077"
},
{
"_domain": "cine.gr",
"_type": "Proprietary",
"value": "712808"
},
{
"_domain": "edb.co.il",
"_type": "Proprietary",
"value": "t0013302"
},
{
"_domain": "csfd.cz",
"_type": "Proprietary",
"value": "254156"
},
{
"_domain": "internetvideoarchive.com",
"_type": "Proprietary",
"value": "Movie/23858"
},
{
"_domain": "varietyinsight.com",
"_type": "Proprietary",
"value": "53295"
},
{
"_domain": "moviebuff.com",
"_type": "Proprietary",
"value": "d9454fd8-a7e9-4271-a128-10ac29e26663"
},
{
"_domain": "prisma.de",
"_type": "Proprietary",
"value": "525603"
},
{
"_domain": "movieplayer.it/film",
"_type": "Proprietary",
"value": "22765"
},
{
"_domain": "ofdb.de",
"_type": "Proprietary",
"value": "195180"
},
{
"_domain": "tvguide.com",
"_type": "Proprietary",
"value": "305285"
},
{
"_domain": "siamzone.com",
"_type": "Proprietary",
"value": "5815"
},
{
"_domain": "cnc.fr/visa",
"_type": "Proprietary",
"value": "126718"
}
],
"ApproximateLength": "PT2H28M",
"AssociatedOrg": [
{
"DisplayName": "Legendary Pictures",
"_idType": "EIDRPartyID",
"_organizationID": "10.5237/5538-B194",
"_role": "producer"
},
{
"DisplayName": "Syncopy",
"_idType": "EIDRPartyID",
"_organizationID": "10.5237/1C9A-B03F",
"_role": "producer"
},
{
"AlternateName": [
"WB"
],
"DisplayName": "Warner Bros",
"_idType": "EIDRPartyID",
"_organizationID": "10.5237/A929-C667",
"_role": "producer"
}
],
"CountryOfOrigin": [
"US",
"GB"
],
"Credits": {
"Actor": [
{
"DisplayName": "Leonardo DiCaprio"
},
{
"DisplayName": "Joseph Gordon-Levitt"
}
],
"Director": [
{
"DisplayName": "Christopher Nolan"
}
]
},
"ID": "10.5240/0EF3-54F9-2642-0B49-6829-R",
"Mode": "AudioVisual",
"OriginalLanguage": [
{
"_mode": "Audio",
"_type": "primary",
"value": "en"
}
],
"ReferentType": "Movie",
"ReleaseDate": "2010",
"ResourceName": {
"_lang": "en",
"_titleClass": "release",
"value": "Inception"
},
"Status": "valid",
"StructuralType": "Abstraction"
},
{
"Administrators": {
"Registrant": "10.5237/A929-C667"
},
"AlternateID": [
{
"_domain": "commonsense.org/nid",
"_type": "Proprietary",
"value": "6195180"
},
{
"_domain": "commonsense.org/uuid",
"_type": "Proprietary",
"value": "58a2f623-6b88-4a0a-bf0b-6265a3912504"
},
{
"_domain": "warnerbros.com/MPM",
"_type": "Proprietary",
"value": "2079316"
},
{
"_domain": "opusdata.com/movie",
"_type": "Proprietary",
"value": "299230100"
},
{
"_domain": "the-numbers.com/movie",
"_type": "Proprietary",
"value": "Wonder-Woman-2"
},
{
"_domain": "the-numbers.com/movie",
"_type": "Proprietary",
"value": "Wonder-Woman-1984"
},
{
"_domain": "varietyinsight.com",
"_type": "Proprietary",
"value": "142737"
},
{
"_relation": "IsSameAs",
"_type": "IMDB",
"value": "tt7126948"
},
{
"_domain": "wikidata.org",
"_relation": "IsSameAs",
"_type": "Proprietary",
"value": "Q33408623"
},
{
"_domain": "themoviedb.org/movie",
"_relation": "IsSameAs",
"_type": "Proprietary",
"value": "464052"
},
{
"_relation": "IsSameAs",
"_type": "ISAN",
"value": "0000-0005-4E91-0000-2-0000-0000-V"
},
{
"_domain": "boxofficemojo.com",
"_type": "Proprietary",
"value": "wbeventfilmiii19"
},
{
"_domain": "letterboxd.com",
"_relation": "IsSameAs",
"_type": "Proprietary",
"value": "wonder-woman-1984"
},
{
"_domain": "internetvideoarchive.com",
"_type": "Proprietary",
"value": "Movie/154618"
},
{
"_domain": "moviebuff.com",
"_type": "Proprietary",
"value": "c0facda5-6394-4d8d-9e8b-acdcd2f456df"
}
],
"AlternateResourceName": [
{
"_lang": "en",
"_titleClass": "other",
"value": "Wonder Woman 2"
}
],
"ApproximateLength": "PT1H30M",
"AssociatedOrg": [
{
"AlternateName": [
"WB"
],
"DisplayName": "Warner Bros",
"_idType": "EIDRPartyID",
"_organizationID": "10.5237/A929-C667",
"_role": "producer"
},
{
"DisplayName": "DC Entertainment",
"_idType": "EIDRPartyID",
"_organizationID": "10.5237/23A2-7A4B",
"_role": "producer"
},
{
"DisplayName": "Atlas Entertainment",
"_role": "producer"
},
{
"DisplayName": "The Stone Quarry",
"_role": "producer"
}
],
"CountryOfOrigin": [
"US"
],
"Credits": {
"Actor": [
{
"DisplayName": "Gal Gadot"
},
{
"DisplayName": "Pedro Pascal"
},
{
"DisplayName": "Robin Wright"
},
{
"DisplayName": "Gabriella Wilde"
}
],
"Director": [
{
"DisplayName": "Patty Jenkins"
}
]
},
"ID": "10.5240/1B62-64ED-A354-C5A1-EBFC-7",
"Mode": "AudioVisual",
"OriginalLanguage": [
{
"_mode": "Audio",
"_type": "primary",
"value": "en"
}
],
"ReferentType": "Movie",
"RegistrantExtra": "AL:Pro;",
"ReleaseDate": "2020-12-25",
"ResourceName": {
"_lang": "en",
"_titleClass": "release",
"value": "Wonder Woman 1984"
},
"Status": "valid",
"StructuralType": "Abstraction"
}
]

Let’s test the second function to pull EIDR data for multiple EIDR IDs in one call. First we create the JSON payload with the list of EIDR IDs and then we pass it to the getMultipleEIDRData function.

eidr_list = '{"ids": ["10.5240/0EF3-54F9-2642-0B49-6829-R","10.5240/1B62-64ED-A354-C5A1-EBFC-7"]}'eidr_resp = getMultipleEIDRData(eidr_list)

You can load and format the JSON response as before

json_response = json.loads(eidr_resp)
print(json.dumps(json_response, indent=4, sort_keys=True))

The JSON response for multiple IDs (in this case 2 IDs were passed) looks as below

[
{
"Administrators": {
"Registrant": "10.5237/superparty"
},
"AlternateID": [
{
"_domain": "commonsense.org/nid",
"_type": "Proprietary",
"value": "1262009"
},
{
"_domain": "commonsense.org/uuid",
"_type": "Proprietary",
"value": "3043640c-0c61-472f-9912-07464a04a8c5"
},
{
"_type": "Baseline",
"value": "4755659"
},
{
"_type": "IVA",
"value": "768340"
},
{
"_relation": "IsSameAs",
"_type": "IMDB",
"value": "tt1375666"
},
{
"_domain": "amazon.com",
"_type": "Proprietary",
"value": "B0047WJ11G"
},
{
"_domain": "flixster.com",
"_type": "Proprietary",
"value": "770805418"
},
{
"_domain": "netflix.com",
"_type": "Proprietary",
"value": "70131314"
},
{
"_domain": "thecinemasource.com",
"_type": "Proprietary",
"value": "72226"
},
{
"_domain": "warnerbros.com/MPM",
"_type": "Proprietary",
"value": "2051258"
},
{
"_domain": "veronicamagazine.nl",
"_type": "Proprietary",
"value": "846994"
},
{
"_domain": "redbeemedia.com",
"_type": "Proprietary",
"value": "30392576"
},
{
"_domain": "bfi.org.uk",
"_type": "Proprietary",
"value": "150763981"
},
{
"_domain": "comcast.com",
"_type": "Proprietary",
"value": "8368357466401273112"
},
{
"_domain": "spe.sony.com/ProductID",
"_type": "Proprietary",
"value": "924756"
},
{
"_domain": "lumiere.obs.coe.int",
"_type": "Proprietary",
"value": "34895"
},
{
"_domain": "webedia-group.com",
"_type": "Proprietary",
"value": "143692"
},
{
"_domain": "itv.com",
"_type": "Proprietary",
"value": "2/4944/0001"
},
{
"_type": "ISAN",
"value": "0000-0002-B3C8-0000-3-0000-0000-S"
},
{
"_domain": "tivo.com",
"_relation": "Other",
"_type": "Proprietary",
"value": "See-TiVo"
},
{
"_domain": "boxofficemojo.com",
"_type": "Proprietary",
"value": "inception"
},
{
"_domain": "wikidata.org",
"_type": "Proprietary",
"value": "Q25188"
},
{
"_domain": "citwf.com",
"_type": "Proprietary",
"value": "464713"
},
{
"_domain": "dfi.dk/movie",
"_type": "Proprietary",
"value": "66644"
},
{
"_domain": "sfi.se",
"_type": "Proprietary",
"value": "71224"
},
{
"_domain": "afidb.com",
"_type": "Proprietary",
"value": "66167"
},
{
"_domain": "tcm.com",
"_type": "Proprietary",
"value": "774971"
},
{
"_domain": "opusdata.com/movie",
"_type": "Proprietary",
"value": "105240100"
},
{
"_domain": "the-numbers.com/movie",
"_type": "Proprietary",
"value": "Inception"
},
{
"_domain": "themoviedb.org/movie",
"_type": "Proprietary",
"value": "27205"
},
{
"_domain": "cinematheque.qc.ca",
"_type": "Proprietary",
"value": "94467"
},
{
"_domain": "moviemeter.nl",
"_type": "Proprietary",
"value": "59666"
},
{
"_domain": "movie.douban.com",
"_type": "Proprietary",
"value": "3541415"
},
{
"_domain": "port.hu",
"_type": "Proprietary",
"value": "105025"
},
{
"_domain": "cinemagia.ro",
"_type": "Proprietary",
"value": "34077"
},
{
"_domain": "cine.gr",
"_type": "Proprietary",
"value": "712808"
},
{
"_domain": "edb.co.il",
"_type": "Proprietary",
"value": "t0013302"
},
{
"_domain": "csfd.cz",
"_type": "Proprietary",
"value": "254156"
},
{
"_domain": "internetvideoarchive.com",
"_type": "Proprietary",
"value": "Movie/23858"
},
{
"_domain": "varietyinsight.com",
"_type": "Proprietary",
"value": "53295"
},
{
"_domain": "moviebuff.com",
"_type": "Proprietary",
"value": "d9454fd8-a7e9-4271-a128-10ac29e26663"
},
{
"_domain": "prisma.de",
"_type": "Proprietary",
"value": "525603"
},
{
"_domain": "movieplayer.it/film",
"_type": "Proprietary",
"value": "22765"
},
{
"_domain": "ofdb.de",
"_type": "Proprietary",
"value": "195180"
},
{
"_domain": "tvguide.com",
"_type": "Proprietary",
"value": "305285"
},
{
"_domain": "siamzone.com",
"_type": "Proprietary",
"value": "5815"
},
{
"_domain": "cnc.fr/visa",
"_type": "Proprietary",
"value": "126718"
}
],
"ApproximateLength": "PT2H28M",
"AssociatedOrg": [
{
"DisplayName": "Legendary Pictures",
"_idType": "EIDRPartyID",
"_organizationID": "10.5237/5538-B194",
"_role": "producer"
},
{
"DisplayName": "Syncopy",
"_idType": "EIDRPartyID",
"_organizationID": "10.5237/1C9A-B03F",
"_role": "producer"
},
{
"AlternateName": [
"WB"
],
"DisplayName": "Warner Bros",
"_idType": "EIDRPartyID",
"_organizationID": "10.5237/A929-C667",
"_role": "producer"
}
],
"CountryOfOrigin": [
"US",
"GB"
],
"Credits": {
"Actor": [
{
"DisplayName": "Leonardo DiCaprio"
},
{
"DisplayName": "Joseph Gordon-Levitt"
}
],
"Director": [
{
"DisplayName": "Christopher Nolan"
}
]
},
"ID": "10.5240/0EF3-54F9-2642-0B49-6829-R",
"Mode": "AudioVisual",
"OriginalLanguage": [
{
"_mode": "Audio",
"_type": "primary",
"value": "en"
}
],
"ReferentType": "Movie",
"ReleaseDate": "2010",
"ResourceName": {
"_lang": "en",
"_titleClass": "release",
"value": "Inception"
},
"Status": "valid",
"StructuralType": "Abstraction"
},
{
"Administrators": {
"Registrant": "10.5237/A929-C667"
},
"AlternateID": [
{
"_domain": "commonsense.org/nid",
"_type": "Proprietary",
"value": "6195180"
},
{
"_domain": "commonsense.org/uuid",
"_type": "Proprietary",
"value": "58a2f623-6b88-4a0a-bf0b-6265a3912504"
},
{
"_domain": "warnerbros.com/MPM",
"_type": "Proprietary",
"value": "2079316"
},
{
"_domain": "opusdata.com/movie",
"_type": "Proprietary",
"value": "299230100"
},
{
"_domain": "the-numbers.com/movie",
"_type": "Proprietary",
"value": "Wonder-Woman-2"
},
{
"_domain": "the-numbers.com/movie",
"_type": "Proprietary",
"value": "Wonder-Woman-1984"
},
{
"_domain": "varietyinsight.com",
"_type": "Proprietary",
"value": "142737"
},
{
"_relation": "IsSameAs",
"_type": "IMDB",
"value": "tt7126948"
},
{
"_domain": "wikidata.org",
"_relation": "IsSameAs",
"_type": "Proprietary",
"value": "Q33408623"
},
{
"_domain": "themoviedb.org/movie",
"_relation": "IsSameAs",
"_type": "Proprietary",
"value": "464052"
},
{
"_relation": "IsSameAs",
"_type": "ISAN",
"value": "0000-0005-4E91-0000-2-0000-0000-V"
},
{
"_domain": "boxofficemojo.com",
"_type": "Proprietary",
"value": "wbeventfilmiii19"
},
{
"_domain": "letterboxd.com",
"_relation": "IsSameAs",
"_type": "Proprietary",
"value": "wonder-woman-1984"
},
{
"_domain": "internetvideoarchive.com",
"_type": "Proprietary",
"value": "Movie/154618"
},
{
"_domain": "moviebuff.com",
"_type": "Proprietary",
"value": "c0facda5-6394-4d8d-9e8b-acdcd2f456df"
}
],
"AlternateResourceName": [
{
"_lang": "en",
"_titleClass": "other",
"value": "Wonder Woman 2"
}
],
"ApproximateLength": "PT1H30M",
"AssociatedOrg": [
{
"AlternateName": [
"WB"
],
"DisplayName": "Warner Bros",
"_idType": "EIDRPartyID",
"_organizationID": "10.5237/A929-C667",
"_role": "producer"
},
{
"DisplayName": "DC Entertainment",
"_idType": "EIDRPartyID",
"_organizationID": "10.5237/23A2-7A4B",
"_role": "producer"
},
{
"DisplayName": "Atlas Entertainment",
"_role": "producer"
},
{
"DisplayName": "The Stone Quarry",
"_role": "producer"
}
],
"CountryOfOrigin": [
"US"
],
"Credits": {
"Actor": [
{
"DisplayName": "Gal Gadot"
},
{
"DisplayName": "Pedro Pascal"
},
{
"DisplayName": "Robin Wright"
},
{
"DisplayName": "Gabriella Wilde"
}
],
"Director": [
{
"DisplayName": "Patty Jenkins"
}
]
},
"ID": "10.5240/1B62-64ED-A354-C5A1-EBFC-7",
"Mode": "AudioVisual",
"OriginalLanguage": [
{
"_mode": "Audio",
"_type": "primary",
"value": "en"
}
],
"ReferentType": "Movie",
"RegistrantExtra": "AL:Pro;",
"ReleaseDate": "2020-12-25",
"ResourceName": {
"_lang": "en",
"_titleClass": "release",
"value": "Wonder Woman 1984"
},
"Status": "valid",
"StructuralType": "Abstraction"
}
]

You can see that details of both Ids are present in the JSON list.You can parse the response using the python JSON package as below -

for eidr in json_response:
print(eidr['ID'] + ' - ' + eidr['ResourceName']['value'])

Now, you can read a file with multiple EIDRs and use the getMultipleEIDRData function to get data for all the EIDR IDs.

  • Create a text file with the EIDR IDs (filename: input_eidrs.txt)
  • read the file and create a JSON payload with the EIDR IDs
  • Pass the JSON to getMultipleEIDRData function
  • load and parse the JSON response into the output list
  • create a dataframe from the output list
inputFile = 'input_eidrs.txt'# read the input file
with open(inputFile) as f:
eidrs = f.read().splitlines()
#create the json payload with the EIDR IDs
input_list = {"ids":eidrs}
#call the EIDR Api
eidr_resp = getMultipleEIDRData(json.dumps(input_list))
#load the json response
json_response = json.loads(eidr_resp)
#parse the json reponse and save the values in the output list
output_list = []
for eidr in json_response:
EIDR_Id = eidr['ID']
Title = eidr['ResourceName']['value']
StructureType = eidr['StructuralType']
Type = eidr['ReferentType']
ReleaseYear = eidr['ReleaseDate']
RunTime = eidr['ApproximateLength']

output_list.append([EIDR_Id, Title, StructureType, Type, ReleaseYear, RunTime])
#create a panda dataframe using the output list
df_output = pd.DataFrame(output_list, columns =['ID', 'Title', 'StructuralType', 'Type', 'ReleaseYear', 'Runtime'])
#display the top 5 records of the dataframe
df_output.head()
  • Export the output dataframe to an excel file
df_output.to_excel('eidr_data.xlsx')

This covers the basic framework to access the new EIDR APIs using Python

Also check out:

how to get EIDR data from Alternate Ids

Using Python to check EIDR token Status

--

--