Scopus API in Mathematica#
by Vishank Patel
These recipe examples use the Elsevier Scopus API and Mathematica’s inbuilt functionalities to manipulate and visualize data. Code was tested and sample data downloaded from the Scopus API on March 6, 2022 via http://api.elsevier.com and http://www.scopus.com. This tutorial content is intended to help facilitate academic research. Before continuing or reusing any of this code, please be aware of Elsevier’s API policies and appropriate use-cases. You will also need to register for an API key in order to use the Scopus API.
Setup#
We will start by setting up the API key. If you do not have a key already, one can be obtained from the following link: https://dev.elsevier.com/apikey/manage.
Once obtained, save the key in a text file in the same directory as the current Mathematica notebook and import your key as follows:
myAPIKey = Import["INSERT PATH HERE"];
We will concatenate the key at the end of every URL using <>, the shortcut for StringJoin.
3. Get References via a Title Search#
Number of Title Match Records#
Search Scopus for all references containing’ ChemSpider’ in the record title
q2=Import["https://api.elsevier.com/content/search/scopus?query=TITLE(ChemSpider)&apiKey="<>myAPIKey,
"RawJSON"];
q2["search-results"]["opensearch:totalResults"]
7
Repeat this in a loop to get number of Scopus records for each title search
titleWordList={"ChemSpider","PubChem","ChEMBL","Reaxys","SciFinder"};
numRecordsTitle={};
For[i=1,i<=Length[titleWordList],i++,
qt=Import["https://api.elsevier.com/content/search/scopus?query=TITLE("<>titleWordList[[i]]<>")&apiKey="<>myAPIKey,"RawJSON"];
numt=qt["search-results"]["opensearch:totalResults"];
AppendTo[numRecordsTitle,{titleWordList[[i]],numt}];
Pause[1]
]
numRecordsTitle
{{ChemSpider, 7}, {PubChem, 82}, {ChEMBL, 53}, {Reaxys, 8}, {SciFinder, 31}}
Download Title Match Record Data#
Download records and create a list of selected metadata
titleWordList={"ChemSpider","PubChem","ChEMBL","Reaxys","SciFinder"};
scopusTitleData={};
For[i=1,i<=Length[titleWordList],i++,
qt=Import["https://api.elsevier.com/content/search/scopus?query=TITLE("<>titleWordList[[i]]<>")&apiKey="<>myAPIKey,"RawJSON"]["search-results"]["entry"];
doiList=qt[[All,"prism:doi"]];
titleList=qt[[All,"dc:title"]];
coverDateList=qt[[All,"prism:coverDate"]];
AppendTo[scopusTitleData,{titleWordList[[i]],doiList,titleList,coverDateList}];
Pause[1]
]
scopusTitleData // Dataset
Output not shown here
scopusTitleData[[1]]
Creating a flat list of scopusTitleData
scopusTitleDataFlat={};
For[i=1,i<=Length[titleWordList],i++,
For[j=1,j<=Length[scopusTitleData[[i,2]]],j++,
AppendTo[scopusTitleDataFlat,{titleWordList[[i]],scopusTitleData[[i,2,j]],scopusTitleData[[i,3,j]],scopusTitleData[[i,4,j]]}]
]
]
scopusTitleDataFlat // Dataset
scopusTitleDataFlatNamed =
<|"titleWord"->scopusTitleDataFlat[[All,1]],"doi"->scopusTitleDataFlat[[All,2]],"title"->scopusTitleDataFlat[[All,3]],"coverDate"->scopusTitleDataFlat[[All,4]]|>;
Transpose[Dataset[scopusTitleDataFlatNamed]]