## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>", eval = FALSE ) ## ----install------------------------------------------------------------------ # # install.packages("pak") # pak::pkg_install("zx122ty/UniTCM_R_Package") ## ----install-remotes---------------------------------------------------------- # remotes::install_github("zx122ty/UniTCM_R_Package") ## ----setup-------------------------------------------------------------------- # library(unitcm) ## ----base-url----------------------------------------------------------------- # # Only needed for custom/local deployments # set_base_url("https://unitcm.qfxulab.com/api/v1") ## ----auth--------------------------------------------------------------------- # # Via environment variable (recommended for scripts/CI) # # Set UNITCM_TOKEN in your .Renviron # # # Or set in session # set_unitcm_token("your-token-here") # # # Or store securely in system keyring # set_unitcm_token("your-token-here", keyring = TRUE) ## ----first-query-------------------------------------------------------------- # herbs <- search_herbs(q = "ginseng") # herbs ## ----herb-detail-------------------------------------------------------------- # herb <- get_herb("UNITCM_H001") # herb$herb_english_name # herb$efficacy ## ----pagination--------------------------------------------------------------- # # Manual pagination # page1 <- search_herbs(q = "ginseng", page = 1, page_size = 50) # attr(page1, "total") # Total records available # # # Auto-pagination: fetches all pages with a progress bar # all_herbs <- search_herbs(q = "ginseng", all_pages = TRUE) # nrow(all_herbs)