Search code examples
pythonapiweb-servicessearchacademic-graph

Return correct number of citations from Microsoft Academic API


I'm trying to get citation count for several authors using Microsoft Academic API. However, I'm finding that my manual searches retrieve different results than the API call. For example, the author Laurens van der Maaten appears to have 40,747 citations (see here). However, when I I try using the API call as shown below (using Python), I get fewer results.

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": "CC"
    }
    headers = {'Ocp-Apim-Subscription-Key': subscription_key}

    r = requests.get(url, params=params, headers=headers).json().get('entities')
    
    return sum([ld.get('CC') for ld in r])

get_author_CC(subscription_key="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", author_name="laurens van der maaten")
>>> 26545

Is there a parameter or something I'm missing? Thanks.


Solution

  • After going through the docs, I think you need to use ECC which is the estimated citation count. Also, you need to provide count in the params, since the default is count=10

    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])
    
    get_author_CC(subscription_key="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", author_name="laurens van der maaten")