curl -X POST "https://api.omophub.com/v1/concepts/hierarchy/batch" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"queries": [
{
"query_id": "q1",
"concept_id": 201826,
"operation": "ancestors",
"params": {
"max_levels": 5
}
},
{
"query_id": "q2",
"concept_id": 4182210,
"operation": "descendants",
"params": {
"max_levels": 3
}
},
{
"query_id": "q3",
"concept_id": 313217,
"operation": "hierarchy",
"params": {
"max_levels": 4,
"relationship_types": ["Is a"]
}
}
]
}'
import requests
def batch_hierarchy_query(queries, api_key):
url = "https://api.omophub.com/v1/concepts/hierarchy/batch"
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
data = {"queries": queries}
response = requests.post(url, json=data, headers=headers)
return response.json()
# Example usage
queries = [
{
"query_id": "diabetes",
"concept_id": 201826,
"operation": "ancestors",
"params": {"max_levels": 5}
},
{
"query_id": "hypertension",
"concept_id": 4182210,
"operation": "descendants",
"params": {"max_levels": 3}
},
{
"query_id": "afib",
"concept_id": 313217,
"operation": "hierarchy",
"params": {"max_levels": 4}
}
]
result = batch_hierarchy_query(queries, "YOUR_API_KEY")
for query_result in result['data']['results']:
if query_result['success']:
data = query_result['data']
ancestors = len(data.get('ancestors', []))
descendants = len(data.get('descendants', []))
print(f"{query_result['query_id']}: {ancestors} ancestors, {descendants} descendants")
else:
print(f"{query_result['query_id']}: Error - {query_result['error']}")
import { OMOPHub } from '@omophub/omophub-node';
// Not yet exposed as a dedicated SDK method — use the typed low-level helper
// for parity with auth, retries, and error handling.
const client = new OMOPHub();
interface HierarchyQueryResult {
results: Array<{
query_id: string;
success: boolean;
data?: { ancestors?: unknown[]; descendants?: unknown[] };
error?: string;
}>;
}
const { data } = await client.post<HierarchyQueryResult>('/concepts/hierarchy/batch', {
queries: [
{ query_id: 'q1', concept_id: 201826, operation: 'ancestors', params: { max_levels: 5 } },
{ query_id: 'q2', concept_id: 4182210, operation: 'descendants', params: { max_levels: 3 } },
{ query_id: 'q3', concept_id: 313217, operation: 'hierarchy', params: { max_levels: 4 } },
],
});
data?.results.forEach((queryResult) => {
if (queryResult.success) {
const ancestors = queryResult.data?.ancestors?.length ?? 0;
const descendants = queryResult.data?.descendants?.length ?? 0;
console.log(`${queryResult.query_id}: ${ancestors} ancestors, ${descendants} descendants`);
} else {
console.error(`${queryResult.query_id} failed: ${queryResult.error}`);
}
});
{
"success": true,
"data": {
"results": [
{
"query_id": "q1",
"concept_id": 201826,
"operation": "ancestors",
"success": true,
"data": {
"ancestors": [
{
"concept_id": 73211009,
"concept_name": "Diabetes mellitus",
"vocabulary_id": "SNOMED",
"domain_id": "Condition",
"concept_class_id": "Clinical Finding",
"standard_concept": "S",
"level": 1
},
{
"concept_id": 64572001,
"concept_name": "Disease",
"vocabulary_id": "SNOMED",
"domain_id": "Condition",
"concept_class_id": "Clinical Finding",
"standard_concept": "S",
"level": 2
}
],
"total_count": 2
}
},
{
"query_id": "q2",
"concept_id": 4182210,
"operation": "descendants",
"success": true,
"data": {
"descendants": [
{
"concept_id": 320128,
"concept_name": "Essential hypertension",
"vocabulary_id": "SNOMED",
"domain_id": "Condition",
"concept_class_id": "Clinical Finding",
"standard_concept": "S",
"level": 1
}
],
"total_count": 1
}
},
{
"query_id": "q3",
"concept_id": 313217,
"operation": "hierarchy",
"success": true,
"data": {
"ancestors": [
{
"concept_id": 49436004,
"concept_name": "Atrial fibrillation and flutter",
"vocabulary_id": "SNOMED",
"domain_id": "Condition",
"concept_class_id": "Clinical Finding",
"standard_concept": "S",
"level": 1
}
],
"descendants": [],
"total_count": 1
}
}
]
},
"meta": {
"request_id": "req_batch_hierarchy_123",
"timestamp": "2024-12-22T10:00:00Z",
"vocab_release": "2025.1"
}
}
Batch Hierarchy Queries
Run multiple OMOP concept hierarchy lookups in a single batched request to efficiently retrieve ancestors and descendants for bulk ETL workflows.
curl -X POST "https://api.omophub.com/v1/concepts/hierarchy/batch" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"queries": [
{
"query_id": "q1",
"concept_id": 201826,
"operation": "ancestors",
"params": {
"max_levels": 5
}
},
{
"query_id": "q2",
"concept_id": 4182210,
"operation": "descendants",
"params": {
"max_levels": 3
}
},
{
"query_id": "q3",
"concept_id": 313217,
"operation": "hierarchy",
"params": {
"max_levels": 4,
"relationship_types": ["Is a"]
}
}
]
}'
import requests
def batch_hierarchy_query(queries, api_key):
url = "https://api.omophub.com/v1/concepts/hierarchy/batch"
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
data = {"queries": queries}
response = requests.post(url, json=data, headers=headers)
return response.json()
# Example usage
queries = [
{
"query_id": "diabetes",
"concept_id": 201826,
"operation": "ancestors",
"params": {"max_levels": 5}
},
{
"query_id": "hypertension",
"concept_id": 4182210,
"operation": "descendants",
"params": {"max_levels": 3}
},
{
"query_id": "afib",
"concept_id": 313217,
"operation": "hierarchy",
"params": {"max_levels": 4}
}
]
result = batch_hierarchy_query(queries, "YOUR_API_KEY")
for query_result in result['data']['results']:
if query_result['success']:
data = query_result['data']
ancestors = len(data.get('ancestors', []))
descendants = len(data.get('descendants', []))
print(f"{query_result['query_id']}: {ancestors} ancestors, {descendants} descendants")
else:
print(f"{query_result['query_id']}: Error - {query_result['error']}")
import { OMOPHub } from '@omophub/omophub-node';
// Not yet exposed as a dedicated SDK method — use the typed low-level helper
// for parity with auth, retries, and error handling.
const client = new OMOPHub();
interface HierarchyQueryResult {
results: Array<{
query_id: string;
success: boolean;
data?: { ancestors?: unknown[]; descendants?: unknown[] };
error?: string;
}>;
}
const { data } = await client.post<HierarchyQueryResult>('/concepts/hierarchy/batch', {
queries: [
{ query_id: 'q1', concept_id: 201826, operation: 'ancestors', params: { max_levels: 5 } },
{ query_id: 'q2', concept_id: 4182210, operation: 'descendants', params: { max_levels: 3 } },
{ query_id: 'q3', concept_id: 313217, operation: 'hierarchy', params: { max_levels: 4 } },
],
});
data?.results.forEach((queryResult) => {
if (queryResult.success) {
const ancestors = queryResult.data?.ancestors?.length ?? 0;
const descendants = queryResult.data?.descendants?.length ?? 0;
console.log(`${queryResult.query_id}: ${ancestors} ancestors, ${descendants} descendants`);
} else {
console.error(`${queryResult.query_id} failed: ${queryResult.error}`);
}
});
{
"success": true,
"data": {
"results": [
{
"query_id": "q1",
"concept_id": 201826,
"operation": "ancestors",
"success": true,
"data": {
"ancestors": [
{
"concept_id": 73211009,
"concept_name": "Diabetes mellitus",
"vocabulary_id": "SNOMED",
"domain_id": "Condition",
"concept_class_id": "Clinical Finding",
"standard_concept": "S",
"level": 1
},
{
"concept_id": 64572001,
"concept_name": "Disease",
"vocabulary_id": "SNOMED",
"domain_id": "Condition",
"concept_class_id": "Clinical Finding",
"standard_concept": "S",
"level": 2
}
],
"total_count": 2
}
},
{
"query_id": "q2",
"concept_id": 4182210,
"operation": "descendants",
"success": true,
"data": {
"descendants": [
{
"concept_id": 320128,
"concept_name": "Essential hypertension",
"vocabulary_id": "SNOMED",
"domain_id": "Condition",
"concept_class_id": "Clinical Finding",
"standard_concept": "S",
"level": 1
}
],
"total_count": 1
}
},
{
"query_id": "q3",
"concept_id": 313217,
"operation": "hierarchy",
"success": true,
"data": {
"ancestors": [
{
"concept_id": 49436004,
"concept_name": "Atrial fibrillation and flutter",
"vocabulary_id": "SNOMED",
"domain_id": "Condition",
"concept_class_id": "Clinical Finding",
"standard_concept": "S",
"level": 1
}
],
"descendants": [],
"total_count": 1
}
}
]
},
"meta": {
"request_id": "req_batch_hierarchy_123",
"timestamp": "2024-12-22T10:00:00Z",
"vocab_release": "2025.1"
}
}
Overview
This endpoint allows you to perform multiple hierarchy queries (ancestors, descendants, or full hierarchy) for multiple concepts in a single API call. This is highly efficient for applications that need hierarchical information for many concepts simultaneously.Request Body
array
required
Array of hierarchy query requests (1-100 queries)
Show queries
Show queries
string
required
Unique identifier for this query (used to match results)
integer
required
The OMOP concept ID to query hierarchy for
string
required
Type of hierarchy query. Options:
ancestors, descendants, hierarchy, levelAny other value fails that individual query with Unknown operation: <name>
(the surrounding batch still succeeds - check success on each result).
Relationship traversal is not available here; use
GET /v1/concepts/{concept_id}/relationships
or POST /v1/concepts/relationships/traverse.object
Optional parameters for the query
Show params
Show params
integer
default:"10"
Maximum number of hierarchy levels to traverse
array
Accepted for backwards compatibility, but ignored by every operation this
endpoint supports.All four operations read OMOP’s precomputed
concept_ancestor closure,
which stores transitive Is a subsumption only and has no relationship
column to filter on. Passing Part of - or a nonexistent relationship -
returns the same Is a results.array
Limit results to specific vocabularies
array
Limit results to specific domains
boolean
default:"false"
Include relationships to invalid/deprecated concepts
Query Parameters
string
Specific vocabulary release version (e.g., “2025.1”)
Response
boolean
required
Indicates whether the request was successful
object
required
Response data containing batch results
Show data
Show data
array
required
Array of query results matching the input order
Show results
Show results
string
The query identifier from the request
integer
The concept ID that was queried
string
The operation that was performed
boolean
Whether this individual query succeeded
object
Result data if the query succeeded (structure varies by operation)
Show data (ancestors/descendants)
Show data (ancestors/descendants)
array
Array of ancestor concepts (for ancestors/hierarchy operations)
array
Array of descendant concepts (for descendants/hierarchy operations)
integer
Total number of results
string
Error message if the query failed
object
required
curl -X POST "https://api.omophub.com/v1/concepts/hierarchy/batch" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"queries": [
{
"query_id": "q1",
"concept_id": 201826,
"operation": "ancestors",
"params": {
"max_levels": 5
}
},
{
"query_id": "q2",
"concept_id": 4182210,
"operation": "descendants",
"params": {
"max_levels": 3
}
},
{
"query_id": "q3",
"concept_id": 313217,
"operation": "hierarchy",
"params": {
"max_levels": 4,
"relationship_types": ["Is a"]
}
}
]
}'
import requests
def batch_hierarchy_query(queries, api_key):
url = "https://api.omophub.com/v1/concepts/hierarchy/batch"
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
data = {"queries": queries}
response = requests.post(url, json=data, headers=headers)
return response.json()
# Example usage
queries = [
{
"query_id": "diabetes",
"concept_id": 201826,
"operation": "ancestors",
"params": {"max_levels": 5}
},
{
"query_id": "hypertension",
"concept_id": 4182210,
"operation": "descendants",
"params": {"max_levels": 3}
},
{
"query_id": "afib",
"concept_id": 313217,
"operation": "hierarchy",
"params": {"max_levels": 4}
}
]
result = batch_hierarchy_query(queries, "YOUR_API_KEY")
for query_result in result['data']['results']:
if query_result['success']:
data = query_result['data']
ancestors = len(data.get('ancestors', []))
descendants = len(data.get('descendants', []))
print(f"{query_result['query_id']}: {ancestors} ancestors, {descendants} descendants")
else:
print(f"{query_result['query_id']}: Error - {query_result['error']}")
import { OMOPHub } from '@omophub/omophub-node';
// Not yet exposed as a dedicated SDK method — use the typed low-level helper
// for parity with auth, retries, and error handling.
const client = new OMOPHub();
interface HierarchyQueryResult {
results: Array<{
query_id: string;
success: boolean;
data?: { ancestors?: unknown[]; descendants?: unknown[] };
error?: string;
}>;
}
const { data } = await client.post<HierarchyQueryResult>('/concepts/hierarchy/batch', {
queries: [
{ query_id: 'q1', concept_id: 201826, operation: 'ancestors', params: { max_levels: 5 } },
{ query_id: 'q2', concept_id: 4182210, operation: 'descendants', params: { max_levels: 3 } },
{ query_id: 'q3', concept_id: 313217, operation: 'hierarchy', params: { max_levels: 4 } },
],
});
data?.results.forEach((queryResult) => {
if (queryResult.success) {
const ancestors = queryResult.data?.ancestors?.length ?? 0;
const descendants = queryResult.data?.descendants?.length ?? 0;
console.log(`${queryResult.query_id}: ${ancestors} ancestors, ${descendants} descendants`);
} else {
console.error(`${queryResult.query_id} failed: ${queryResult.error}`);
}
});
{
"success": true,
"data": {
"results": [
{
"query_id": "q1",
"concept_id": 201826,
"operation": "ancestors",
"success": true,
"data": {
"ancestors": [
{
"concept_id": 73211009,
"concept_name": "Diabetes mellitus",
"vocabulary_id": "SNOMED",
"domain_id": "Condition",
"concept_class_id": "Clinical Finding",
"standard_concept": "S",
"level": 1
},
{
"concept_id": 64572001,
"concept_name": "Disease",
"vocabulary_id": "SNOMED",
"domain_id": "Condition",
"concept_class_id": "Clinical Finding",
"standard_concept": "S",
"level": 2
}
],
"total_count": 2
}
},
{
"query_id": "q2",
"concept_id": 4182210,
"operation": "descendants",
"success": true,
"data": {
"descendants": [
{
"concept_id": 320128,
"concept_name": "Essential hypertension",
"vocabulary_id": "SNOMED",
"domain_id": "Condition",
"concept_class_id": "Clinical Finding",
"standard_concept": "S",
"level": 1
}
],
"total_count": 1
}
},
{
"query_id": "q3",
"concept_id": 313217,
"operation": "hierarchy",
"success": true,
"data": {
"ancestors": [
{
"concept_id": 49436004,
"concept_name": "Atrial fibrillation and flutter",
"vocabulary_id": "SNOMED",
"domain_id": "Condition",
"concept_class_id": "Clinical Finding",
"standard_concept": "S",
"level": 1
}
],
"descendants": [],
"total_count": 1
}
}
]
},
"meta": {
"request_id": "req_batch_hierarchy_123",
"timestamp": "2024-12-22T10:00:00Z",
"vocab_release": "2025.1"
}
}
Usage Examples
Simple Batch Ancestors
Get ancestors for multiple concepts:{
"queries": [
{"query_id": "q1", "concept_id": 201826, "operation": "ancestors"},
{"query_id": "q2", "concept_id": 4182210, "operation": "ancestors"},
{"query_id": "q3", "concept_id": 313217, "operation": "ancestors"}
]
}
Mixed Operations
Combine different operations in one batch:{
"queries": [
{"query_id": "ancestors_query", "concept_id": 201826, "operation": "ancestors", "params": {"max_levels": 5}},
{"query_id": "descendants_query", "concept_id": 4182210, "operation": "descendants", "params": {"max_levels": 3}},
{"query_id": "full_hierarchy", "concept_id": 313217, "operation": "hierarchy", "params": {"max_levels": 4}}
]
}
With Filtering
Use vocabulary and relationship filters:{
"queries": [
{
"query_id": "filtered_query",
"concept_id": 201826,
"operation": "hierarchy",
"params": {
"max_levels": 5,
"relationship_types": ["Is a"],
"vocabulary_ids": ["SNOMED", "ICD10CM"]
}
}
]
}
Important Notes
- Batch size limit: Maximum 100 queries per batch request
- Performance optimization: Batch processing is significantly faster than individual requests
- Error handling: Individual query failures don’t affect other queries in the batch
- Result matching: Use
query_idto match results to your input queries - Rate limiting: Batch requests count as single requests for rate limiting purposes
Related Endpoints
- Get Concept Ancestors - Single concept ancestors
- Get Concept Descendants - Single concept descendants
- Get Concept Hierarchy - Complete hierarchy tree
Was this page helpful?
⌘I