| Title: | R Client for the 'OMOPHub' Medical Vocabulary API |
| Version: | 1.3.0 |
| Description: | Provides an R interface to the 'OMOPHub' API for accessing 'OHDSI ATHENA' standardized medical vocabularies. Supports concept search, vocabulary exploration, hierarchy navigation, relationship queries, and concept mappings with automatic pagination and rate limiting. |
| License: | MIT + file LICENSE |
| URL: | https://github.com/omopHub/omophub-R, https://docs.omophub.com, https://omophub.github.io/omophub-R/, https://omophub.com |
| BugReports: | https://github.com/omopHub/omophub-R/issues |
| Depends: | R (≥ 4.1) |
| Imports: | httr2 (≥ 1.0.0), R6, rlang (≥ 1.0.0), cli, tibble, purrr, glue, checkmate |
| Suggests: | testthat (≥ 3.0.0), httptest2, webmockr, knitr, rmarkdown, keyring, withr |
| Config/testthat/edition: | 3 |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.2 |
| VignetteBuilder: | knitr |
| NeedsCompilation: | no |
| Packaged: | 2026-01-08 11:24:57 UTC; konstantin |
| Author: | Alex Chen [aut, cre, cph], Observational Health Data Science and Informatics [cph] |
| Maintainer: | Alex Chen <alex@omophub.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-01-08 15:20:07 UTC |
omophub: R Client for the 'OMOPHub' Medical Vocabulary API
Description
Provides an R interface to the 'OMOPHub' API for accessing 'OHDSI ATHENA' standardized medical vocabularies. Supports concept search, vocabulary exploration, hierarchy navigation, relationship queries, and concept mappings with automatic pagination and rate limiting.
Provides an R interface to the OMOPHub API for accessing OHDSI ATHENA standardized medical vocabularies. Supports concept search, vocabulary exploration, hierarchy navigation, relationship queries, and concept mappings with automatic pagination and rate limiting.
Main Client
The main entry point is the OMOPHubClient R6 class which provides access to all API resources:
library(omophub)
client <- OMOPHubClient$new()
# Search for concepts
results <- client$search$basic("diabetes")
# Get a specific concept
concept <- client$concepts$get(201826)
Authentication
Set your API key using one of these methods:
Environment variable:
OMOPHUB_API_KEYExplicit argument:
OMOPHubClient$new(api_key = "your_key")Keyring:
set_api_key("your_key", store = "keyring")
Resources
The client provides access to these resources:
-
concepts: Concept lookup and batch operations -
search: Basic and advanced concept search -
vocabularies: Vocabulary listing and details -
domains: Domain listing and concept filtering -
hierarchy: Ancestor and descendant navigation -
relationships: Concept relationships -
mappings: Concept mappings between vocabularies
Author(s)
Maintainer: Alex Chen alex@omophub.com [copyright holder]
Other contributors:
Observational Health Data Science and Informatics [copyright holder]
See Also
Useful links:
Report bugs at https://github.com/omopHub/omophub-R/issues
Package Attach Hook
Description
Package Attach Hook
Usage
.onAttach(libname, pkgname)
Arguments
libname |
Library name. |
pkgname |
Package name. |
Package Load Hook
Description
Package Load Hook
Usage
.onLoad(libname, pkgname)
Arguments
libname |
Library name. |
pkgname |
Package name. |
Concepts Resource
Description
R6 class providing access to concept operations.
Value
A list containing the concept data.
A list containing the concept data with optional relationships and synonyms.
A list with concepts and any failures.
A list with suggestions and pagination metadata.
Related concepts with relationship scores.
Relationships data.
Recommendations grouped by source concept ID with pagination metadata.
Methods
Public methods
Method new()
Create a new ConceptsResource.
Usage
ConceptsResource$new(base_req)
Arguments
base_reqBase httr2 request object.
Method get()
Get a concept by ID.
Usage
ConceptsResource$get( concept_id, include_relationships = FALSE, include_synonyms = FALSE, include_hierarchy = FALSE, vocab_release = NULL )
Arguments
concept_idThe OMOP concept ID.
include_relationshipsInclude related concepts (parents/children). Default
FALSE.include_synonymsInclude concept synonyms. Default
FALSE.include_hierarchyInclude hierarchy information. Default
FALSE.vocab_releaseSpecific vocabulary release (e.g., "2025.2"). Default
NULL.
Method get_by_code()
Get a concept by vocabulary and code.
Usage
ConceptsResource$get_by_code( vocabulary_id, concept_code, include_relationships = FALSE, include_synonyms = FALSE, include_hierarchy = FALSE, vocab_release = NULL )
Arguments
vocabulary_idThe vocabulary ID (e.g., "SNOMED", "ICD10CM").
concept_codeThe concept code within the vocabulary.
include_relationshipsInclude related concepts (parents/children). Default
FALSE.include_synonymsInclude concept synonyms. Default
FALSE.include_hierarchyInclude hierarchy information. Default
FALSE.vocab_releaseSpecific vocabulary release (e.g., "2025.2"). Default
NULL.
Method batch()
Get multiple concepts by IDs.
Usage
ConceptsResource$batch( concept_ids, include_relationships = FALSE, include_synonyms = FALSE, include_mappings = FALSE, vocabulary_filter = NULL, standard_only = TRUE )
Arguments
concept_idsVector of concept IDs (max 100).
include_relationshipsInclude related concepts. Default
FALSE.include_synonymsInclude concept synonyms. Default
FALSE.include_mappingsInclude concept mappings. Default
FALSE.vocabulary_filterFilter results to specific vocabularies.
standard_onlyOnly return standard concepts. Default
TRUE.
Method suggest()
Get concept suggestions (autocomplete).
Usage
ConceptsResource$suggest( query, page = 1, page_size = 10, vocabulary_ids = NULL, domain_ids = NULL, vocab_release = NULL )
Arguments
querySearch query (min 2 characters, max 100 characters).
pagePage number (default 1).
page_sizeNumber of suggestions per page (default 10, max 100).
vocabulary_idsFilter to specific vocabularies (character vector).
domain_idsFilter to specific domains (character vector).
vocab_releaseSpecific vocabulary release (e.g., "2025.2").
Method related()
Get related concepts.
Usage
ConceptsResource$related( concept_id, relationship_types = NULL, min_score = NULL, page_size = 20, vocab_release = NULL )
Arguments
concept_idThe source concept ID.
relationship_typesFilter by relationship types (e.g., c("Is a", "Maps to")).
min_scoreMinimum relationship score (0.0-1.0).
page_sizeMaximum number of results (default 20, max 100).
vocab_releaseSpecific vocabulary release (e.g., "2025.1").
Method relationships()
Get concept relationships.
Usage
ConceptsResource$relationships( concept_id, relationship_ids = NULL, vocabulary_ids = NULL, domain_ids = NULL, include_invalid = FALSE, standard_only = FALSE, include_reverse = FALSE, vocab_release = NULL )
Arguments
concept_idThe concept ID.
relationship_idsFilter by relationship type IDs (character vector or comma-separated string).
vocabulary_idsFilter by target vocabulary IDs (character vector or comma-separated string).
domain_idsFilter by target domain IDs (character vector or comma-separated string).
include_invalidInclude relationships to invalid concepts. Default
FALSE.standard_onlyOnly include relationships to standard concepts. Default
FALSE.include_reverseInclude reverse relationships. Default
FALSE.vocab_releaseSpecific vocabulary release version. Default
NULL.
Method recommended()
Get recommended concepts using OHDSI Phoebe algorithm.
Usage
ConceptsResource$recommended( concept_ids, relationship_types = NULL, vocabulary_ids = NULL, domain_ids = NULL, standard_only = TRUE, include_invalid = FALSE, page = 1, page_size = 100 )
Arguments
concept_idsVector of source concept IDs (1-100).
relationship_typesFilter by relationship types (max 20).
vocabulary_idsFilter to specific vocabularies (max 50).
domain_idsFilter to specific domains (max 50).
standard_onlyOnly return standard concepts. Default
TRUE.include_invalidInclude invalid/deprecated concepts. Default
FALSE.pagePage number. Default 1.
page_sizeResults per page (default 100, max 1000).
Method print()
Print resource information.
Usage
ConceptsResource$print()
Method clone()
The objects of this class are cloneable with this method.
Usage
ConceptsResource$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Domains Resource
Description
R6 class providing access to domain operations.
Value
Domain list.
Paginated concepts.
Methods
Public methods
Method new()
Create a new DomainsResource.
Usage
DomainsResource$new(base_req)
Arguments
base_reqBase httr2 request object.
Method list()
List all domains.
Usage
DomainsResource$list(include_stats = FALSE)
Arguments
include_statsInclude concept counts and vocabulary coverage. Default
FALSE.
Method concepts()
Get concepts in a domain.
Usage
DomainsResource$concepts( domain_id, vocabulary_ids = NULL, standard_only = FALSE, include_invalid = FALSE, page = 1, page_size = 50 )
Arguments
domain_idThe domain ID.
vocabulary_idsFilter by vocabularies.
standard_onlyOnly standard concepts. Default
FALSE.include_invalidInclude invalid/deprecated concepts. Default
FALSE.pagePage number. Default 1.
page_sizeResults per page. Default 50.
Method print()
Print resource information.
Usage
DomainsResource$print()
Method clone()
The objects of this class are cloneable with this method.
Usage
DomainsResource$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Hierarchy Resource
Description
R6 class providing access to hierarchy operations (ancestors and descendants).
Value
For flat format: ancestors, descendants arrays with level/total counts. For graph format: nodes and edges arrays for visualization.
Ancestors with hierarchy summary.
Descendants with hierarchy summary.
Methods
Public methods
Method new()
Create a new HierarchyResource.
Usage
HierarchyResource$new(base_req)
Arguments
base_reqBase httr2 request object.
Method get()
Get complete concept hierarchy (ancestors and descendants).
Usage
HierarchyResource$get( concept_id, format = "flat", vocabulary_ids = NULL, domain_ids = NULL, max_levels = 10, max_results = NULL, relationship_types = NULL, include_invalid = FALSE )
Arguments
concept_idThe concept ID.
formatResponse format - "flat" (default) or "graph" for visualization.
vocabulary_idsFilter to specific vocabularies (character vector).
domain_idsFilter to specific domains (character vector).
max_levelsMaximum hierarchy levels to traverse in both directions (default 10).
max_resultsMaximum results per direction for performance optimization.
relationship_typesRelationship types to follow (default: "Is a").
include_invalidInclude deprecated/invalid concepts. Default
FALSE.
Method ancestors()
Get concept ancestors.
Usage
HierarchyResource$ancestors( concept_id, vocabulary_ids = NULL, max_levels = NULL, relationship_types = NULL, include_paths = FALSE, include_distance = TRUE, include_invalid = FALSE, page = 1, page_size = 100 )
Arguments
concept_idThe concept ID.
vocabulary_idsFilter to specific vocabularies (character vector).
max_levelsMaximum hierarchy levels to traverse.
relationship_typesRelationship types to follow (default: "Is a").
include_pathsInclude path information. Default
FALSE.include_distanceInclude distance from source. Default
TRUE.include_invalidInclude deprecated/invalid concepts. Default
FALSE.pagePage number. Default 1.
page_sizeResults per page. Default 100.
Method descendants()
Get concept descendants.
Usage
HierarchyResource$descendants( concept_id, vocabulary_ids = NULL, max_levels = 10, relationship_types = NULL, include_distance = TRUE, include_paths = FALSE, include_invalid = FALSE, domain_ids = NULL, page = 1, page_size = 100 )
Arguments
concept_idThe concept ID.
vocabulary_idsFilter to specific vocabularies (character vector).
max_levelsMaximum hierarchy levels (default 10, max 20).
relationship_typesRelationship types to follow.
include_distanceInclude distance from source. Default
TRUE.include_pathsInclude path information. Default
FALSE.include_invalidInclude deprecated/invalid concepts. Default
FALSE.domain_idsFilter by domains.
pagePage number. Default 1.
page_sizeResults per page. Default 100.
Method print()
Print resource information.
Usage
HierarchyResource$print()
Method clone()
The objects of this class are cloneable with this method.
Usage
HierarchyResource$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Mappings Resource
Description
R6 class providing access to mapping operations.
Value
Mappings for the concept.
Mapping results with summary.
Methods
Public methods
Method new()
Create a new MappingsResource.
Usage
MappingsResource$new(base_req)
Arguments
base_reqBase httr2 request object.
Method get()
Get mappings for a concept.
Usage
MappingsResource$get( concept_id, target_vocabulary = NULL, include_invalid = FALSE, vocab_release = NULL )
Arguments
concept_idThe concept ID.
target_vocabularyFilter to a specific target vocabulary (e.g., "ICD10CM").
include_invalidInclude invalid/deprecated mappings. Default
FALSE.vocab_releaseSpecific vocabulary release version (e.g., "2025.1"). Default
NULL.
Method map()
Map concepts to a target vocabulary.
Usage
MappingsResource$map( source_concepts, target_vocabulary, mapping_type = NULL, include_invalid = FALSE, vocab_release = NULL )
Arguments
source_conceptsVector of OMOP concept IDs to map.
target_vocabularyTarget vocabulary ID (e.g., "ICD10CM", "SNOMED").
mapping_typeMapping type (direct, equivalent, broader, narrower).
include_invalidInclude invalid mappings. Default
FALSE.vocab_releaseSpecific vocabulary release version (e.g., "2025.1"). Default
NULL.
Method print()
Print resource information.
Usage
MappingsResource$print()
Method clone()
The objects of this class are cloneable with this method.
Usage
MappingsResource$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
OMOPHub API Client
Description
R6 class for interacting with the OMOPHub vocabulary service. Provides access to OHDSI ATHENA standardized medical vocabularies.
Details
The client provides access to these resources:
-
concepts: Concept lookup and batch operations -
search: Basic and advanced concept search -
vocabularies: Vocabulary listing and details -
domains: Domain listing and concept filtering -
hierarchy: Ancestor and descendant navigation -
relationships: Concept relationships -
mappings: Concept mappings between vocabularies
Value
A new OMOPHubClient object.
Active bindings
conceptsAccess to concept operations.
searchAccess to search operations.
vocabulariesAccess to vocabulary operations.
domainsAccess to domain operations.
hierarchyAccess to hierarchy operations.
relationshipsAccess to relationship operations.
mappingsAccess to mapping operations.
Methods
Public methods
Method new()
Create a new OMOPHub client.
Usage
OMOPHubClient$new( api_key = NULL, base_url = NULL, timeout = 30, max_retries = 3, vocab_version = NULL )
Arguments
api_keyAPI key for authentication. If not provided, reads from
OMOPHUB_API_KEYenvironment variable or system keyring.base_urlAPI base URL. Defaults to
https://api.omophub.com/v1.timeoutRequest timeout in seconds. Defaults to 30.
max_retriesMaximum retry attempts for failed requests. Defaults to 3.
vocab_versionOptional vocabulary version (e.g., "2025.1"). If not specified, uses the latest version.
Method print()
Print client information.
Usage
OMOPHubClient$print()
Method clone()
The objects of this class are cloneable with this method.
Usage
OMOPHubClient$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Examples
## Not run:
# Create client (uses OMOPHUB_API_KEY env var)
client <- OMOPHubClient$new()
# Or with explicit API key
client <- OMOPHubClient$new(api_key = "your_api_key")
# Search for concepts
results <- client$search$basic("diabetes")
# Get a specific concept
concept <- client$concepts$get(201826)
# Use specific vocabulary version
client <- OMOPHubClient$new(vocab_version = "2025.1")
## End(Not run)
Relationships Resource
Description
R6 class providing access to relationship operations.
Value
Relationships data with pagination metadata.
Relationship types with pagination metadata.
Methods
Public methods
Method new()
Create a new RelationshipsResource.
Usage
RelationshipsResource$new(base_req)
Arguments
base_reqBase httr2 request object.
Method get()
Get relationships for a concept.
Usage
RelationshipsResource$get( concept_id, relationship_ids = NULL, vocabulary_ids = NULL, domain_ids = NULL, include_invalid = FALSE, standard_only = FALSE, include_reverse = FALSE, page = 1, page_size = 100, vocab_release = NULL )
Arguments
concept_idThe concept ID.
relationship_idsFilter by relationship type IDs (character vector or comma-separated string).
vocabulary_idsFilter by target vocabulary IDs (character vector or comma-separated string).
domain_idsFilter by target domain IDs (character vector or comma-separated string).
include_invalidInclude relationships to invalid concepts. Default
FALSE.standard_onlyOnly include relationships to standard concepts. Default
FALSE.include_reverseInclude reverse relationships. Default
FALSE.pagePage number. Default 1.
page_sizeResults per page (max 1000). Default 100.
vocab_releaseSpecific vocabulary release version. Default
NULL.
Method types()
Get available relationship types from the OMOP CDM.
Usage
RelationshipsResource$types(page = 1, page_size = 100)
Arguments
pagePage number. Default 1.
page_sizeResults per page (max 500). Default 100.
Method print()
Print resource information.
Usage
RelationshipsResource$print()
Method clone()
The objects of this class are cloneable with this method.
Usage
RelationshipsResource$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Search Resource
Description
R6 class providing access to search operations.
Value
Search results with pagination.
A tibble of all matching concepts.
Search results with facets and metadata.
Autocomplete suggestions.
Methods
Public methods
Method new()
Create a new SearchResource.
Usage
SearchResource$new(base_req)
Arguments
base_reqBase httr2 request object.
Method basic()
Basic concept search.
Usage
SearchResource$basic( query, vocabulary_ids = NULL, domain_ids = NULL, concept_class_ids = NULL, standard_concept = NULL, include_synonyms = FALSE, include_invalid = FALSE, min_score = NULL, exact_match = FALSE, page = 1, page_size = 20, sort_by = NULL, sort_order = NULL )
Arguments
querySearch query string.
vocabulary_idsFilter by vocabulary IDs.
domain_idsFilter by domain IDs.
concept_class_idsFilter by concept class IDs.
standard_conceptFilter by standard concept ("S", "C", or NULL).
include_synonymsSearch in synonyms. Default
FALSE.include_invalidInclude invalid concepts. Default
FALSE.min_scoreMinimum relevance score.
exact_matchRequire exact match. Default
FALSE.pagePage number (1-based). Default 1.
page_sizeResults per page. Default 20.
sort_bySort field.
sort_orderSort order ("asc" or "desc").
Method basic_all()
Fetch all search results with automatic pagination.
Usage
SearchResource$basic_all( query, vocabulary_ids = NULL, domain_ids = NULL, page_size = 100, max_pages = Inf, progress = TRUE, ... )
Arguments
querySearch query string.
vocabulary_idsFilter by vocabulary IDs.
domain_idsFilter by domain IDs.
page_sizeResults per page. Default 100.
max_pagesMaximum pages to fetch. Default Inf.
progressShow progress bar. Default
TRUE....Additional search parameters.
Method advanced()
Advanced concept search with facets.
Usage
SearchResource$advanced( query, vocabulary_ids = NULL, domain_ids = NULL, concept_class_ids = NULL, standard_concepts_only = FALSE, include_invalid = FALSE, relationship_filters = NULL, page = 1, page_size = 20 )
Arguments
querySearch query string.
vocabulary_idsFilter by vocabulary IDs.
domain_idsFilter by domain IDs.
concept_class_idsFilter by concept class IDs.
standard_concepts_onlyOnly return standard concepts. Default
FALSE.include_invalidInclude invalid concepts. Default
FALSE.relationship_filtersRelationship-based filters.
pagePage number (1-based). Default 1.
page_sizeResults per page. Default 20.
Method autocomplete()
Get autocomplete suggestions.
Usage
SearchResource$autocomplete( query, vocabulary_ids = NULL, domains = NULL, max_suggestions = 10 )
Arguments
queryPartial query string.
vocabulary_idsFilter by vocabulary IDs.
domainsFilter by domains.
max_suggestionsMaximum suggestions. Default 10.
Method print()
Print resource information.
Usage
SearchResource$print()
Method clone()
The objects of this class are cloneable with this method.
Usage
SearchResource$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Vocabularies Resource
Description
R6 class providing access to vocabulary operations.
Value
Paginated vocabulary list.
Vocabulary details including vocabulary_id, vocabulary_name, vocabulary_reference, vocabulary_version, vocabulary_concept_id.
Vocabulary statistics.
Domain statistics including concept counts and class breakdown.
List of all available domains with domain_id, domain_name, and description.
List of all available concept classes with concept_class_id, concept_class_name, and concept_class_concept_id.
Paginated concepts.
Methods
Public methods
Method new()
Create a new VocabulariesResource.
Usage
VocabulariesResource$new(base_req)
Arguments
base_reqBase httr2 request object.
Method list()
List all vocabularies.
Usage
VocabulariesResource$list( include_stats = FALSE, include_inactive = FALSE, sort_by = "name", sort_order = "asc", page = 1, page_size = 100 )
Arguments
include_statsInclude vocabulary statistics. Default
FALSE.include_inactiveInclude inactive vocabularies. Default
FALSE.sort_bySort field ("name", "priority", "updated"). Default "name".
sort_orderSort order ("asc" or "desc"). Default "asc".
pagePage number. Default 1.
page_sizeResults per page. Default 100.
Method get()
Get vocabulary details.
Usage
VocabulariesResource$get(vocabulary_id)
Arguments
vocabulary_idThe vocabulary ID.
Method stats()
Get vocabulary statistics.
Usage
VocabulariesResource$stats(vocabulary_id)
Arguments
vocabulary_idThe vocabulary ID.
Method domain_stats()
Get statistics for a specific domain within a vocabulary.
Usage
VocabulariesResource$domain_stats(vocabulary_id, domain_id)
Arguments
vocabulary_idThe vocabulary ID (e.g., "SNOMED", "ICD10CM").
domain_idThe domain ID (e.g., "Condition", "Drug", "Procedure").
Method domains()
Get all standard OHDSI domains.
Usage
VocabulariesResource$domains()
Method concept_classes()
Get all concept classes.
Usage
VocabulariesResource$concept_classes()
Method concepts()
Get concepts in a vocabulary.
Usage
VocabulariesResource$concepts( vocabulary_id, search = NULL, standard_concept = "all", include_invalid = FALSE, include_relationships = FALSE, include_synonyms = FALSE, sort_by = "name", sort_order = "asc", page = 1, page_size = 20 )
Arguments
vocabulary_idThe vocabulary ID.
searchSearch term to filter concepts by name or code.
standard_conceptFilter by standard concept status ('S', 'C', 'all'). Default "all".
include_invalidInclude invalid or deprecated concepts. Default
FALSE.include_relationshipsInclude concept relationships. Default
FALSE.include_synonymsInclude concept synonyms. Default
FALSE.sort_bySort field ('name', 'concept_id', 'concept_code'). Default "name".
sort_orderSort order ('asc' or 'desc'). Default "asc".
pagePage number. Default 1.
page_sizeResults per page (max 1000). Default 20.
Method print()
Print resource information.
Usage
VocabulariesResource$print()
Method clone()
The objects of this class are cloneable with this method.
Usage
VocabulariesResource$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Abort with OMOPHub API Error
Description
Abort with OMOPHub API Error
Usage
abort_api_error(status, message, endpoint, call = rlang::caller_env())
Arguments
status |
HTTP status code. |
message |
Error message. |
endpoint |
API endpoint that failed. |
call |
The calling environment. |
Abort with Authentication Error
Description
Abort with Authentication Error
Usage
abort_auth_error(message, call = rlang::caller_env())
Arguments
message |
Error message. |
call |
The calling environment. |
Abort with Rate Limit Error
Description
Abort with Rate Limit Error
Usage
abort_rate_limit(retry_after = NULL, call = rlang::caller_env())
Arguments
retry_after |
Seconds until rate limit resets. |
call |
The calling environment. |
Abort with Validation Error
Description
Abort with Validation Error
Usage
abort_validation(message, arg = NULL, call = rlang::caller_env())
Arguments
message |
Error message. |
arg |
The argument that failed validation. |
call |
The calling environment. |
Convert Boolean to API String
Description
Convert Boolean to API String
Usage
bool_to_str(x)
Arguments
x |
A logical value. |
Value
"true" or "false" string, or NULL if x is NULL.
Build Base OMOPHub Request
Description
Creates an httr2 request object with authentication, rate limiting, and retry logic configured.
Usage
build_request(
base_url,
api_key,
timeout = 30,
max_retries = 3,
vocab_version = NULL
)
Arguments
base_url |
API base URL. |
api_key |
API key for authentication. |
timeout |
Request timeout in seconds. |
max_retries |
Maximum retry attempts. |
vocab_version |
Optional vocabulary version. |
Value
An httr2 request object.
Extract Error Message from API Response
Description
Extract Error Message from API Response
Usage
extract_error_message(resp)
Arguments
resp |
An httr2 response object. |
Value
A character string with the error message.
Extract Pagination Metadata
Description
Extracts pagination metadata from an API response.
Usage
extract_pagination(response)
Arguments
response |
API response object. |
Value
A list with pagination fields.
Get OMOPHub API Key
Description
Retrieves the OMOPHub API key from multiple sources in priority order:
Explicit argument
-
OMOPHUB_API_KEYenvironment variable System keyring (if
keyringpackage is installed)
Usage
get_api_key(key = NULL)
Arguments
key |
Optional explicit API key. If provided, this takes precedence. |
Value
A character string containing the API key.
Examples
## Not run:
# From environment variable
Sys.setenv(OMOPHUB_API_KEY = "your_api_key")
key <- get_api_key()
# Explicit key
key <- get_api_key("your_api_key")
## End(Not run)
Check if API Key is Available
Description
Checks whether an OMOPHub API key is available without throwing an error.
Usage
has_api_key()
Value
TRUE if an API key is available, FALSE otherwise.
Check if Error is Transient (Retryable)
Description
Check if Error is Transient (Retryable)
Usage
is_transient_error(resp)
Arguments
resp |
An httr2 response object. |
Value
TRUE if the error is transient and should be retried.
Join List Elements for Query Parameter
Description
Join List Elements for Query Parameter
Usage
join_params(x, sep = ",")
Arguments
x |
A character vector. |
sep |
Separator (default comma). |
Value
A single comma-separated string, or NULL if x is NULL/empty.
Create OMOPHub Concepts Result
Description
Creates an S3 object for concept search results.
Usage
new_omophub_concepts(data, meta = list())
Arguments
data |
Concept data (list or tibble). |
meta |
Pagination metadata. |
Value
An omophub_concepts S3 object.
Create OMOPHub Hierarchy Result
Description
Create OMOPHub Hierarchy Result
Usage
new_omophub_hierarchy(data, meta = list(), type = "hierarchy")
Arguments
data |
Hierarchy data (ancestors or descendants). |
meta |
Metadata including summary. |
type |
Type of hierarchy ("ancestors" or "descendants"). |
Value
An omophub_hierarchy S3 object.
Create OMOPHub Mappings Result
Description
Create OMOPHub Mappings Result
Usage
new_omophub_mappings(data, meta = list())
Arguments
data |
Mapping data. |
meta |
Metadata. |
Value
An omophub_mappings S3 object.
Create OMOPHub Relationships Result
Description
Create OMOPHub Relationships Result
Usage
new_omophub_relationships(data, meta = list())
Arguments
data |
Relationship data. |
meta |
Metadata. |
Value
An omophub_relationships S3 object.
Create OMOPHub Vocabularies Result
Description
Create OMOPHub Vocabularies Result
Usage
new_omophub_vocabularies(data, meta = list())
Arguments
data |
Vocabulary data. |
meta |
Pagination metadata. |
Value
An omophub_vocabularies S3 object.
Fetch All Paginated Results
Description
Fetches all pages of results and combines them into a single tibble.
Usage
paginate_all(fetch_fn, page_size = 100, max_pages = Inf, progress = TRUE)
Arguments
fetch_fn |
A function that takes |
page_size |
Number of items per page. Default 100. |
max_pages |
Maximum number of pages to fetch. Default |
progress |
Show progress bar. Default |
Value
A tibble containing all fetched results.
Create Lazy Pagination Iterator
Description
Creates an iterator that fetches pages on demand.
Usage
paginate_lazy(fetch_fn, page_size = 100)
Arguments
fetch_fn |
A function that takes |
page_size |
Number of items per page. Default 100. |
Value
An iterator object with next_page() and has_more() methods.
Perform GET Request
Description
Perform GET Request
Usage
perform_get(base_req, endpoint, query = NULL)
Arguments
base_req |
Base request object. |
endpoint |
API endpoint path. |
query |
Named list of query parameters. |
Value
Parsed JSON response. For paginated endpoints, returns a list with
data (the results) and meta (pagination info). For single-item endpoints,
returns the unwrapped data directly.
Perform POST Request
Description
Perform POST Request
Usage
perform_post(base_req, endpoint, body = NULL, query = NULL)
Arguments
base_req |
Base request object. |
endpoint |
API endpoint path. |
body |
Named list for JSON body. |
query |
Named list of query parameters. |
Value
Parsed JSON response (unwrapped from data field if present).
Set OMOPHub API Key
Description
Stores the OMOPHub API key in the specified location.
Usage
set_api_key(key, store = c("env", "keyring"))
Arguments
key |
The API key to store. |
store |
Where to store the key. One of:
|
Value
Invisibly returns TRUE on success.
Examples
## Not run:
# Store in environment (current session only)
set_api_key("your_api_key")
# Store securely in keyring (persistent)
set_api_key("your_api_key", store = "keyring")
## End(Not run)
Validate Concept ID
Description
Validate Concept ID
Usage
validate_concept_id(concept_id, arg = "concept_id", call = rlang::caller_env())
Arguments
concept_id |
A concept ID to validate. |
arg |
Argument name for error messages. |
call |
The calling environment. |
Validate Page Parameters
Description
Validate Page Parameters
Usage
validate_pagination(
page,
page_size,
max_page_size = 1000,
call = rlang::caller_env()
)
Arguments
page |
Page number. |
page_size |
Page size. |
max_page_size |
Maximum allowed page size. |
call |
The calling environment. |