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

# Visualize theme volume evolution

## Overview

This guide demonstrates how to use the Bigdata Search Volume API endpoint (`/v1/search/volume`) to retrieve and visualize theme volume data over time. The script displays the evolution of documents, chunks, and sentiment for any given theme, helping you track narrative trends and coverage patterns.

<Card title="GitHub Repository" icon="github" href="https://github.com/Bigdata-com/bigdata-docs-resources/tree/main/how_to_guides/api_theme_volume">
  Access the complete source code, requirements, and setup instructions.
</Card>

## Features

✅ Retrieves theme volume data from the Bigdata Search Volume API <br />
✅ Visualizes three key metrics: number of documents, number of chunks, and sentiment <br />
✅ Displays daily values as bars (documents and chunks) or lines (sentiment) <br />
✅ Overlays weekly average trends for better pattern recognition <br />
✅ Generates high-resolution PNG charts with theme-specific filenames <br />
✅ Supports custom date ranges and themes via command-line arguments <br />

## Use Cases

The Search Volume endpoint is valuable for several scenarios:

* **Evaluate Coverage**: See how many unique documents Bigdata has available for your particular query
* **Narrative/Thematic Screeners**: Create a query and see how the defined narrative evolves over time
* **Query Strategy**: Check coverage and plan how to structure your queries accordingly

<Tip>
  **Efficient Usage**: The `/v1/search/volume` endpoint consumes exactly 1 API Query Unit regardless of the time period queried (up to 60 weeks maximum), making it a very efficient way to visualize narrative evolution over time.
</Tip>

