# Analytics

Every registered analytics instance operation, with source-derived inputs, outputs, access policy, and errors.

Source: https://docs.minds.sh/docs/api/instance/analytics



This reference covers **9 HTTP operations** registered by the Akasha daemon. Call these paths on your instance base URL. See [authentication](/docs/api/instance/authentication), [errors](/docs/api/instance/errors), and [coverage](/docs/api/instance/coverage) before integrating.

| Method   | Path                            | Operation                                                        |
| -------- | ------------------------------- | ---------------------------------------------------------------- |
| `POST`   | `/v1/analytics/sql`             | [Analytics sql](#post-v1-analytics-sql)                          |
| `POST`   | `/v1/analytics/sources/csv`     | [Analytics register csv](#post-v1-analytics-sources-csv)         |
| `POST`   | `/v1/analytics/sources/parquet` | [Analytics register parquet](#post-v1-analytics-sources-parquet) |
| `POST`   | `/v1/analytics/sources/core`    | [Analytics register core](#post-v1-analytics-sources-core)       |
| `POST`   | `/v1/ingest`                    | [Ingest data](#post-v1-ingest)                                   |
| `GET`    | `/v1/analytics/health`          | [Analytics health](#get-v1-analytics-health)                     |
| `GET`    | `/v1/analytics/views`           | [Analytics views list](#get-v1-analytics-views)                  |
| `POST`   | `/v1/analytics/views`           | [Analytics views create](#post-v1-analytics-views)               |
| `DELETE` | `/v1/analytics/views/:name`     | [Analytics views delete](#delete-v1-analytics-views-name)        |

<a id="post-v1-analytics-sql" />

## POST `/v1/analytics/sql` [#post-v1analyticssql]

Analytics sql

| Availability         | Source contract                            |
| -------------------- | ------------------------------------------ |
| Registration         | `config.enable_analytics`                  |
| Runtime service      | `analytics`                                |
| Handler dependencies | See handler source and return expressions. |

**Access:** Daemon authentication and capability namespace authority; memory-domain permissions apply where mapped.

### Request [#request]

**Json** — `SqlRequest`

| Field | Rust type | Required on input | Notes |
| ----- | --------- | ----------------- | ----- |
| `sql` | `String`  | Yes               |       |

```rust
struct SqlRequest {
    sql: String,
}
```

### Response [#response]

**Declared return:** `Result<impl IntoResponse, DaemonError>`

The following are the exact JSON construction expressions in the handler. Values such as `rows`, `result`, and delegated types are runtime values, not literal example payloads.

```rust
serde_json::json!({"rows": rows})
```

### Errors and validation [#errors-and-validation]

Directly referenced error variants: `InvalidRequest`. Middleware and delegated services can return additional errors described in the shared error reference.

<Accordions>
  <Accordion title="Inspect implementation">
    This exact source excerpt includes validation, defaults, delegated calls, and response assembly.

    ```rust
    async fn analytics_sql(
        State(state): State<AppState>,
        Extension(db): Extension<Arc<AkashaDB>>,
        Json(req): Json<SqlRequest>,
    ) -> Result<impl IntoResponse, DaemonError> {
        state.record_http_request();
        state.usage_emitter.emit_analytics_query();
        let rows = db
            .sql(&req.sql)
            .await
            .map_err(|e| DaemonError::InvalidRequest(e.to_string()))?;
        Ok(Json(serde_json::json!({"rows": rows})))
    }
    ```
  </Accordion>
</Accordions>

Source: `akasha-daemon/src/main.rs:2210`. Registration: `akasha-daemon/src/main.rs:4407`.

<a id="post-v1-analytics-sources-csv" />

## POST `/v1/analytics/sources/csv` [#post-v1analyticssourcescsv]

Analytics register csv

| Availability         | Source contract                            |
| -------------------- | ------------------------------------------ |
| Registration         | `config.enable_analytics`                  |
| Runtime service      | `analytics`                                |
| Handler dependencies | See handler source and return expressions. |

**Access:** Daemon authentication and capability namespace authority; memory-domain permissions apply where mapped.

### Request [#request-1]

**Json** — `AnalyticsSourceCsv`

| Field  | Rust type | Required on input | Notes |
| ------ | --------- | ----------------- | ----- |
| `name` | `String`  | Yes               |       |
| `path` | `String`  | Yes               |       |

```rust
struct AnalyticsSourceCsv {
    name: String,
    path: String,
}
```

### Response [#response-1]

**Declared return:** `Result<impl IntoResponse, DaemonError>`

The following are the exact JSON construction expressions in the handler. Values such as `rows`, `result`, and delegated types are runtime values, not literal example payloads.

```rust
serde_json::json!({"ok": true})
```

### Errors and validation [#errors-and-validation-1]

Directly referenced error variants: `InvalidRequest`. Middleware and delegated services can return additional errors described in the shared error reference.

<Accordions>
  <Accordion title="Inspect implementation">
    This exact source excerpt includes validation, defaults, delegated calls, and response assembly.

    ```rust
    async fn analytics_register_csv(
        State(state): State<AppState>,
        Extension(db): Extension<Arc<AkashaDB>>,
        Json(req): Json<AnalyticsSourceCsv>,
    ) -> Result<impl IntoResponse, DaemonError> {
        state.record_http_request();
        db.analytics_register_csv(&req.name, &req.path)
            .await
            .map_err(|e| DaemonError::InvalidRequest(e.to_string()))?;
        Ok(Json(serde_json::json!({"ok": true})))
    }
    ```
  </Accordion>
</Accordions>

Source: `akasha-daemon/src/main.rs:3850`. Registration: `akasha-daemon/src/main.rs:4408`.

<a id="post-v1-analytics-sources-parquet" />

## POST `/v1/analytics/sources/parquet` [#post-v1analyticssourcesparquet]

Analytics register parquet

| Availability         | Source contract                            |
| -------------------- | ------------------------------------------ |
| Registration         | `config.enable_analytics`                  |
| Runtime service      | `analytics`                                |
| Handler dependencies | See handler source and return expressions. |

**Access:** Daemon authentication and capability namespace authority; memory-domain permissions apply where mapped.

### Request [#request-2]

**Json** — `AnalyticsSourceParquet`

| Field  | Rust type | Required on input | Notes |
| ------ | --------- | ----------------- | ----- |
| `name` | `String`  | Yes               |       |
| `path` | `String`  | Yes               |       |

```rust
struct AnalyticsSourceParquet {
    name: String,
    path: String,
}
```

### Response [#response-2]

**Declared return:** `Result<impl IntoResponse, DaemonError>`

The following are the exact JSON construction expressions in the handler. Values such as `rows`, `result`, and delegated types are runtime values, not literal example payloads.

```rust
serde_json::json!({"ok": true})
```

### Errors and validation [#errors-and-validation-2]

Directly referenced error variants: `InvalidRequest`. Middleware and delegated services can return additional errors described in the shared error reference.

<Accordions>
  <Accordion title="Inspect implementation">
    This exact source excerpt includes validation, defaults, delegated calls, and response assembly.

    ```rust
    async fn analytics_register_parquet(
        State(state): State<AppState>,
        Extension(db): Extension<Arc<AkashaDB>>,
        Json(req): Json<AnalyticsSourceParquet>,
    ) -> Result<impl IntoResponse, DaemonError> {
        state.record_http_request();
        db.analytics_register_parquet(&req.name, &req.path)
            .await
            .map_err(|e| DaemonError::InvalidRequest(e.to_string()))?;
        Ok(Json(serde_json::json!({"ok": true})))
    }
    ```
  </Accordion>
</Accordions>

Source: `akasha-daemon/src/main.rs:3868`. Registration: `akasha-daemon/src/main.rs:4409`.

<a id="post-v1-analytics-sources-core" />

## POST `/v1/analytics/sources/core` [#post-v1analyticssourcescore]

Analytics register core

| Availability         | Source contract                            |
| -------------------- | ------------------------------------------ |
| Registration         | `config.enable_analytics`                  |
| Runtime service      | `analytics`                                |
| Handler dependencies | See handler source and return expressions. |

**Access:** Daemon authentication and capability namespace authority; memory-domain permissions apply where mapped.

### Request [#request-3]

**Json** — `AnalyticsSourceCore`

| Field        | Rust type | Required on input | Notes |
| ------------ | --------- | ----------------- | ----- |
| `name`       | `String`  | Yes               |       |
| `keyspace`   | `String`  | Yes               |       |
| `collection` | `String`  | Yes               |       |

```rust
struct AnalyticsSourceCore {
    name: String,
    keyspace: String,
    collection: String,
}
```

### Response [#response-3]

**Declared return:** `Result<impl IntoResponse, DaemonError>`

The following are the exact JSON construction expressions in the handler. Values such as `rows`, `result`, and delegated types are runtime values, not literal example payloads.

```rust
serde_json::json!({"ok": true})
```

### Errors and validation [#errors-and-validation-3]

Directly referenced error variants: `InvalidRequest`. Middleware and delegated services can return additional errors described in the shared error reference.

<Accordions>
  <Accordion title="Inspect implementation">
    This exact source excerpt includes validation, defaults, delegated calls, and response assembly.

    ```rust
    async fn analytics_register_core(
        State(state): State<AppState>,
        Extension(db): Extension<Arc<AkashaDB>>,
        Json(req): Json<AnalyticsSourceCore>,
    ) -> Result<impl IntoResponse, DaemonError> {
        state.record_http_request();
        db.analytics_register_core_keyspace(&req.name, &req.keyspace, &req.collection)
            .await
            .map_err(|e| DaemonError::InvalidRequest(e.to_string()))?;
        Ok(Json(serde_json::json!({"ok": true})))
    }
    ```
  </Accordion>
</Accordions>

Source: `akasha-daemon/src/main.rs:3887`. Registration: `akasha-daemon/src/main.rs:4413`.

<a id="post-v1-ingest" />

## POST `/v1/ingest` [#post-v1ingest]

Ingest data

| Availability         | Source contract                                                  |
| -------------------- | ---------------------------------------------------------------- |
| Registration         | `config.enable_analytics`                                        |
| Runtime service      | No prefix-level service check; handler dependencies still apply. |
| Handler dependencies | See handler source and return expressions.                       |

**Access:** Daemon authentication and capability namespace authority; memory-domain permissions apply where mapped.

### Request [#request-4]

**Json** — `IngestRequest`

| Field          | Rust type    | Required on input | Notes |
| -------------- | ------------ | ----------------- | ----- |
| `kind`         | `IngestKind` | Yes               |       |
| `content_type` | `String`     | Yes               |       |

```rust
struct IngestRequest {
    kind: IngestKind,
    content_type: String,
}
```

### Response [#response-4]

**Declared return:** `Result<impl IntoResponse, DaemonError>`

The following are the exact JSON construction expressions in the handler. Values such as `rows`, `result`, and delegated types are runtime values, not literal example payloads.

```rust
serde_json::to_value(out).unwrap_or(serde_json::json!({})),
```

### Errors and validation [#errors-and-validation-4]

Directly referenced error variants: `InvalidRequest`. Middleware and delegated services can return additional errors described in the shared error reference.

<Accordions>
  <Accordion title="Inspect implementation">
    This exact source excerpt includes validation, defaults, delegated calls, and response assembly.

    ```rust
    async fn ingest_data(
        State(state): State<AppState>,
        Extension(db): Extension<Arc<AkashaDB>>,
        Json(req): Json<IngestRequest>,
    ) -> Result<impl IntoResponse, DaemonError> {
        state.record_http_request();
        let pk = match req.kind {
            IngestKind::Triples { triples } => akasha::adapters::PayloadKind::Triples(triples),
            IngestKind::Document { document } => akasha::adapters::PayloadKind::Document(document),
            IngestKind::Entities { entities } => akasha::adapters::PayloadKind::Entities(entities),
        };
        let payload = DataPayload::new(pk, &req.content_type);
        let out = db
            .ingestion()
            .ingest(payload)
            .await
            .map_err(|e| DaemonError::InvalidRequest(e.to_string()))?;
        Ok(Json(
            serde_json::to_value(out).unwrap_or(serde_json::json!({})),
        ))
    }
    ```
  </Accordion>
</Accordions>

Source: `akasha-daemon/src/main.rs:2243`. Registration: `akasha-daemon/src/main.rs:4414`.

<a id="get-v1-analytics-health" />

## GET `/v1/analytics/health` [#get-v1analyticshealth]

Analytics health

| Availability         | Source contract                            |
| -------------------- | ------------------------------------------ |
| Registration         | `config.enable_analytics`                  |
| Runtime service      | `analytics`                                |
| Handler dependencies | See handler source and return expressions. |

**Access:** Daemon authentication and capability namespace authority; memory-domain permissions apply where mapped.

### Request [#request-5]

No typed JSON, query, or path extractor is declared in the handler signature. Headers or request objects may still be consumed; the signature below is authoritative.

### Response [#response-5]

**Declared return:** `Result<impl IntoResponse, DaemonError>`

Serialization is delegated or the handler returns a raw response. Consult the exact handler below; the OpenAPI response intentionally remains unconstrained.

### Errors and validation [#errors-and-validation-5]

Directly referenced error variants: none in the handler body. Middleware and delegated services can return additional errors described in the shared error reference.

<Accordions>
  <Accordion title="Inspect implementation">
    This exact source excerpt includes validation, defaults, delegated calls, and response assembly.

    ```rust
    async fn analytics_health(State(state): State<AppState>) -> Result<impl IntoResponse, DaemonError> {
        service_health_payload(&state, "analytics").await
    }
    ```
  </Accordion>
</Accordions>

Source: `akasha-daemon/src/main.rs:10281`. Registration: `akasha-daemon/src/main.rs:4415`.

<a id="get-v1-analytics-views" />

## GET `/v1/analytics/views` [#get-v1analyticsviews]

Analytics views list

| Availability         | Source contract                            |
| -------------------- | ------------------------------------------ |
| Registration         | `config.enable_analytics`                  |
| Runtime service      | `analytics`                                |
| Handler dependencies | See handler source and return expressions. |

**Access:** Daemon authentication and capability namespace authority; memory-domain permissions apply where mapped.

### Request [#request-6]

No typed JSON, query, or path extractor is declared in the handler signature. Headers or request objects may still be consumed; the signature below is authoritative.

### Response [#response-6]

**Declared return:** `Result<impl IntoResponse, DaemonError>`

The following are the exact JSON construction expressions in the handler. Values such as `rows`, `result`, and delegated types are runtime values, not literal example payloads.

```rust
serde_json::json!({"views": entries, "total": entries.len()}),
```

### Errors and validation [#errors-and-validation-6]

Directly referenced error variants: none in the handler body. Middleware and delegated services can return additional errors described in the shared error reference.

<Accordions>
  <Accordion title="Inspect implementation">
    This exact source excerpt includes validation, defaults, delegated calls, and response assembly.

    ```rust
    async fn analytics_views_list(
        State(state): State<AppState>,
    ) -> Result<impl IntoResponse, DaemonError> {
        state.record_http_request();
        let views = state.analytics_views.read().await;
        let entries: Vec<serde_json::Value> = views
            .iter()
            .map(|(name, query)| serde_json::json!({"name": name, "query": query}))
            .collect();
        Ok(Json(
            serde_json::json!({"views": entries, "total": entries.len()}),
        ))
    }
    ```
  </Accordion>
</Accordions>

Source: `akasha-daemon/src/main.rs:11255`. Registration: `akasha-daemon/src/main.rs:4416`.

<a id="post-v1-analytics-views" />

## POST `/v1/analytics/views` [#post-v1analyticsviews]

Analytics views create

| Availability         | Source contract                            |
| -------------------- | ------------------------------------------ |
| Registration         | `config.enable_analytics`                  |
| Runtime service      | `analytics`                                |
| Handler dependencies | See handler source and return expressions. |

**Access:** Daemon authentication and capability namespace authority; memory-domain permissions apply where mapped.

### Request [#request-7]

**Json** — `AnalyticsViewCreateReq`

| Field   | Rust type | Required on input | Notes |
| ------- | --------- | ----------------- | ----- |
| `name`  | `String`  | Yes               |       |
| `query` | `String`  | Yes               |       |

```rust
struct AnalyticsViewCreateReq {
    name: String,
    query: String,
}
```

### Response [#response-7]

**Declared return:** `Result<impl IntoResponse, DaemonError>`

The following are the exact JSON construction expressions in the handler. Values such as `rows`, `result`, and delegated types are runtime values, not literal example payloads.

```rust
serde_json::json!({"ok": true, "name": req.name})
```

### Errors and validation [#errors-and-validation-7]

Directly referenced error variants: none in the handler body. Middleware and delegated services can return additional errors described in the shared error reference.

<Accordions>
  <Accordion title="Inspect implementation">
    This exact source excerpt includes validation, defaults, delegated calls, and response assembly.

    ```rust
    async fn analytics_views_create(
        State(state): State<AppState>,
        Json(req): Json<AnalyticsViewCreateReq>,
    ) -> Result<impl IntoResponse, DaemonError> {
        state.record_http_request();
        let mut views = state.analytics_views.write().await;
        views.insert(req.name.clone(), req.query);
        Ok(Json(serde_json::json!({"ok": true, "name": req.name})))
    }
    ```
  </Accordion>
</Accordions>

Source: `akasha-daemon/src/main.rs:11275`. Registration: `akasha-daemon/src/main.rs:4416`.

<a id="delete-v1-analytics-views-name" />

## DELETE `/v1/analytics/views/:name` [#delete-v1analyticsviewsname]

Analytics views delete

| Availability         | Source contract                            |
| -------------------- | ------------------------------------------ |
| Registration         | `config.enable_analytics`                  |
| Runtime service      | `analytics`                                |
| Handler dependencies | See handler source and return expressions. |

**Access:** Daemon authentication and capability namespace authority; memory-domain permissions apply where mapped.

### Request [#request-8]

**Path** — `String`

```json
{
  "type": "string"
}
```

### Response [#response-8]

**Declared return:** `Result<impl IntoResponse, DaemonError>`

The following are the exact JSON construction expressions in the handler. Values such as `rows`, `result`, and delegated types are runtime values, not literal example payloads.

```rust
serde_json::json!({"ok": true, "removed": name})
```

### Errors and validation [#errors-and-validation-8]

Directly referenced error variants: `InvalidRequest`. Middleware and delegated services can return additional errors described in the shared error reference.

<Accordions>
  <Accordion title="Inspect implementation">
    This exact source excerpt includes validation, defaults, delegated calls, and response assembly.

    ```rust
    async fn analytics_views_delete(
        State(state): State<AppState>,
        Path(name): Path<String>,
    ) -> Result<impl IntoResponse, DaemonError> {
        state.record_http_request();
        let mut views = state.analytics_views.write().await;
        let existed = views.remove(&name).is_some();
        if !existed {
            return Err(DaemonError::InvalidRequest(format!(
                "view '{}' not found",
                name
            )));
        }
        Ok(Json(serde_json::json!({"ok": true, "removed": name})))
    }
    ```
  </Accordion>
</Accordions>

Source: `akasha-daemon/src/main.rs:11285`. Registration: `akasha-daemon/src/main.rs:4420`.
