I am trying to work directly with the pubmed
api from R using httr
. There are excellent packages available such as RISmed
and easypubmed
but for this particular task, I need to interact directly with the api.
Using this set of instructions (https://www.ncbi.nlm.nih.gov/books/NBK25500/), I started with this code but the returned is a list without any details or pmid
. Any guidance is appreciated. or if you are aware of particular tutorials on using R in this setting.
library(XML)
library(httr)
library(glue)
query = 'asthma[mesh]+AND+leukotrienes[mesh]+AND+2009[pdat]'
reqq = glue ('https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term={query}')
op = GET(reqq)
I also tried the code from this post (why i get that error : XML content does not seem to be XML), but it give this error Error in read_xml.raw(x, encoding = encoding, ...) : Opening and ending tag mismatch: meta line 17 and head [76]
You can read XML response and parse it to collect pubmed IDs, for instance:
which gives: