I have a Python function for calling the Microsoft Academic API evaluate method. The function currently takes in the author name and returns citation count:
import requests
def get_author_CC(subscription_key, author_name):
url = 'https://api.labs.cognitive.microsoft.com/academic/v1.0/evaluate'
params = {
"expr": f"Composite(AA.AuN=='{author_name}')",
"attributes": "ECC,CC",
'count': 10000
}
headers = {'Ocp-Apim-Subscription-Key': subscription_key}
r = requests.get(url, params=params, headers=headers).json().get('entities')
return sum([ld.get('ECC') for ld in r])
Since I know the affiliation of several of the authors I am interested in querying for, I would like to add the affiliation parameter to the request. However, I am not quite understanding how to go about doing that. I have tried this:
import requests
def get_author_CC(subscription_key, author_name, affiliation):
url = 'https://api.labs.cognitive.microsoft.com/academic/v1.0/evaluate'
params = {
"expr": f"Composite(AA.AuN=='{author_name}', Ty==5, AfN=='{affiliation}')",
"attributes": "ECC,CC",
'count': 10000
}
headers = {'Ocp-Apim-Subscription-Key': subscription_key}
r = requests.get(url, params=params, headers=headers).json().get('entities')
return sum([ld.get('ECC') for ld in r])
but that returned errors, so obviously that wasn't quite right.
As an example, one author I am looking at is laurens van der maaten who has about 40,000+ citation counts and is affiliated with Facebook. So the new function should still return 40,000+ citation counts but use the fact that she was at Facebook to narrow the search (especially useful for more common names).
Any help here is much appreciated. Thanks.