Skip to content

docs(api): adding api examples to DVC and LVC #6277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
67c2d19
docs(api): adding api examples to DVC and LVC
MeelahMe Jul 31, 2025
8a74c7d
Update content/shared/influxdb3-admin/distinct-value-cache/show.md
MeelahMe Jul 31, 2025
d2904df
Update content/shared/influxdb3-admin/distinct-value-cache/show.md
MeelahMe Jul 31, 2025
faa973a
Update content/shared/influxdb3-admin/last-value-cache/delete.md
MeelahMe Jul 31, 2025
5419f10
fix(docs): close code-placeholders shortcode in LVC delete guide
MeelahMe Jul 31, 2025
7140e46
Update content/shared/influxdb3-admin/distinct-value-cache/query.md
MeelahMe Aug 1, 2025
0e58bb8
Update content/shared/influxdb3-admin/distinct-value-cache/query.md
MeelahMe Aug 1, 2025
f39af3f
Update content/shared/influxdb3-admin/distinct-value-cache/show.md
MeelahMe Aug 1, 2025
0f5056e
Update content/shared/influxdb3-admin/last-value-cache/create.md
MeelahMe Aug 1, 2025
99715ce
Update content/shared/influxdb3-admin/last-value-cache/show.md
MeelahMe Aug 1, 2025
9c9f2c6
Update content/shared/influxdb3-admin/last-value-cache/show.md
MeelahMe Aug 1, 2025
c281a6e
Update content/shared/influxdb3-admin/distinct-value-cache/create.md
MeelahMe Aug 1, 2025
a4023ba
Update content/shared/influxdb3-admin/distinct-value-cache/show.md
MeelahMe Aug 1, 2025
aad8d89
Update content/shared/influxdb3-admin/distinct-value-cache/query.md
MeelahMe Aug 1, 2025
866ee9b
Update content/shared/influxdb3-admin/distinct-value-cache/create.md
MeelahMe Aug 1, 2025
0384cad
Update content/shared/influxdb3-admin/distinct-value-cache/query.md
MeelahMe Aug 1, 2025
057de12
Update content/shared/influxdb3-admin/distinct-value-cache/show.md
MeelahMe Aug 1, 2025
419fda9
Update content/shared/influxdb3-admin/last-value-cache/create.md
MeelahMe Aug 1, 2025
a5c19e6
Update content/shared/influxdb3-admin/last-value-cache/create.md
MeelahMe Aug 1, 2025
5ea8749
Update content/shared/influxdb3-admin/last-value-cache/delete.md
MeelahMe Aug 1, 2025
5e465a4
Update content/shared/influxdb3-admin/last-value-cache/delete.md
MeelahMe Aug 1, 2025
61fe70a
Update content/shared/influxdb3-admin/last-value-cache/delete.md
MeelahMe Aug 1, 2025
0f46f10
Update content/shared/influxdb3-admin/last-value-cache/show.md
MeelahMe Aug 1, 2025
63d0025
Merge branch 'master' into feature/pr-5974-add-api-examples-to-cache-…
MeelahMe Aug 1, 2025
13087e4
Update content/shared/influxdb3-admin/distinct-value-cache/create.md
MeelahMe Aug 1, 2025
ba62dde
Merge branch 'master' into feature/pr-5974-add-api-examples-to-cache-…
MeelahMe Aug 1, 2025
50b0fc0
Merge branch 'master' into feature/pr-5974-add-api-examples-to-cache-…
MeelahMe Aug 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions content/shared/influxdb3-admin/distinct-value-cache/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,59 @@ influxdb3 create distinct_cache \
<!--------------------------- END ENTERPRISE EXAMPLE -------------------------->
{{% /show-in %}}

## Use the HTTP API

To use the HTTP API to create a Distinct Value Cache, send a `POST` request to the `/api/v3/configure/distinct_cache` endpoint.

{{% api-endpoint method="POST" endpoint="/api/v3/configure/distinct_cache" api-ref="/influxdb3/version/api/v3/#operation/PostConfigureDistinctCache" %}}

{{% code-placeholders "(DATABASE|TABLE|DVC)_NAME|AUTH_TOKEN|COLUMNS|MAX_(CARDINALITY|AGE)" %}}

```bash
curl -X POST "https://localhost:8181/api/v3/configure/distinct_cache" \
--header "Authorization: Bearer AUTH_TOKEN" \
--json '{
"db": "DATABASE_NAME",
"table": "TABLE_NAME",
"name": "DVC_NAME",
"columns": ["COLUMNS"],
"max_cardinality": MAX_CARDINALITY,
"max_age": MAX_AGE
}'
```

{{% /code-placeholders %}}

### Example

```bash
curl -X POST "https://localhost:8181/api/v3/configure/distinct_cache" \
--header "Authorization: Bearer 00xoXX0xXXx0000XxxxXx0Xx0xx0" \
--json '{
"db": "example-db",
"table": "wind_data",
"name": "windDistinctCache",
"columns": ["country", "county", "city"],
"max_cardinality": 10000,
"max_age": 86400
}'
```

**Response codes:**