<Tip>
  **Flexible Filtering**: The Search Volume endpoint supports all the same filters as the Search endpoint, including entity, source, category, keyword, and sentiment filters. For more details, check out the [Search Volume API specification](https://docs.bigdata.com/api-reference/search/search-volume).
</Tip>

## Prerequisites

* Python 3.9 or higher
* A Bigdata.com API key

### System Dependencies

Matplotlib requires some system libraries for chart generation.

<Tabs>
  <Tab title="Ubuntu/Debian">
    ```bash theme={null}
    sudo apt-get install python3-tk
    ```
  </Tab>

  <Tab title="macOS">
    ```bash theme={null}
    # Usually pre-installed, but if needed:
    brew install python-tk
    ```
  </Tab>

  <Tab title="Windows">
    Matplotlib should work out of the box with the pip installation.
  </Tab>
</Tabs>

## Setup

<Steps>
  <Step title="Clone the repository">
    ```bash theme={null}
    git clone https://github.com/Bigdata-com/bigdata-docs-resources.git
    cd bigdata-docs-resources/how_to_guides/api_theme_volume
    ```
  </Step>

  <Step title="Create a virtual environment (recommended)">
    ```bash theme={null}
    python -m venv venv
    ```

    Activate the virtual environment:

    <Tabs>
      <Tab title="Linux/macOS">
        ```bash theme={null}
        source venv/bin/activate
        ```
      </Tab>

      <Tab title="Windows">
        ```bash theme={null}
        venv\Scripts\activate
        ```
      </Tab>
    </Tabs>
  </Step>

  <Step title="Install Python dependencies">
    ```bash theme={null}
    pip install -r requirements.txt
    ```
  </Step>

  <Step title="Configure API Key">
    Copy the `.env_template` file to `.env`:

    ```bash theme={null}
    cp .env_template .env
    ```

    Open the `.env` file and replace the placeholder value with your actual API key:

    ```
    BIGDATA_API_KEY=your_bigdata_api_key_here
    ```

    You can obtain your API key from the [Bigdata Platform](https://platform.bigdata.com/api-keys).

    <Warning>
      Never commit your `.env` file to version control. Add it to your `.gitignore` file.
    </Warning>
  </Step>
</Steps>

## Usage

### Run the script

Run the script with required date range parameters:

```bash theme={null}
python theme_volume_evolution.py --start-date 2025-01-01 --end-date 2025-12-15
```

### Command-Line Arguments

| Argument       | Short | Description                                                 | Required |
| -------------- | ----- | ----------------------------------------------------------- | -------- |
| `--start-date` | `-s`  | Start date in format `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SSZ` | Yes      |
| `--end-date`   | `-e`  | End date in format `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SSZ`   | Yes      |
| `--theme`      | `-t`  | Theme to search for (default: "Tariffs impact")             | No       |

### Examples

Basic usage with default theme:

```bash theme={null}
python theme_volume_evolution.py --start-date 2025-01-01 --end-date 2025-12-15
```

Using short flags:

```bash theme={null}
python theme_volume_evolution.py -s 2025-01-01 -e 2025-12-15
```

With a custom theme:

```bash theme={null}
python theme_volume_evolution.py -s 2025-01-01 -e 2025-12-15 --theme "Quantum computing chip"
```

View help:

```bash theme={null}
python theme_volume_evolution.py --help
```

## Output

The script generates a high-resolution (300 DPI) PNG chart with a timestamped filename:

```
{theme}_volume_evolution_YYYYMMDD_HHMMSS.png
```

The chart includes three subplots:

1. **Unique Documents per Day**: Daily document counts as bars with weekly average line
2. **Chunks per Day**: Daily chunk counts as bars with weekly average line
3. **Sentiment per Day**: Daily sentiment values as a line with weekly average line

## Example Charts

Here are example charts generated for different themes:

<Tabs>
  <Tab title="Tariffs Impact">
    Theme: `"Tariffs impact"`

    <img src="https://mintcdn.com/ravenpackinternational/79ansyMCKgAABFQi/images/how-to-guides/search/search-volume/tariffs_impact_volume_evolution_20260115_190153.png?fit=max&auto=format&n=79ansyMCKgAABFQi&q=85&s=58f445c560c42a436d335fabff1ae713" alt="Tariffs Impact Volume Evolution" width="4165" height="2950" data-path="images/how-to-guides/search/search-volume/tariffs_impact_volume_evolution_20260115_190153.png" />
  </Tab>

  <Tab title="Quantum Computing">
    Theme: `"Quantum computing chip"`

    <img src="https://mintcdn.com/ravenpackinternational/79ansyMCKgAABFQi/images/how-to-guides/search/search-volume/quantum_computing_chip_volume_evolution_20260115_190600.png?fit=max&auto=format&n=79ansyMCKgAABFQi&q=85&s=3d3631952e2c54cdf89a745eb61e32cc" alt="Quantum Computing Chip Volume Evolution" width="4164" height="2950" data-path="images/how-to-guides/search/search-volume/quantum_computing_chip_volume_evolution_20260115_190600.png" />
  </Tab>

  <Tab title="Solid State Batteries">
    Theme: `"Solid state batteries"`

    <img src="https://mintcdn.com/ravenpackinternational/79ansyMCKgAABFQi/images/how-to-guides/search/search-volume/solid_state_batteries_volume_evolution_20260115_190519.png?fit=max&auto=format&n=79ansyMCKgAABFQi&q=85&s=bdc5743fbdf1fdc5553a6f969979188a" alt="Solid State Batteries Volume Evolution" width="4164" height="2950" data-path="images/how-to-guides/search/search-volume/solid_state_batteries_volume_evolution_20260115_190519.png" />
  </Tab>

  <Tab title="Greenland">
    Theme: `"Greenland"`

    <img src="https://mintcdn.com/ravenpackinternational/79ansyMCKgAABFQi/images/how-to-guides/search/search-volume/greenland_volume_evolution_20260115_191247.png?fit=max&auto=format&n=79ansyMCKgAABFQi&q=85&s=ee6abcd5788383c515e4b56bda2c8690" alt="Greenland Volume Evolution" width="4164" height="2950" data-path="images/how-to-guides/search/search-volume/greenland_volume_evolution_20260115_191247.png" />
  </Tab>

  <Tab title="Venezuela">
    Theme: `"Venezuela"`

    <img src="https://mintcdn.com/ravenpackinternational/79ansyMCKgAABFQi/images/how-to-guides/search/search-volume/venezuela_volume_evolution_20260115_191144.png?fit=max&auto=format&n=79ansyMCKgAABFQi&q=85&s=1f601b7b7dfbdbaee8bbc683492a2393" alt="Venezuela Volume Evolution" width="4164" height="2950" data-path="images/how-to-guides/search/search-volume/venezuela_volume_evolution_20260115_191144.png" />
  </Tab>
</Tabs>
