> ## Documentation Index
> Fetch the complete documentation index at: https://docs.omophub.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Search Trending

> Retrieve trending and popular OMOP concept search queries based on platform-wide usage patterns and analytics data to surface relevant terms.

This endpoint provides insights into trending medical concepts and popular search queries, helping users discover relevant terminology based on community usage patterns and temporal trends.

## Query Parameters

<ParamField query="vocabulary_ids" type="string" optional>
  Comma-separated list of vocabulary IDs to filter trending searches

  <br />

  **Example:** `SNOMED,ICD10CM,LOINC`
</ParamField>

<ParamField query="domain_ids" type="string" optional>
  Comma-separated list of domain IDs to focus trending analysis

  <br />

  **Example:** `Condition,Drug,Procedure`
</ParamField>

<ParamField query="time_period" type="string" optional default="7d">
  Time period for trending analysis

  <br />

  **Options:** `1d`, `7d`, `30d`, `90d`
</ParamField>

<ParamField query="trend_type" type="string" optional default="search_volume">
  Type of trending metric to analyze

  <br />

  **Options:** `search_volume`, `new_concepts`, `rising_queries`, `seasonal_patterns`
</ParamField>

<ParamField query="include_statistics" type="boolean" optional default="false">
  Include detailed trending statistics and growth metrics
</ParamField>

<ParamField query="include_related" type="boolean" optional default="false">
  Include related trending concepts and co-occurrence patterns
</ParamField>

<ParamField query="page_size" type="integer" optional default="20">
  Number of trending items to return (max 100)
</ParamField>

<ParamField query="page" type="integer" optional default="1">
  Page number for pagination (1-based)
</ParamField>

## Response

