Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
48 changes: 48 additions & 0 deletions client-sdk/curl-sample/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# cURL Cloud Sample

Use [cURL](https://curl.se/) to run SQL against [Spice.ai Cloud](https://spice.ai) over HTTP.

## Links

- [cURL](https://curl.se/)
- [Spice.ai Cloud](https://spice.ai)
- [Spice.ai Cloud API documentation](https://docs.spiceai.org/api)

## Prerequisites

- [cURL](https://curl.se/)
- A Spice.ai Cloud API key
- A dataset available in your Cloud app

## Quick Start

```bash
git clone https://github.com/spiceai/cookbook.git
cd cookbook/client-sdk/curl-sample
```

Set your cloud values for the commands in this README:

```bash
export SPICE_API_KEY="your_api_key"
export SPICE_DATASET="your_dataset"
```

The script snippet keeps inline placeholders by design. Replace the API key and dataset placeholders in `query_cloud_http.sh`, then run:

```bash
bash query_cloud_http.sh
```

## Manual Query (HTTP)

```bash
curl -X POST https://data.spiceai.io/v1/sql \
-H "Content-Type: application/json" \
-H "X-API-Key: ${SPICE_API_KEY}" \
-d "{\"query\": \"SELECT * FROM ${SPICE_DATASET} LIMIT 10\"}"
```

## Expected Result

You should receive JSON with query results in a `data` array.
8 changes: 8 additions & 0 deletions client-sdk/curl-sample/query_cloud_http.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail

curl -sS -X POST https://data.spiceai.io/v1/sql \
-H "Content-Type: application/json" \
-H "X-API-Key: \"<YOUR_API_KEY>\"" \
-d "{\"query\": \"SELECT * FROM <YOUR_DATASET> LIMIT 10\"}"
echo
59 changes: 44 additions & 15 deletions client-sdk/gospice-sdk-sample/README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
# Spice with gospice SDK

This recipe demonstrates how to use the gospice SDK to connect to a Spice runtime and query data.
Use the [gospice SDK](https://github.com/spiceai/gospice) to query Spice from Go.

Clone this cookbook repo locally and navigate to the `gospice-sdk-sample` directory:
## What This Sample Includes

```shell
git clone https://github.com/spiceai/cookbook.git
cd cookbook/client-sdk/gospice-sdk-sample/
```
- `main.go`: Query a local Spice runtime, including a parameterized query.
- `cloud/main.go`: Query Spice.ai Cloud with inline replacement values.

## Prerequisites

This recipe requires [Go](https://go.dev/) to be installed.
- [Go](https://go.dev/) 1.24+
- [Spice CLI](https://docs.spiceai.org/getting-started) for local mode

## Local Quick Start

```bash
git clone https://github.com/spiceai/cookbook.git
cd cookbook/client-sdk/gospice-sdk-sample
```

## Start spice runtime
Start Spice runtime in one terminal:

```shell
```bash
spice run
```

Output:
Sample runtime logs:

```shell
```text
2024/11/27 16:24:27 INFO Checking for latest Spice runtime release...
2024/11/27 16:24:27 INFO Spice.ai runtime starting...
2024-11-28T00:24:28.411072Z INFO runtime::init::dataset: Initializing dataset taxi_trips
Expand All @@ -35,15 +41,15 @@ Output:
2024-11-28T00:24:37.106088Z INFO runtime::accelerated_table::refresh_task: Loaded 2,964,624 rows (419.31 MiB) for dataset taxi_trips in 7s 856ms.
```

## Run sample application
Run the Go sample in another terminal:

```shell
```bash
go run main.go
```

Results:
Sample output:

```shell
```text
=== Using Sql ===
VendorID: 2, tpep_pickup_datetime: 1706465757000000, fare_amount: 15.6
VendorID: 2, tpep_pickup_datetime: 1706466833000000, fare_amount: 14.2
Expand All @@ -63,3 +69,26 @@ VendorID: 1, tpep_pickup_datetime: 1706250595000000, fare_amount: 20.5
VendorID: 1, tpep_pickup_datetime: 1706250222000000, fare_amount: 10.7
VendorID: 2, tpep_pickup_datetime: 1706249286000000, fare_amount: 70
```

## Spice.ai Cloud Quick Start

Set your API key for the commands in this README:

```bash
export SPICE_API_KEY="your_api_key"
```

The cloud snippet keeps an inline API key placeholder by design. Replace the API key placeholder in `cloud/main.go` with `${SPICE_API_KEY}`, then run:

```bash
go run ./cloud
```

Expected output is a list of tables from `show tables;`.

## Links

- [gospice SDK](https://github.com/spiceai/gospice)
- [Go package](https://pkg.go.dev/github.com/spiceai/gospice/v6)
- [Spice.ai Cloud](https://spice.ai)
- [Spice.ai documentation](https://docs.spiceai.org)
75 changes: 75 additions & 0 deletions client-sdk/spice-cli-sample/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Spice CLI Cloud Sample

Use the [Spice CLI](https://docs.spiceai.org/getting-started) to run SQL against [Spice.ai Cloud](https://spice.ai).

## Links

- [Spice CLI documentation](https://docs.spiceai.org/cli)
- [Spice CLI installation](https://docs.spiceai.org/getting-started)
- [Spice.ai Cloud](https://spice.ai)
- [Spice OSS GitHub](https://github.com/spiceai/spiceai)

## Prerequisites

- [Spice CLI](https://docs.spiceai.org/getting-started)
- A Spice.ai Cloud API key
- A dataset available in your Cloud app

Install Spice CLI if needed:

```bash
curl https://install.spiceai.org | /bin/bash
```

## Quick Start

```bash
git clone https://github.com/spiceai/cookbook.git
cd cookbook/client-sdk/spice-cli-sample
```

Set your cloud values for the commands in this README:

```bash
export SPICE_API_KEY="your_api_key"
export SPICE_DATASET="your_dataset"
```

The script snippets keep inline placeholders by design. Replace the API key and dataset placeholders in the scripts, then run:

```bash
bash query_cloud_default.sh
```

## Additional URL Examples

Run with an explicit gRPC endpoint URL:

```bash
bash query_cloud_grpc.sh
```

Run with an explicit HTTP endpoint URL:

```bash
bash query_cloud_http.sh
```

## Manual Commands

```bash
spice sql \
--cloud \
--api-key "${SPICE_API_KEY}" \
"SELECT * FROM ${SPICE_DATASET} LIMIT 10"

spice sql \
--api-key "${SPICE_API_KEY}" \
--endpoint "grpc+tls://flight.spiceai.io:443" \
"SELECT * FROM ${SPICE_DATASET} LIMIT 10"

spice sql \
--api-key "${SPICE_API_KEY}" \
--endpoint "https://data.spiceai.io" \
"SELECT * FROM ${SPICE_DATASET} LIMIT 10"
```
7 changes: 7 additions & 0 deletions client-sdk/spice-cli-sample/query_cloud_default.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail

spice sql \
--cloud \
--api-key "<YOUR_API_KEY>" \
"SELECT * FROM <YOUR_DATASET> LIMIT 10"
7 changes: 7 additions & 0 deletions client-sdk/spice-cli-sample/query_cloud_grpc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail

spice sql \
--api-key "<YOUR_API_KEY>" \
--endpoint "grpc+tls://flight.spiceai.io:443" \
"SELECT * FROM <YOUR_DATASET> LIMIT 10"
7 changes: 7 additions & 0 deletions client-sdk/spice-cli-sample/query_cloud_http.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail

spice sql \
--api-key "<YOUR_API_KEY>" \
--endpoint "https://data.spiceai.io" \
"SELECT * FROM <YOUR_DATASET> LIMIT 10"
48 changes: 37 additions & 11 deletions client-sdk/spice-dotnet-sdk-sample/README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
# Spice with Dotnet SDK

This recipe shows how to interact with Spice using the [Dotnet SDK](https://github.com/spiceai/spice-dotnet).
Use the [Spice Dotnet SDK](https://github.com/spiceai/spice-dotnet) to query Spice from C#.

## What This Sample Includes

- `Program.cs`: Query a local Spice runtime, including a parameterized query.
- `Cloud.cs`: Query Spice.ai Cloud with inline replacement values.

## Prerequisites

- [Spice](https://github.com/spiceai/spiceai) is installed
- [Dotnet](https://dotnet.microsoft.com/en-us/download)
- [.NET SDK](https://dotnet.microsoft.com/en-us/download) compatible with `net10.0`
- [Spice CLI](https://docs.spiceai.org/getting-started) for local mode

## Clone this sample
## Local Quick Start

```shell
```bash
git clone https://github.com/spiceai/cookbook.git
cd cookbook/client-sdk/spice-dotnet-sdk-sample
```

## Start the Spice runtime
Start Spice runtime in one terminal:

```shell
```bash
spice run
```

```shell
Sample runtime logs:

```text
2025-08-28T21:08:10.674387Z INFO spiced: Starting runtime v1.7.0-unstable-build.246c46c4d-dev+models
2025-08-28T21:08:10.675513Z INFO runtime::init::caching: Initialized results cache; max size: 128.00 MiB, item ttl: 1s
2025-08-28T21:08:10.675671Z INFO runtime::init::caching: Initialized search results cache;
Expand All @@ -34,13 +41,15 @@ spice run
2025-08-28T21:08:20.455383Z INFO runtime: All components are loaded. Spice runtime is ready!
```

## Run the sample
Run the sample in another terminal:

```shell
```bash
dotnet run
```

```shell
Sample output:

```text
=== Using Query ===
VendorID: 2, tpep_pickup_datetime: 2024-01-09 23:22:13, fare_amount: 7.20
VendorID: 1, tpep_pickup_datetime: 2024-01-09 23:40:08, fare_amount: 18.40
Expand All @@ -60,3 +69,20 @@ VendorID: 2, tpep_pickup_datetime: 2024-01-31 09:12:53, fare_amount: 7.90
VendorID: 2, tpep_pickup_datetime: 2024-01-31 09:24:15, fare_amount: 27.50
VendorID: 2, tpep_pickup_datetime: 2024-01-31 09:42:13, fare_amount: 7.90
```

## Spice.ai Cloud Configuration

Set your API key for the commands in this README:

```bash
export SPICE_API_KEY="your_api_key"
```

The cloud snippet keeps an inline API key placeholder by design. Replace the API key placeholder in `Cloud.cs` with `${SPICE_API_KEY}`.

## Links

- [Spice .NET SDK](https://github.com/spiceai/spice-dotnet)
- [NuGet package](https://www.nuget.org/packages/SpiceAI.Client)
- [Spice.ai Cloud](https://spice.ai)
- [Spice.ai documentation](https://docs.spiceai.org)
Loading
Loading