Tutorial#

Here we will show the basic commands for working with pygscholar. When you install pygscholar you will get access to the scholar command which you can use in the terminal. In this tutorial we are running the commands from a notebook and therefore all commands starts with a !. However if you are using a terminal, then you should not use the ! in front of the command.

The help option#

To see all the available options, you can type

$ scholar --help
!scholar --help
                                                                                
 Usage: scholar [OPTIONS] COMMAND [ARGS]...                                     
                                                                                
 Command line interface for pygscholar. You can also set the environment        
 variable `PYSCHOLAR_CACHE_DIR` to change the default cache directory.          
                                                                                
                                                                                
╭─ Options ────────────────────────────────────────────────────────────────────╮
 --version                     Show version                                   
 --license                     Show license                                   
 --install-completion          Install completion for the current shell.      
 --show-completion             Show completion for the current shell, to copy 
                               it or customize the installation.              
 --help                        Show this message and exit.                    
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────────╮
 list-authors                       List all authors                          
 search-author                      Search for authors                        
 add-author                         Add new author                            
 remove-author                      Remove author                             
 list-author-publications           List authors publications                 
 list-new-author-publications       List new authors publications             
 list-department-publications       List department publications              
 list-new-department-publications   List department publications              
 generate-test-data                 Generate test data                        
 download-test-data                 Download test data                        
╰──────────────────────────────────────────────────────────────────────────────╯

This will list all the available options with a message explaining the different sub-commands. For each sub-command you can also use the --help option, e.g

$ scholar add-author --help
!scholar add-author --help
                                                                                
 Usage: scholar add-author [OPTIONS] NAME                                       
                                                                                
 Add new author                                                                 
                                                                                
                                                                                
╭─ Arguments ──────────────────────────────────────────────────────────────────╮
 *    name      TEXT  [default: None] [required]                              
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Options ────────────────────────────────────────────────────────────────────╮
 --scholar-id        TEXT                                                     
 --cache-dir         TEXT                 [default: /home/runner/.pygscholar] 
 --backend           [scraper|scholarly]  [default: scraper]                  
 --help                                   Show this message and exit.         
╰──────────────────────────────────────────────────────────────────────────────╯

First we will download some test data in order not to spam Google Scholar with requests. This is only needed because Google scholar rejects requests if they are coming from an automated service. This is not needed if you run this from the terminal.

!scholar download-test-data local_db.json
Downloading test data from https://drive.google.com/uc?id=14VERTNNbU8l-24SDJKkGZqXuHvALtDfI&export=download to local_db.json

Adding an author to your database#

The way pygscholar works is that you need to add authors to a database in order for pygscholar to find them. First we can try to list all the authors in our database using the command

$ scholar list-authors
!scholar list-authors
2025-05-10 11:12:58 [info     ] Cache dir /home/runner/.pygscholar does not exist. Creating...
       Authors       
┏━━━━━━┳━━━━━━━━━━━━┓
┃ Name  Scholar ID ┃
┡━━━━━━╇━━━━━━━━━━━━┩
└──────┴────────────┘

Now we could try to add an author to the database by using the command

$ scholar add-author <name of author>

e.g

$ scholar add-author 'Henrik Finsberg'
!scholar add-author 'Henrik Finsberg'
2025-05-10 11:12:59 [info     ] Searching for author Henrik Finsberg
2025-05-10 11:12:59 [debug    ] Found 1 author(s)             
Adding author Henrik Nicolay Finsberg
Successfully added author with name Henrik Nicolay Finsberg and scholar id NDPIHoEAAAAJ
Search for publications. This can take some time
2025-05-10 11:12:59 [info     ] Get author info for Henrik Nicolay Finsberg
2025-05-10 11:12:59 [info     ] Searching for author Henrik Nicolay Finsberg
2025-05-10 11:12:59 [debug    ] Found 1 author(s)             
2025-05-10 11:12:59 [debug    ] Extracting all articles for NDPIHoEAAAAJ
2025-05-10 11:12:59 [info     ] Updating author info for Henrik Nicolay Finsberg
2025-05-10 11:12:59 [debug    ] Extracting author info        
2025-05-10 11:12:59 [debug    ] Extracting co-authors         