<ResponseField name="data" type="array">
  Array of trending search items with analytics data

  <Expandable title="Trending Item Object">
    <ResponseField name="query" type="string">
      The trending search query or concept term
    </ResponseField>

    <ResponseField name="concept_id" type="string" optional>
      Associated concept ID if trending item is a specific concept (returned as string to prevent precision loss)
    </ResponseField>

    <ResponseField name="concept_name" type="string" optional>
      Standard concept name if applicable
    </ResponseField>

    <ResponseField name="vocabulary_id" type="string" optional>
      Vocabulary containing the trending concept
    </ResponseField>

    <ResponseField name="domain_id" type="string" optional>
      Domain classification of the trending concept
    </ResponseField>

    <ResponseField name="trend_score" type="number">
      Normalized trending score (0-100)
    </ResponseField>

    <ResponseField name="search_volume" type="integer">
      Number of searches in the specified time period
    </ResponseField>

    <ResponseField name="growth_rate" type="number">
      Percentage growth rate compared to previous period
    </ResponseField>

    <ResponseField name="trend_direction" type="string">
      Direction of the trend

      <br />

      **Values:** `rising`, `declining`, `stable`, `new`
    </ResponseField>

    <ResponseField name="statistics" type="object" optional>
      Detailed trending statistics (when include\_statistics=true)

      <Expandable title="Statistics Object">
        <ResponseField name="peak_volume" type="integer">
          Highest search volume in the period
        </ResponseField>

        <ResponseField name="average_volume" type="number">
          Average daily search volume
        </ResponseField>

        <ResponseField name="consistency_score" type="number">
          Trend consistency score (0-1)
        </ResponseField>

        <ResponseField name="seasonal_factor" type="number">
          Seasonal adjustment factor
        </ResponseField>

        <ResponseField name="first_seen" type="string">
          ISO timestamp when trend was first detected
        </ResponseField>

        <ResponseField name="velocity" type="number">
          Rate of change in search volume
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="related_concepts" type="array" optional>
      Related trending concepts (when include\_related=true)

      <Expandable title="Related Concept Object">
        <ResponseField name="concept_id" type="string">
          Related concept identifier (returned as string to prevent precision loss)
        </ResponseField>

        <ResponseField name="concept_name" type="string">
          Related concept name
        </ResponseField>

        <ResponseField name="correlation_score" type="number">
          Correlation strength with main trending item (0-1)
        </ResponseField>

        <ResponseField name="co_occurrence_rate" type="number">
          Rate of co-occurrence in searches
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="geographic_data" type="object" optional>
      Geographic distribution of trend (when available)

      <Expandable title="Geographic Data Object">
        <ResponseField name="top_regions" type="array">
          Top geographic regions for this trend
        </ResponseField>

        <ResponseField name="regional_scores" type="object">
          Regional trending scores
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="meta" type="object">
  Response metadata and pagination information

  <Expandable title="Metadata Object">
    <ResponseField name="pagination" type="object">
      <ResponseField name="page" type="integer">Current page number</ResponseField>
      <ResponseField name="page_size" type="integer">Items per page</ResponseField>
      <ResponseField name="total_items" type="integer">Total trending items available</ResponseField>
      <ResponseField name="total_pages" type="integer">Total number of pages</ResponseField>
      <ResponseField name="has_next" type="boolean">Whether next page exists</ResponseField>
      <ResponseField name="has_previous" type="boolean">Whether previous page exists</ResponseField>
    </ResponseField>

    <ResponseField name="analysis_period" type="object">
      Time period used for trend analysis
      <ResponseField name="start_date" type="string">Analysis start date (ISO format)</ResponseField>
      <ResponseField name="end_date" type="string">Analysis end date (ISO format)</ResponseField>
      <ResponseField name="period_type" type="string">Type of period analyzed</ResponseField>
    </ResponseField>

    <ResponseField name="data_freshness" type="string">
      Timestamp of last trending data update
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash theme={null}
  curl -X GET "https://api.omophub.com/v1/search/trending?time_period=7d&trend_type=search_volume&include_statistics=true&page_size=10" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json"
  ```

  ```javascript theme={null}
  const response = await fetch('https://api.omophub.com/v1/search/trending?time_period=7d&trend_type=search_volume&include_statistics=true&page_size=10', {
    method: 'GET',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    }
  });

  const trendingData = await response.json();
  console.log('Trending searches:', trendingData.data.data);
  ```

  ```python theme={null}
  import requests

  url = "https://api.omophub.com/v1/search/trending"
  params = {
      "time_period": "7d",
      "trend_type": "search_volume",
      "include_statistics": True,
      "page_size": 10
  }

  headers = {
      "Authorization": "Bearer YOUR_API_KEY",
      "Content-Type": "application/json"
  }

  response = requests.get(url, params=params, headers=headers)
  trending_data = response.json()

  print(f"Found {len(trending_data['data']['data'])} trending items")
  for item in trending_data['data']['data']:
      print(f"- {item['query']}: {item['trend_score']} score, {item['growth_rate']}% growth")
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "success": true,
    "data": {
      "data": [
        {
          "query": "covid-19 symptoms",
          "concept_id": "840539006",
          "concept_name": "Disease caused by severe acute respiratory syndrome coronavirus 2",
          "vocabulary_id": "SNOMED",
          "domain_id": "Condition",
          "trend_score": 95.8,
          "search_volume": 15420,
          "growth_rate": 234.7,
          "trend_direction": "rising",
          "statistics": {
            "peak_volume": 2180,
            "average_volume": 1850.0,
            "consistency_score": 0.82,
            "seasonal_factor": 1.15,
            "first_seen": "2024-12-15T08:00:00Z",
            "velocity": 12.3
          },
          "related_concepts": [
            {
              "concept_id": "49727002",
              "concept_name": "Cough",
              "correlation_score": 0.78,
              "co_occurrence_rate": 0.45
            },
            {
              "concept_id": "386661006",
              "concept_name": "Fever",
              "correlation_score": 0.72,
              "co_occurrence_rate": 0.41
            }
          ]
        },
        {
          "query": "diabetes management",
          "concept_id": "73211009",
          "concept_name": "Diabetes mellitus",
          "vocabulary_id": "SNOMED",
          "domain_id": "Condition",
          "trend_score": 87.3,
          "search_volume": 8920,
          "growth_rate": 45.2,
          "trend_direction": "rising",
          "statistics": {
            "peak_volume": 1420,
            "average_volume": 1274.3,
            "consistency_score": 0.91,
            "seasonal_factor": 1.03,
            "first_seen": "2024-12-10T14:30:00Z",
            "velocity": 8.7
          }
        },
        {
          "query": "hypertension treatment",
          "concept_id": "38341003",
          "concept_name": "Hypertensive disorder, systemic arterial",
          "vocabulary_id": "SNOMED",
          "domain_id": "Condition",
          "trend_score": 79.1,
          "search_volume": 6750,
          "growth_rate": 28.9,
          "trend_direction": "stable"
        }
      ],
      "meta": {
        "pagination": {
          "page": 1,
          "page_size": 10,
          "total_items": 156,
          "total_pages": 16,
          "has_next": true,
          "has_previous": false
        },
        "analysis_period": {
          "start_date": "2024-12-15T00:00:00Z",
          "end_date": "2024-12-22T00:00:00Z",
          "period_type": "7d"
        },
        "data_freshness": "2024-12-22T12:00:00Z",
        "request_id": "req_search_trending_7d_analytics_001",
        "timestamp": "2024-12-22T10:30:00Z",
        "vocab_release": "2025.2"
      }
    }
  }
  ```
</ResponseExample>

## Usage Examples

### Basic Trending Analysis

Get the most popular trending searches in the past week:

```javascript theme={null}
const trending = await fetch('/v1/search/trending?time_period=7d&page_size=20');
```

### Domain-Specific Trends

Find trending searches within specific medical domains:

```javascript theme={null}
const conditionTrends = await fetch('/v1/search/trending?domain_ids=Condition,Drug&time_period=30d');
```

### Rising Query Detection

Identify rapidly growing search queries:

```javascript theme={null}
const risingQueries = await fetch('/v1/search/trending?trend_type=rising_queries&include_statistics=true');
```

### Vocabulary-Specific Analysis

Analyze trends within specific vocabularies:

```javascript theme={null}
const snomedTrends = await fetch('/v1/search/trending?vocabulary_ids=SNOMED&time_period=90d&include_related=true');
```

### Seasonal Pattern Analysis

Detect seasonal trending patterns:

```javascript theme={null}
const seasonalTrends = await fetch('/v1/search/trending?trend_type=seasonal_patterns&time_period=90d');
```

## Related Endpoints

* [Search Concepts](/api-reference/search/basic-search) - Primary concept search functionality
* [Search Autocomplete](/api-reference/search/search-autocomplete) - Real-time search suggestions
* [Search Facets](/api-reference/search/search-facets) - Search result faceting and filtering
* [Search Suggest](/api-reference/search/search-suggest) - Intelligent search suggestions
* [Get Vocabulary Statistics](/api-reference/vocabulary/get-vocabulary-statistics) - Overall vocabulary usage stats

## Notes

* Trending data is updated every 4 hours with the latest search analytics
* Trend scores are normalized across all vocabularies and time periods
* Geographic data may not be available for all trending items due to privacy considerations
* Rising queries are identified using proprietary algorithms that account for baseline search volume
* Seasonal patterns require at least 90 days of historical data for accurate detection
* Some trending data may be filtered to exclude potentially sensitive health information