- `201` : Success. The distinct cache has been created.
- `204` : Not created. A distinct cache with this configuration already exists.
- `400` : Bad request.


> [!Note]
> #### API parameter differences
>
> - **Columns format**: The API uses a JSON array (`["country", "county", "city"]`)
> instead of the CLI's comma-delimited format (`country,county,city`).
> - **Maximum age format**: The API uses seconds (`86400`) instead of the CLI's
> [humantime format](https://docs.rs/humantime/latest/humantime/fn.parse_duration.html) (`24h`, `1 day`).

Replace the following:

- {{% code-placeholder-key %}}`DATABASE_NAME`{{% /code-placeholder-key %}}:
Expand Down
34 changes: 34 additions & 0 deletions content/shared/influxdb3-admin/distinct-value-cache/query.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,37 @@ FROM
WHERE
country = 'Spain'
```

## Use the HTTP API

To use the HTTP API to query cached data, send a `GET` or `POST` request to the `/api/v3/query_sql` endpoint and include the [`distinct_cache()`](/influxdb3/version/reference/sql/functions/cache/#distinct_cache) function in your query.

{{% api-endpoint method="GET" endpoint="/api/v3/query_sql" api-ref="/influxdb3/version/api/v3/#operation/GetExecuteQuerySQL" %}}

{{% api-endpoint method="POST" endpoint="/api/v3/query_sql" api-ref="/influxdb3/version/api/v3/#operation/PostExecuteQuerySQL" %}}

{{% code-placeholders "DATABASE_NAME|AUTH_TOKEN|TABLE_NAME|CACHE_NAME" %}}

```bash
curl -X POST "https://localhost:8181/api/v3/query_sql" \
--header "Authorization: Bearer AUTH_TOKEN" \
--json '{
"db": "DATABASE_NAME",
"q": "SELECT * FROM distinct_cache('\''TABLE_NAME'\'', '\''CACHE_NAME'\'')",
"format": "json"
}'
```

{{% /code-placeholders %}}

## Example with WHERE clause

```bash
curl -X POST "https://localhost:8181/api/v3/query_sql" \
--header "Authorization: Bearer 00xoXX0xXXx0000XxxxXx0Xx0xx0" \
--json '{
"db": "example-db",
"q": "SELECT room, temp FROM last_cache('\''home'\'', '\''homeCache'\'') WHERE room = '\''Kitchen'\''",
"format": "json"
}'
```
41 changes: 41 additions & 0 deletions content/shared/influxdb3-admin/distinct-value-cache/show.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,44 @@ In the examples above, replace the following:
- {{% code-placeholder-key %}}`AUTH_TOKEN`{{% /code-placeholder-key %}}:
your {{< product-name >}} {{% show-in "enterprise" %}}admin {{% /show-in %}}
authentication token

## Use the HTTP API

To use the HTTP API to query and output cache information from the system table, send a `GET` or `POST` request to the `/api/v3/query_sql` endpoint.

{{% api-endpoint method="GET" endpoint="/api/v3/query_sql" api-ref="/influxdb3/version/api/v3/#operation/GetExecuteQuerySQL" %}}

{{% api-endpoint method="POST" endpoint="/api/v3/query_sql" api-ref="/influxdb3/version/api/v3/#operation/PostExecuteQuerySQL" %}}

### Query all caches

{{% code-placeholders "DATABASE_NAME|AUTH_TOKEN" %}}

```bash
curl -X POST "https://localhost:8181/api/v3/query_sql" \
--header "Authorization: Bearer AUTH_TOKEN" \
--json '{
"db": "DATABASE_NAME",
"q": "SELECT * FROM system.distinct_caches",
"format": "json"
}'
```

{{% /code-placeholders %}}

## Query specific cache details

{{% code-placeholders "DATABASE_NAME|AUTH_TOKEN|CACHE_NAME" %}}

```bash
curl -X POST "https://localhost:8181/api/v3/query_sql" \
--header "Authorization: Bearer AUTH_TOKEN" \
--json '{
"db": "DATABASE_NAME",
"q": "SELECT * FROM system.distinct_caches WHERE name = '\''CACHE_NAME'\''",
"format": "json"
}'
```

{{% /code-placeholders %}}

55 changes: 54 additions & 1 deletion content/shared/influxdb3-admin/last-value-cache/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,59 @@ influxdb3 create last_cache \
<!--------------------------- END ENTERPRISE EXAMPLE -------------------------->
{{% /show-in %}}

## Use the HTTP API

To use the HTTP API to create a Last Value Cache, send a `POST` request to the `/api/v3/configure/last_cache` endpoint.

{{% api-endpoint method="POST" endpoint="/api/v3/configure/last_cache" api-ref="/influxdb3/version/api/v3/#operation/PostConfigureLastCache" %}}

{{% code-placeholders "(DATABASE|TABLE|LVC)_NAME|AUTH_TOKEN|(KEY|VALUE)_COLUMNS|COUNT|TTL" %}}

```bash
curl -X POST "https://localhost:8181/api/v3/configure/last_cache" \
--header "Authorization: Bearer AUTH_TOKEN" \
--json '{
"db": "DATABASE_NAME",
"table": "TABLE_NAME",
"name": "LVC_NAME",
"key_columns": ["KEY_COLUMNS"],
"value_columns": ["VALUE_COLUMNS"],
"count": COUNT,
"ttl": TTL
}'
```

{{% /code-placeholders %}}

### Example

```bash
curl -X POST "https://localhost:8181/api/v3/configure/last_cache" \
--header "Authorization: Bearer 00xoXX0xXXx0000XxxxXx0Xx0xx0" \
--json '{
"db": "example-db",
"table": "home",
"name": "homeLastCache",
"key_columns": ["room", "wall"],
"value_columns": ["temp", "hum", "co"],
"count": 5,
"ttl": 14400
}'
```

**Response codes:**

- `201` : Success. Last cache created.
- `400` : Bad request.
- `401` : Unauthorized.
- `404` : Cache not found.
- `409` : Cache already exists.

> [!Note]
> #### API parameter differences
> Column format: The API uses JSON arrays (["room", "wall"]) instead of the CLI's comma-delimited format (room,wall).
> TTL format: The API uses seconds (14400) instead of the CLI's humantime format (4h, 4 hours).

Replace the following:

- {{% code-placeholder-key %}}`DATABASE_NAME`{{% /code-placeholder-key %}}:
Expand Down Expand Up @@ -116,4 +169,4 @@ The cache imports the distinct values from the table and starts caching them.
>
> The LVC is stored in memory, so it's important to consider the size and persistence
> of the cache. For more information, see
> [Important things to know about the Last Value Cache](/influxdb3/version/admin/last-value-cache/#important-things-to-know-about-the-last-value-cache).
> [Important things to know about the Last Value Cache.](/influxdb3/version/admin/last-value-cache/#important-things-to-know-about-the-last-value-cache)
27 changes: 27 additions & 0 deletions content/shared/influxdb3-admin/last-value-cache/delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,33 @@ influxdb3 delete last_cache \
```
{{% /code-placeholders %}}