You can now try to list the authors again

!scholar list-authors
Henrik Nicolay Finsberg
                 Authors                  
┏━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┓
┃                    Name  Scholar ID   ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━┩
│ Henrik Nicolay Finsberg  NDPIHoEAAAAJ │
└─────────────────────────┴──────────────┘

As we can see, we didn’t type the full name (i.e Henrik Nicolay Finsberg), but the program was still able to find the correct author. Sometimes there are more than one person with the same name, in which case you can use the Scholar ID to specify which person you mean. We can first use the command

$ scholar search-author

to search for an author. This would be equivalent of searching for an author at Google Scholar. Let us say that we want to add a person with surname ‘Dokken’ that we know work at Simula Research Laboratory. We can then search for Dokken

$ scholar search-author 'Dokken'
!scholar search-author 'Dokken'
2025-05-10 11:13:01 [info     ] Searching for author Dokken   
2025-05-10 11:13:01 [debug    ] Found 4 author(s)             
                       Search results for author 'Dokken'                       
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ Name                    Scholar ID    Affiliation                Cited by ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━┩
│ Trond Dokken            42hVWYwAAAAJ  Uni Research Climate and   6977     │
│                                       the Bjerknes Centre for             │
│                                       Climate Research                    │
│ Tor Dokken              vkPMFtwAAAAJ  SINTEF Digital             2184     │
│ Therese Dokken          KUDqasUAAAAJ  Norwegian Social Research  1441     │
│                                       (NOVA)                              │
│ Jørgen Schartum Dokken  hfeXoYMAAAAJ  Simula Research            727      │
│                                       Laboratory                          │
└────────────────────────┴──────────────┴───────────────────────────┴──────────┘

We see that, the person we are looking for is Jørgen Dokken, so we could go ahead an add this author, or we could use the Scholar ID as follows

$ scholar add-author 'Dokken' --scholar-id=hfeXoYMAAAAJ
!scholar add-author 'Dokken' --scholar-id=hfeXoYMAAAAJ
2025-05-10 11:13:02 [info     ] Searching for author Dokken   
2025-05-10 11:13:02 [debug    ] Found 4 author(s)             
Adding author Jørgen Schartum Dokken
Successfully added author with name Jørgen Schartum Dokken and scholar id hfeXoYMAAAAJ
Search for publications. This can take some time
2025-05-10 11:13:02 [info     ] Get author info for Jørgen Schartum Dokken
2025-05-10 11:13:02 [info     ] Searching for author Jørgen Schartum Dokken
2025-05-10 11:13:02 [debug    ] Found 1 author(s)             
2025-05-10 11:13:02 [debug    ] Extracting all articles for hfeXoYMAAAAJ
2025-05-10 11:13:02 [info     ] Updating author info for Jørgen Schartum Dokken
2025-05-10 11:13:02 [debug    ] Extracting author info        
2025-05-10 11:13:02 [debug    ] Extracting co-authors         

We can now list the authors again

!scholar list-authors
Henrik Nicolay Finsberg
Jørgen Schartum Dokken
                 Authors                  
┏━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┓
┃                    Name  Scholar ID   ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━┩
│ Henrik Nicolay Finsberg  NDPIHoEAAAAJ │
│  Jørgen Schartum Dokken  hfeXoYMAAAAJ │
└─────────────────────────┴──────────────┘

Listing author publications#

The next command we want to look at is the command

$ scholar list-author-publications

We can take a look at the help section first

!scholar list-author-publications --help
                                                                                
 Usage: scholar list-author-publications [OPTIONS] NAME                         
                                                                                
 List authors publications                                                      
                                                                                
                                                                                
