Skip to content

Citation Badge

Alan Silva edited this page Feb 5, 2022 · 2 revisions

How to Create a Citation Badge Using Google Scholar

For the Impatient

  1. Get your SerpAPI API_KEY;
  2. Clone this RunKit Notebook, modify it accordingly and copy the URL endpoint;
  3. Use that URL in Shields.IO.

The Details

We'll need:

  1. Google Scholar Search API (https://serpapi.com);
  2. RunKit Endpoint (https://runkit.com);
  3. Shields.IO Endpoint (https://shields.io/endpoint).

Introduction

I'm going to use my own case as an example. I want to find the number of citations for the article "ACPYPE - Antechamber python parser interface".

So, in https://scholar.google.com, search specifically for "ACPYPE - Antechamber python parser interface", the title of the article in double quotes. We want this search to have the wanted result at the top.

1. Get Your API KEY from SerpAPI

Now, let's use SerpAPI to create your Google Scholar Search API. You'll need to register, and the free plan gives you 100 queries per month. One may think this is too little but, remember, does your article get hundreds of citations in a month? If so, wow, congratulations! Anyway, updating the citation number once a month seems pretty reasonable, don't you agree? If you don't, please take a paid plan with SerpAPI (but it's not cheap, starting at $50/month, ouch!).

Once registered and signed in, take note of your API_KEY.

That's enough for now, and you can go to the next step but, if you want to explore more, go to the SerpAPI playground, enter, e.g., "ACPYPE-Antechamber python parser interface" in the Search Query box and hit Search.

In Advanced Parameters, you can narrow your search per year, for example, so I added in fields as_ylo (from year) and as_yhi (to year) the value 2012 (the year of the wanted paper). The whole point here, even if you don't get your solely wanted result, the aim here is to have some certainty that the wanted paper will top your search, this is critical if you really want your badge to show the citations number for the right paper.

2. Create Your RunKit Endpoint

Go to this RunKit Notebook and clone it. It's not necessary to register, but I strongly recommend it. If you don't register, you need to replace var process.env.api_key with your API_KEY explicitly!

Being registered you can hide your API_KEY in https://runkit.com/settings/environment, by defining api_key and its value in Name and Value fields respectively.

Once cloned, edit your notebook accordingly, aiming to always get your desired query result at the top. You only need to modify params JS object:

// Google Scholar search for the number of citations of a specific article title
let params = {
    engine: "google_scholar",
    as_ylo: "2012", // restrict you search to a year
    as_yhi: "2012", // restrict you search to a year
    q: '"ACPYPE-Antechamber python parser interface"', // use double-quotes for specific title
    hl: "en",
    // there are several other parameters for refining a query
};

Once ready, click the endpoint link, verify the result, which should be a JSON like:

{
    "schemaVersion": 1,
    "label": "citations",
    "message": "1417",
    "color": "orange",
    "cacheSeconds": 604800
}

And, if all looks fine, retrieve the URL generated for this endpoint, something like https://xxxxxxxxxx.runkit.sh/.

3. Create Your Badge With Shields.IO Endpoint

Go to Shields.IO Endpoint. Follow the instructions. If you want, you can customise your JSON response following their schema instructions. You can, for example, change cacheSeconds, which, in our RunKit Notebook, is set for a week (604,800 seconds).

If all goes according to the plan you should get a badge like this:

![Custom badge](https://img.shields.io/endpoint?style=plastic&url=https%3A%2F%2Fgsch-citations-kjn1x4rc56s9.runkit.sh%2F)

Custom badge