Open vojtechhuser opened 3 years ago
this can be closed. I found a way.
Yet pagination of results is a problem. I want to get full publication table
url='https://api.cpicpgx.org/v1/guideline?select=*,publication(title,pmid,year)&order=name'
library(httr)
r=GET(url,add_headers(Accept = "text/csv")) r http_status(r) df=content(r) nrow(df) df
@vojtechhuser The request you're currently working with is bascially saying "give me all the guideline records and include related publications inside those guidelines".
I think what you're asking for is "give me all the publication records that are associated with a guideline". That request would be:
https://api.cpicpgx.org/v1/publication?guidelineid=not.is.null
See in that request you're asking for /publication
instead of /guideline
and then filtering on the guidelineid
property of the publication data model.
Does that get you what you want?
@vojtechhuser One other thing. I just saw that I already have an example call for this in the Postman "quickstart" examples: https://documenter.getpostman.com/view/1446428/Szt78VUJ?version=latest#a9cee1e5-b041-4b01-8f07-8feee18380b2
I've been leaving language-specific exmaples of API calls to Postman since they have a good set of popular language/frameworks (see the "LANGUAGE" select box at the top of the Postman page). Unfortunately, they don't include R in there. I'll update the cpic-data wiki docs to include a link to the httr docs for R folks.
To help users, can you please provide R code that calls theapi call and gets CSV back
e.g. for this call https://api.cpicpgx.org/v1/guideline?select=*,publication(title,pmid,year)&order=name
The default format for API responses is JSON. However, PostgREST has built-in support for responding to any request in CSV format. Use the Accept HTTP header with a value of text/csv.