## Use the HTTP API

To use the HTTP API to delete a Last Value Cache, send a `DELETE` request to the `/api/v3/configure/last_cache` endpoint with query parameters.

{{% api-endpoint method="DELETE" endpoint="/api/v3/configure/last_cache" api-ref="/influxdb3/core/api/v3/#operation/DeleteConfigureLastCache" %}}

{{% code-placeholders "(DATABASE|TABLE|LVC)_NAME|AUTH_TOKEN" %}}
```bash
curl -X DELETE "https://localhost:8181/api/v3/configure/last_cache?db=DATABASE_NAME&table=TABLE_NAME&name=LVC_NAME" \
--header "Authorization: Bearer AUTH_TOKEN"
```
{{% /code-placeholders %}}

## Example

```bash
curl -X DELETE "https://localhost:8181/api/v3/configure/last_cache?db=example-db&table=home&name=homeLastCache" \
--header "Authorization: Bearer 00xoXX0xXXx0000XxxxXx0Xx0xx0"
```

**Response codes:**

- `200` : Success. The last cache has been deleted.
- `400` : Bad request.
- `401` : Unauthorized.
- `404` : Cache not found.

Replace the following:

- {{% code-placeholder-key %}}`DATABASE_NAME`{{% /code-placeholder-key %}}:
Expand Down
40 changes: 40 additions & 0 deletions content/shared/influxdb3-admin/last-value-cache/show.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,43 @@ In the examples above, replace the following:
- {{% code-placeholder-key %}}`AUTH_TOKEN`{{% /code-placeholder-key %}}:
your {{< product-name >}} {{% show-in "enterprise" %}}admin {{% /show-in %}}
authentication token

## Use the HTTP API

To use the HTTP API to query and output cache information from the system table, send a `GET` or `POST` request to the `/api/v3/query_sql` endpoint.

{{% api-endpoint method="GET" endpoint="/api/v3/query_sql" api-ref="/influxdb3/version/api/v3/#operation/GetExecuteQuerySQL" %}}

{{% api-endpoint method="POST" endpoint="/api/v3/query_sql" api-ref="/influxdb3/version/api/v3/#operation/PostExecuteQuerySQL" %}}

### Query all last value caches

{{% code-placeholders "DATABASE_NAME|AUTH_TOKEN" %}}

```bash
curl -X POST "https://localhost:8181/api/v3/query_sql" \
--header "Authorization: Bearer AUTH_TOKEN" \
--json '{
"db": "DATABASE_NAME",
"q": "SELECT * FROM system.last_caches",
"format": "json"
}'
```

{{% /code-placeholders %}}

## Query specific cache details

{{% code-placeholders "DATABASE_NAME|AUTH_TOKEN|CACHE_NAME" %}}

```bash
curl -X POST "https://localhost:8181/api/v3/query_sql" \
--header "Authorization: Bearer AUTH_TOKEN" \
--json '{
"db": "DATABASE_NAME",
"q": "SELECT * FROM system.last_caches WHERE name = '\''CACHE_NAME'\''",
"format": "json"
}'
```

{{% /code-placeholders %}}