curl -X GET "https://api.omophub.com/v1/concepts/201820/hierarchy?max_levels=3" \
-H "Authorization: Bearer YOUR_API_KEY"
curl -X GET "https://api.omophub.com/v1/concepts/201820/hierarchy?format=graph&max_levels=3" \
-H "Authorization: Bearer YOUR_API_KEY"
import requests
concept_id = 201820 # Diabetes mellitus (SNOMED code 73211009)
url = f"https://api.omophub.com/v1/concepts/{concept_id}/hierarchy"
params = {
"max_levels": 3,
"vocabulary_ids": "SNOMED"
}
headers = {
"Authorization": "Bearer YOUR_API_KEY"
}
response = requests.get(url, params=params, headers=headers)
hierarchy_data = response.json()
print(f"Concept ID: {hierarchy_data['data']['concept_id']}")
print(f"Total ancestors: {hierarchy_data['data']['total_ancestors']}")
print(f"Total descendants: {hierarchy_data['data']['total_descendants']}")
import requests
concept_id = 201820
url = f"https://api.omophub.com/v1/concepts/{concept_id}/hierarchy"
params = {
"format": "graph",
"max_levels": 3
}
headers = {"Authorization": "Bearer YOUR_API_KEY"}
response = requests.get(url, params=params, headers=headers)
graph_data = response.json()
# Use for D3.js or other visualization libraries
nodes = graph_data['data']['nodes']
edges = graph_data['data']['edges']
print(f"Nodes: {len(nodes)}, Edges: {len(edges)}")
import { OMOPHub } from '@omophub/omophub-node';
const client = new OMOPHub();
const { data: hierarchyData } = await client.hierarchy.get(201820, {
maxLevels: 3,
});
console.log(`Ancestors: ${hierarchyData?.total_ancestors}`);
console.log(`Descendants: ${hierarchyData?.total_descendants}`);
const { data: graphData } = await client.hierarchy.get(201820, {
format: 'graph',
maxLevels: 3,
});
// Use with D3.js force-directed graph
const { nodes, edges } = graphData ?? { nodes: [], edges: [] };
{
"success": true,
"data": {
"concept_id": 201820,
"ancestors": [
{
"concept_id": 31821,
"concept_name": "Disorder of endocrine system",
"concept_code": "362969004",
"vocabulary_id": "SNOMED",
"vocabulary_name": "SNOMED Clinical Terms",
"domain_id": "Condition",
"concept_class_id": "Disorder",
"standard_concept": "S",
"level": 1,
"min_levels_of_separation": 1,
"max_levels_of_separation": 1,
"relationship_id": "Is a",
"relationship_name": "Is a"
},
{
"concept_id": 4274025,
"concept_name": "Disease",
"concept_code": "64572001",
"vocabulary_id": "SNOMED",
"vocabulary_name": "SNOMED Clinical Terms",
"domain_id": "Condition",
"concept_class_id": "Disorder",
"standard_concept": "S",
"level": 2,
"min_levels_of_separation": 2,
"max_levels_of_separation": 2,
"relationship_id": "Is a",
"relationship_name": "Is a"
}
],
"descendants": [
{
"concept_id": 201826,
"concept_name": "Type 2 diabetes mellitus",
"concept_code": "44054006",
"vocabulary_id": "SNOMED",
"vocabulary_name": "SNOMED Clinical Terms",
"domain_id": "Condition",
"concept_class_id": "Disorder",
"standard_concept": "S",
"level": 1,
"min_levels_of_separation": 1,
"max_levels_of_separation": 1,
"relationship_id": "Subsumes",
"relationship_name": "Subsumes"
},
{
"concept_id": 201254,
"concept_name": "Type 1 diabetes mellitus",
"concept_code": "46635009",
"vocabulary_id": "SNOMED",
"vocabulary_name": "SNOMED Clinical Terms",
"domain_id": "Condition",
"concept_class_id": "Disorder",
"standard_concept": "S",
"level": 1,
"min_levels_of_separation": 1,
"max_levels_of_separation": 1,
"relationship_id": "Subsumes",
"relationship_name": "Subsumes"
}
],
"level": 3,
"max_level": 5,
"total_ancestors": 2,
"total_descendants": 2
},
"meta": {
"request_id": "req_hierarchy_123",
"timestamp": "2024-12-22T10:30:00Z",
"vocab_release": "2025.2"
}
}
{
"success": true,
"data": {
"concept_id": 201820,
"nodes": [
{
"id": 201820,
"name": "Diabetes mellitus",
"level": 0,
"vocabulary_id": "SNOMED",
"domain_id": "Condition",
"concept_class_id": "Disorder",
"standard_concept": "S"
},
{
"id": 31821,
"name": "Disorder of endocrine system",
"level": -1,
"vocabulary_id": "SNOMED",
"domain_id": "Condition",
"concept_class_id": "Disorder",
"standard_concept": "S"
},
{
"id": 201826,
"name": "Type 2 diabetes mellitus",
"level": 1,
"vocabulary_id": "SNOMED",
"domain_id": "Condition",
"concept_class_id": "Disorder",
"standard_concept": "S"
},
{
"id": 201254,
"name": "Type 1 diabetes mellitus",
"level": 1,
"vocabulary_id": "SNOMED",
"domain_id": "Condition",
"concept_class_id": "Disorder",
"standard_concept": "S"
}
],
"edges": [
{
"from": 201820,
"to": 31821,
"relationship_id": "Is a"
},
{
"from": 201820,
"to": 201826,
"relationship_id": "Subsumes"
},
{
"from": 201820,
"to": 201254,
"relationship_id": "Subsumes"
}
]
},
"meta": {
"request_id": "req_hierarchy_456",
"timestamp": "2024-12-22T10:30:00Z",
"vocab_release": "2025.2"
}
}
Get Concept Hierarchy
Retrieve the complete OMOP hierarchy for a concept - ancestors and descendants in one unified view for phenotype development and concept sets.
curl -X GET "https://api.omophub.com/v1/concepts/201820/hierarchy?max_levels=3" \
-H "Authorization: Bearer YOUR_API_KEY"
curl -X GET "https://api.omophub.com/v1/concepts/201820/hierarchy?format=graph&max_levels=3" \
-H "Authorization: Bearer YOUR_API_KEY"
import requests
concept_id = 201820 # Diabetes mellitus (SNOMED code 73211009)
url = f"https://api.omophub.com/v1/concepts/{concept_id}/hierarchy"
params = {
"max_levels": 3,
"vocabulary_ids": "SNOMED"
}
headers = {
"Authorization": "Bearer YOUR_API_KEY"
}
response = requests.get(url, params=params, headers=headers)
hierarchy_data = response.json()
print(f"Concept ID: {hierarchy_data['data']['concept_id']}")
print(f"Total ancestors: {hierarchy_data['data']['total_ancestors']}")
print(f"Total descendants: {hierarchy_data['data']['total_descendants']}")
import requests
concept_id = 201820
url = f"https://api.omophub.com/v1/concepts/{concept_id}/hierarchy"
params = {
"format": "graph",
"max_levels": 3
}
headers = {"Authorization": "Bearer YOUR_API_KEY"}
response = requests.get(url, params=params, headers=headers)
graph_data = response.json()
# Use for D3.js or other visualization libraries
nodes = graph_data['data']['nodes']
edges = graph_data['data']['edges']
print(f"Nodes: {len(nodes)}, Edges: {len(edges)}")
import { OMOPHub } from '@omophub/omophub-node';
const client = new OMOPHub();
const { data: hierarchyData } = await client.hierarchy.get(201820, {
maxLevels: 3,
});
console.log(`Ancestors: ${hierarchyData?.total_ancestors}`);
console.log(`Descendants: ${hierarchyData?.total_descendants}`);
const { data: graphData } = await client.hierarchy.get(201820, {
format: 'graph',
maxLevels: 3,
});
// Use with D3.js force-directed graph
const { nodes, edges } = graphData ?? { nodes: [], edges: [] };
{
"success": true,
"data": {
"concept_id": 201820,
"ancestors": [
{
"concept_id": 31821,
"concept_name": "Disorder of endocrine system",
"concept_code": "362969004",
"vocabulary_id": "SNOMED",
"vocabulary_name": "SNOMED Clinical Terms",
"domain_id": "Condition",
"concept_class_id": "Disorder",
"standard_concept": "S",
"level": 1,
"min_levels_of_separation": 1,
"max_levels_of_separation": 1,
"relationship_id": "Is a",
"relationship_name": "Is a"
},
{
"concept_id": 4274025,
"concept_name": "Disease",
"concept_code": "64572001",
"vocabulary_id": "SNOMED",
"vocabulary_name": "SNOMED Clinical Terms",
"domain_id": "Condition",
"concept_class_id": "Disorder",
"standard_concept": "S",
"level": 2,
"min_levels_of_separation": 2,
"max_levels_of_separation": 2,
"relationship_id": "Is a",
"relationship_name": "Is a"
}
],
"descendants": [
{
"concept_id": 201826,
"concept_name": "Type 2 diabetes mellitus",
"concept_code": "44054006",
"vocabulary_id": "SNOMED",
"vocabulary_name": "SNOMED Clinical Terms",
"domain_id": "Condition",
"concept_class_id": "Disorder",
"standard_concept": "S",
"level": 1,
"min_levels_of_separation": 1,
"max_levels_of_separation": 1,
"relationship_id": "Subsumes",
"relationship_name": "Subsumes"
},
{
"concept_id": 201254,
"concept_name": "Type 1 diabetes mellitus",
"concept_code": "46635009",
"vocabulary_id": "SNOMED",
"vocabulary_name": "SNOMED Clinical Terms",
"domain_id": "Condition",
"concept_class_id": "Disorder",
"standard_concept": "S",
"level": 1,
"min_levels_of_separation": 1,
"max_levels_of_separation": 1,
"relationship_id": "Subsumes",
"relationship_name": "Subsumes"
}
],
"level": 3,
"max_level": 5,
"total_ancestors": 2,
"total_descendants": 2
},
"meta": {
"request_id": "req_hierarchy_123",
"timestamp": "2024-12-22T10:30:00Z",
"vocab_release": "2025.2"
}
}
{
"success": true,
"data": {
"concept_id": 201820,
"nodes": [
{
"id": 201820,
"name": "Diabetes mellitus",
"level": 0,
"vocabulary_id": "SNOMED",
"domain_id": "Condition",
"concept_class_id": "Disorder",
"standard_concept": "S"
},
{
"id": 31821,
"name": "Disorder of endocrine system",
"level": -1,
"vocabulary_id": "SNOMED",
"domain_id": "Condition",
"concept_class_id": "Disorder",
"standard_concept": "S"
},
{
"id": 201826,
"name": "Type 2 diabetes mellitus",
"level": 1,
"vocabulary_id": "SNOMED",
"domain_id": "Condition",
"concept_class_id": "Disorder",
"standard_concept": "S"
},
{
"id": 201254,
"name": "Type 1 diabetes mellitus",
"level": 1,
"vocabulary_id": "SNOMED",
"domain_id": "Condition",
"concept_class_id": "Disorder",
"standard_concept": "S"
}
],
"edges": [
{
"from": 201820,
"to": 31821,
"relationship_id": "Is a"
},
{
"from": 201820,
"to": 201826,
"relationship_id": "Subsumes"
},
{
"from": 201820,
"to": 201254,
"relationship_id": "Subsumes"
}
]
},
"meta": {
"request_id": "req_hierarchy_456",
"timestamp": "2024-12-22T10:30:00Z",
"vocab_release": "2025.2"
}
}
This endpoint provides a comprehensive hierarchical view of a concept, showing its position within the medical vocabulary structure by including both ancestor (parent) and descendant (child) relationships in a single response.
Path Parameters
The unique identifier of the concept to retrieve hierarchy for
Example:
Example:
201820 (Diabetes mellitus)This path expects an OMOP
concept_id, not a vocabulary-specific code. If you
start with SNOMED code 73211009, resolve it with GET /v1/concepts/by-code/ {vocabulary_id}/{concept_code}
to obtain OMOP concept ID 201820 first.Query Parameters
Response format for hierarchy data
Options:
-
Options:
flat, graph
-
flat: Returns ancestors and descendants as separate arrays (default)graph: Returns nodes and edges for visualization (similar to OHDSI Athena)
Maximum number of results to return per direction (ancestors/descendants) for
performance optimization
Range:
Recommended: Use 100-500 for interactive queries, up to 1000 for bulk analysis
Range:
1-5000Recommended: Use 100-500 for interactive queries, up to 1000 for bulk analysis
This endpoint always traverses the
Is a / Subsumes hierarchy. It reads
OMOP’s precomputed concept_ancestor closure, which has no relationship
column to filter on. A relationship_types parameter is accepted for
backwards compatibility but has no effect here - passing Part of, or
even a nonexistent relationship, returns the same result. To traverse other
relationship types, use GET /v1/concepts/{concept_id} /relationships or
POST /v1/concepts/relationships/traverse.Include deprecated/invalid concepts in hierarchy (by default they are
excluded)
Response
Flat Format (default)
Array of ancestor concepts in hierarchical order
Show Ancestor Concept Object
Show Ancestor Concept Object
Array of descendant concepts in hierarchical order
Show Descendant Concept Object
Show Descendant Concept Object
Graph Format (format=graph)
Array of concept nodes for visualization
Show Node Object
Show Node Object
curl -X GET "https://api.omophub.com/v1/concepts/201820/hierarchy?max_levels=3" \
-H "Authorization: Bearer YOUR_API_KEY"
curl -X GET "https://api.omophub.com/v1/concepts/201820/hierarchy?format=graph&max_levels=3" \
-H "Authorization: Bearer YOUR_API_KEY"
import requests
concept_id = 201820 # Diabetes mellitus (SNOMED code 73211009)
url = f"https://api.omophub.com/v1/concepts/{concept_id}/hierarchy"
params = {
"max_levels": 3,
"vocabulary_ids": "SNOMED"
}
headers = {
"Authorization": "Bearer YOUR_API_KEY"
}
response = requests.get(url, params=params, headers=headers)
hierarchy_data = response.json()
print(f"Concept ID: {hierarchy_data['data']['concept_id']}")
print(f"Total ancestors: {hierarchy_data['data']['total_ancestors']}")
print(f"Total descendants: {hierarchy_data['data']['total_descendants']}")
import requests
concept_id = 201820
url = f"https://api.omophub.com/v1/concepts/{concept_id}/hierarchy"
params = {
"format": "graph",
"max_levels": 3
}
headers = {"Authorization": "Bearer YOUR_API_KEY"}
response = requests.get(url, params=params, headers=headers)
graph_data = response.json()
# Use for D3.js or other visualization libraries
nodes = graph_data['data']['nodes']
edges = graph_data['data']['edges']
print(f"Nodes: {len(nodes)}, Edges: {len(edges)}")
import { OMOPHub } from '@omophub/omophub-node';
const client = new OMOPHub();
const { data: hierarchyData } = await client.hierarchy.get(201820, {
maxLevels: 3,
});
console.log(`Ancestors: ${hierarchyData?.total_ancestors}`);
console.log(`Descendants: ${hierarchyData?.total_descendants}`);
const { data: graphData } = await client.hierarchy.get(201820, {
format: 'graph',
maxLevels: 3,
});
// Use with D3.js force-directed graph
const { nodes, edges } = graphData ?? { nodes: [], edges: [] };
{
"success": true,
"data": {
"concept_id": 201820,
"ancestors": [
{
"concept_id": 31821,
"concept_name": "Disorder of endocrine system",
"concept_code": "362969004",
"vocabulary_id": "SNOMED",
"vocabulary_name": "SNOMED Clinical Terms",
"domain_id": "Condition",
"concept_class_id": "Disorder",
"standard_concept": "S",
"level": 1,
"min_levels_of_separation": 1,
"max_levels_of_separation": 1,
"relationship_id": "Is a",
"relationship_name": "Is a"
},
{
"concept_id": 4274025,
"concept_name": "Disease",
"concept_code": "64572001",
"vocabulary_id": "SNOMED",
"vocabulary_name": "SNOMED Clinical Terms",
"domain_id": "Condition",
"concept_class_id": "Disorder",
"standard_concept": "S",
"level": 2,
"min_levels_of_separation": 2,
"max_levels_of_separation": 2,
"relationship_id": "Is a",
"relationship_name": "Is a"
}
],
"descendants": [
{
"concept_id": 201826,
"concept_name": "Type 2 diabetes mellitus",
"concept_code": "44054006",
"vocabulary_id": "SNOMED",
"vocabulary_name": "SNOMED Clinical Terms",
"domain_id": "Condition",
"concept_class_id": "Disorder",
"standard_concept": "S",
"level": 1,
"min_levels_of_separation": 1,
"max_levels_of_separation": 1,
"relationship_id": "Subsumes",
"relationship_name": "Subsumes"
},
{
"concept_id": 201254,
"concept_name": "Type 1 diabetes mellitus",
"concept_code": "46635009",
"vocabulary_id": "SNOMED",
"vocabulary_name": "SNOMED Clinical Terms",
"domain_id": "Condition",
"concept_class_id": "Disorder",
"standard_concept": "S",
"level": 1,
"min_levels_of_separation": 1,
"max_levels_of_separation": 1,
"relationship_id": "Subsumes",
"relationship_name": "Subsumes"
}
],
"level": 3,
"max_level": 5,
"total_ancestors": 2,
"total_descendants": 2
},
"meta": {
"request_id": "req_hierarchy_123",
"timestamp": "2024-12-22T10:30:00Z",
"vocab_release": "2025.2"
}
}
{
"success": true,
"data": {
"concept_id": 201820,
"nodes": [
{
"id": 201820,
"name": "Diabetes mellitus",
"level": 0,
"vocabulary_id": "SNOMED",
"domain_id": "Condition",
"concept_class_id": "Disorder",
"standard_concept": "S"
},
{
"id": 31821,
"name": "Disorder of endocrine system",
"level": -1,
"vocabulary_id": "SNOMED",
"domain_id": "Condition",
"concept_class_id": "Disorder",
"standard_concept": "S"
},
{
"id": 201826,
"name": "Type 2 diabetes mellitus",
"level": 1,
"vocabulary_id": "SNOMED",
"domain_id": "Condition",
"concept_class_id": "Disorder",
"standard_concept": "S"
},
{
"id": 201254,
"name": "Type 1 diabetes mellitus",
"level": 1,
"vocabulary_id": "SNOMED",
"domain_id": "Condition",
"concept_class_id": "Disorder",
"standard_concept": "S"
}
],
"edges": [
{
"from": 201820,
"to": 31821,
"relationship_id": "Is a"
},
{
"from": 201820,
"to": 201826,
"relationship_id": "Subsumes"
},
{
"from": 201820,
"to": 201254,
"relationship_id": "Subsumes"
}
]
},
"meta": {
"request_id": "req_hierarchy_456",
"timestamp": "2024-12-22T10:30:00Z",
"vocab_release": "2025.2"
}
}
Usage Examples
Basic Hierarchy View
Get complete hierarchy context for a concept:TypeScript
const { data: hierarchy } = await client.hierarchy.get(201820);
Limited Depth Hierarchy
Control the depth of ancestor and descendant traversal:TypeScript
const { data: limitedHierarchy } = await client.hierarchy.get(201820, {
maxLevels: 2,
maxResults: 100,
});
Graph Format for Visualization
Get hierarchy in graph structure for D3.js or similar visualization libraries:TypeScript
const { data: graphData } = await client.hierarchy.get(201820, {
format: 'graph',
maxLevels: 3,
});
Filtered Hierarchy
Filter to specific vocabularies:TypeScript
const { data: filteredHierarchy } = await client.hierarchy.get(201820, {
vocabularyIds: ['SNOMED'],
domainIds: ['Condition'],
});
Related Endpoints
- Get Concept Ancestors - Detailed ancestor information with pagination
- Get Concept Descendants - Detailed descendant information with pagination
- Get Concept Relationships - All concept relationships
- Search Concepts - Search within hierarchies
Notes
- The hierarchy endpoint combines ancestors and descendants in a single request for convenience
- Use the
graphformat when building visualizations (compatible with D3.js, Cytoscape, etc.) - The
flatformat is better for data processing and analysis - In graph format, level 0 is the central concept, negative levels are ancestors, positive are descendants
- Large hierarchies may be limited by
max_resultsto ensure performance - Cross-vocabulary concepts may show relationships spanning multiple vocabularies
Was this page helpful?