get_pug_rest {PubChemR} | R Documentation |
Retrieve Data from PubChem PUG REST API
Description
This function sends a request to the PubChem PUG REST API to retrieve various types of data for a given identifier. It supports fetching data in different formats and allows saving the output.
Usage
get_pug_rest(
identifier = NULL,
namespace = "cid",
domain = "compound",
operation = NULL,
output = "JSON",
searchtype = NULL,
property = NULL,
options = NULL,
save = FALSE,
dpi = 300,
path = NULL,
file_name = NULL,
...
)
Arguments
identifier |
A vector of identifier for the query, either numeric or character. |
namespace |
A character string specifying the namespace for the request. Default is 'cid'. |
domain |
A character string specifying the domain for the request. Default is 'compound'. |
operation |
An optional character string specifying the operation for the request. |
output |
A character string specifying the output format. Possible values are 'SDF', 'JSON', 'JSONP', 'CSV', 'TXT', and 'PNG'. Default is 'JSON'. |
searchtype |
An optional character string specifying the search type. |
property |
An optional character string specifying the property for the request. |
options |
A list of additional options for the request. |
save |
A logical value indicating whether to save the output as a file or image. Default is FALSE. |
dpi |
An integer specifying the DPI for image output. Default is 300. |
path |
description |
file_name |
a character of length 1. Define the name of file (without file extension) to save. If NULL, default file name is set as "files_downloaded". |
... |
description |
Value
Depending on the output format, this function returns different types of content: JSON or JSONP format returns parsed JSON content. CSV format returns a data frame. TXT format returns a table. SDF returns SDF file of requested identifier. PNG format returns an image object or saves an image file.
Examples
result <- get_pug_rest(identifier = "2244", namespace = "cid", domain = "compound", output = "JSON")