╭─ Arguments ──────────────────────────────────────────────────────────────────╮
 *    name      TEXT  [default: None] [required]                              
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Options ────────────────────────────────────────────────────────────────────╮
 --n                                      INTEGER           [default: 5]      
 --sort-by-citati…    --no-sort-by-ci…                      [default:         
                                                            sort-by-citation… 
 --add-authors        --no-add-authors                      [default:         
                                                            no-add-authors]   
 --max-age                                INTEGER           [default: None]   
 --update             --no-update                           [default:         
                                                            no-update]        
 --overwrite          --no-overwrite                        [default:         
                                                            no-overwrite]     
 --cache-dir                              TEXT              [default:         
                                                            /home/runner/.py… 
 --backend                                [scraper|scholar  [default:         
                                          ly]               scraper]          
 --help                                                     Show this message 
                                                            and exit.         
╰──────────────────────────────────────────────────────────────────────────────╯

We see that the command takes a name, which is the name of the author. Let us try it on one of the names in the database

!scholar list-author-publications 'Henrik Finsberg'
Could not find author with name 'Henrik Finsberg'. Will use 'Henrik Nicolay Finsberg' instead
         Publications for Henrik Nicolay Finsberg (Sorted by citations)         
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃ Title                                  Published year  Number of citations ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ Efficient estimation of personalized   2018            51                  │
│ biventricular mechanical function                                          │
│ employing gradient‐based optimization                                      │
│ Improved computational identification  2020            50                  │
│ of drug response using optical                                             │
│ measurements of human stem cell                                            │
│ derived cardiomyocytes in                                                  │
│ microphysiological systems                                                 │
│ Estimating cardiac contraction         2018            35                  │
│ through high resolution data                                               │
│ assimilation of a personalized                                             │
│ mechanical model                                                           │
│ Computational quantification of        2019            29                  │
│ patient-specific changes in                                                │
│ ventricular dynamics associated with                                       │
│ pulmonary hypertension                                                     │
│ In vivo estimation of elastic          2018            25                  │
│ heterogeneity in an infarcted human                                        │
│ heart                                                                      │
└───────────────────────────────────────┴────────────────┴─────────────────────┘

We see that it will display the 5 most cited papers, sorted with the most cited paper on top. We can also choose to display only 3 papers (using the --n flag), and we can also choose to not display papers that are more than two years old (using the --max-age flag). Let us also add all the authors on the papers for each row using the --add-authors flag

!scholar list-author-publications 'Henrik Finsberg' --n=3 --max-age=2 --add-authors
Could not find author with name 'Henrik Finsberg'. Will use 'Henrik Nicolay Finsberg' instead
         Publications for Henrik Nicolay Finsberg (Sorted by citations)         
┏━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┓
┃                                                        Number of          ┃
┃ Title               Authors            Published year  citations          ┃
┡━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━┩
│ Smart: Spatial      JG Laughlin, JS    2023            6                  │
│ modeling            Dokken, HNT                                           │
│ algorithms for      Finsberg, EA                                          │
│ reaction and        Francis, CT Lee,                                      │
│ transport           ME Rognes, ...                                        │
│ simcardems: A       HNT Finsberg, IGM  2023            5                  │
│ FEniCS-based        van Herck, C                                          │
│ cardiac             Daversin-Catty, H                                     │
│ electro-mechanics   Arevalo, S Wall                                       │
│ solver                                                                    │
│ A cell-based        Å Telle, JD        2023            5                  │
│ framework for       Trotter, X Cai, H                                     │
│ modeling cardiac    Finsberg, M                                           │
│ mechanics           Kuchta, J                                             │
│                     Sundnes, ST Wall                                      │
└────────────────────┴───────────────────┴────────────────┴────────────────────┘

Listing publications for the whole department#

Our department now consists of two researchers (Henrik Finsberg and Jørgen Dokken), but you could imaging that you have a lot of researchers in your department. It would then be nice to list the most cited papers across the whole department. We can do this with the

$ scholar list-department-publications

command. Let us first loook at the help menu

!scholar list-department-publications --help
                                                                                
 Usage: scholar list-department-publications [OPTIONS]                          
                                                                                
 List department publications                                                   
                                                                                
                                                                                
╭─ Options ────────────────────────────────────────────────────────────────────╮
 --n                                      INTEGER           [default: 5]      
 --sort-by-citati…    --no-sort-by-ci…                      [default:         
                                                            sort-by-citation… 
 --add-authors        --no-add-authors                      [default:         
                                                            no-add-authors]   
 --max-age                                INTEGER           [default: None]   
 --update             --no-update                           [default:         
                                                            no-update]        
 --cache-dir                              TEXT              [default:         
                                                            /home/runner/.py… 
 --backend                                [scraper|scholar  [default:         
                                          ly]               scraper]          
 --help                                                     Show this message 
                                                            and exit.         
╰──────────────────────────────────────────────────────────────────────────────╯

Let us list the most cited papers not older than 2 year using the command

$ scholar list-department-publications --max-age=2
!scholar list-department-publications --max-age=2
               Publications for department (Sorted by citations)                
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃ Title                                  Published year  Number of citations ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ DOLFINx: the next generation FEniCS    2023            174                 │
│ problem solving environment                                                │
│ Smart: Spatial modeling algorithms     2023            6                   │
│ for reaction and transport                                                 │
│ simcardems: A FEniCS-based cardiac     2023            5                   │
│ electro-mechanics solver                                                   │
│ A cell-based framework for modeling    2023            5                   │
│ cardiac mechanics                                                          │
│ Spatial modeling algorithms for        2024            3                   │
│ reactions and transport in biological                                      │
│ cells                                                                      │
└───────────────────────────────────────┴────────────────┴─────────────────────┘

We can also get the 5 most recent publications using the --no-sort-by-citations flag

!scholar list-department-publications --no-sort-by-citations
                  Publications for department (Sorted by age)                   
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃ Title                                  Published year  Number of citations ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ A software benchmark for cardiac       2025            1                   │
│ elastodynamics                                                             │
│ Human induced pluripotent stem         2025            0                   │
│ cell-derived cardiomyocytes and their                                      │
│ use in a cardiac organ-on-a-chip to                                        │
│ assay electrophysiology, calcium and                                       │
│ contractility                                                              │
│ On the numerical evaluation of wall    2025            0                   │
│ shear stress using the finite element                                      │
│ method                                                                     │
│ The latent variable proximal point     2025            0                   │
│ algorithm for variational problems                                         │
│ with inequality constraints                                                │
│ The Impact of Mechano-Electric         2024            0                   │
│ Feedback on Drug-and Stretch-Induced                                       │
│ Arrhythmia Using a Computational                                           │
│ Model of Cardiac Electromechanics                                          │
└───────────────────────────────────────┴────────────────┴─────────────────────┘

It is also to possible to list new publications using the command

!scholar list-new-department-publications
2025-05-10 11:13:10 [info     ] Get author info for Henrik Nicolay Finsberg
2025-05-10 11:13:10 [info     ] Searching for author Henrik Nicolay Finsberg
2025-05-10 11:13:10 [debug    ] Found 1 author(s)             
2025-05-10 11:13:10 [debug    ] Extracting all articles for NDPIHoEAAAAJ
2025-05-10 11:13:10 [info     ] Updating author info for Henrik Nicolay Finsberg
2025-05-10 11:13:10 [debug    ] Extracting author info        
2025-05-10 11:13:10 [debug    ] Extracting co-authors         
2025-05-10 11:13:10 [info     ] Get author info for Jørgen Schartum Dokken
2025-05-10 11:13:10 [info     ] Searching for author Jørgen Schartum Dokken
2025-05-10 11:13:10 [debug    ] Found 1 author(s)             
2025-05-10 11:13:10 [debug    ] Extracting all articles for hfeXoYMAAAAJ
2025-05-10 11:13:10 [info     ] Updating author info for Jørgen Schartum Dokken
2025-05-10 11:13:10 [debug    ] Extracting author info        
2025-05-10 11:13:10 [debug    ] Extracting co-authors         
     Publications for department (Sorted by     
                   citations)                   
┏━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃ Title  Published year  Number of citations ┃
┡━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
└───────┴────────────────┴─────────────────────┘