---
sidebar_position: 3
title: Evidence
description: Build code-based data products with Evidence connected to MotherDuck using SQL and markdown.
---

import BlockWithBacktick from '@site/src/components/BlockWithBacktick';

[Evidence](https://evidence.dev/) is an open source, code-based alternative to drag-and-drop BI tools. Build polished data products with just SQL and markdown.

## Getting started

Head over to [their installation page](https://docs.evidence.dev/getting-started/install-evidence) and start with their template to get you started.

## Authenticate to MotherDuck

When using development, you can go manually through the UI, pick "settings". If you are running Evidence locally, typically at [http://localhost:3000/settings](http://localhost:3000/settings).

![img](../img/evidence_settings.png)

Then select 'DuckDB' as a connection type, and as the filename, use `'md:?motherduck_token=xxxx'` where `xxx` is your [access token](/key-tasks/authenticating-and-connecting-to-motherduck/authenticating-to-motherduck#authentication-using-an-access-token). Finally as extension, select "No extension". Click on `Save`.

![img](../img/evidence_duckdb.png)

In production, you can set [some global environments](https://docs.evidence.dev/deployment/environments#prod-environment), you would have to set two environments variables:

- `EVIDENCE_DUCKDB_FILENAME='md:?motherduck_token=xxxx'`
- `EVIDENCE_DATABASE=duckdb`

## Displaying some data through SQL and Markdown

Once done, you can add a new page in the `pages` folder and add the following code blocks to `stackoverflow.md` file:

First, we simply add some Markdown headers.

```md
---
title: Evidence & MotherDuck 
---

# Stories with most score
```

Then, we query our data from the [HackerNews sample_data database](/getting-started/sample-data-queries/hacker-news.md) in MotherDuck. The query is fetching the top stories (posts) from HackerNews.

<BlockWithBacktick label="new_items">
SELECT id,
  title,
  score,
  "by",
  strftime('%Y-%m-%d', to_timestamp(time)) AS date
FROM sample_data.hn.hacker_news
WHERE type = 'story'
ORDER BY score DESC
LIMIT 20;
</BlockWithBacktick>

Finally, we use the reference of that query result `new_items` to create a list that would be generated in Mardown. The list contains the title (with the url of the story), the date, the score and the author of the story.

```md
{#each new_items as item}

* [{item.title}](https://news.ycombinator.com/item?id={item.id}) {item.date} ⬆ {item.score} by [{item.by}](https://news.ycombinator.com/user?id={item.by}) 

{/each}
```

Head over then to this page you created and you should see the final result that looks like this:

![img](../img/evidence_hackernews.png)


---

## Docs feedback

MotherDuck accepts optional user-submitted feedback about this page at `POST https://motherduck.com/docs/api/feedback/agent`.
For agents and automated tools, feedback submission should be user-confirmed before sending.

Payload:

```json
{
  "page_path": "/integrations/bi-tools/evidence/",
  "page_title": "Evidence",
  "text": "<the user's feedback, max 2000 characters>",
  "source": "<optional identifier for your interface, for example 'claude.ai' or 'chatgpt'>"
}
```

`page_path` and `text` are required; `page_title` and `source` are optional. Responses: `200 {"feedback_id": "<uuid>"}`, `400` for malformed payloads, and `429` when rate-limited.
