Skip to content
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

Add Spice SDK docs #213

Merged
merged 2 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion spiceaidocs/docs/intelligent-applications/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: 'Intelligent Applications'
sidebar_label: 'Intelligent Applications'
sidebar_position: 12
sidebar_position: 13
description: 'Building intelligent data and AI-driven applications with Spice.ai'
pagination_prev: null
pagination_next: null
Expand Down
54 changes: 54 additions & 0 deletions spiceaidocs/docs/sdks/golang/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
title: 'Go SDK'
description: 'Connect to spice using spice go SDK'
pagination_prev: null
pagination_next: null
---

# Golang SDK for Spice.ai

https://github.com/spiceai/gospice

### Install

```shell
go get github.com/spiceai/gospice/v6
```

### Connect to spice runtime

Import the package:

```go
import "github.com/spiceai/gospice/v6"
```

Create a `SpiceClient` using default configuration:

```go
spice := NewSpiceClient()
defer spice.Close()
```

Or pass custom flight address:

```go
if err := spice.Init(
spice.WithFlightAddress("grpc://localhost:50052")
Jeadie marked this conversation as resolved.
Show resolved Hide resolved
); err != nil {
panic(fmt.Errorf("error initializing SpiceClient: %w", err))
}
```

Execute a query and get back an Apache Arrow Reader:

```go
reader, err := spice.Query(
context.Background(),
"SELECT trip_distance, total_amount FROM taxi_trips ORDER BY trip_distance DESC LIMIT 10;"
)
if err != nil {
panic(fmt.Errorf("error querying: %w", err))
}
defer reader.Release()
```
12 changes: 12 additions & 0 deletions spiceaidocs/docs/sdks/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: 'SDKs'
sidebar_label: 'SDKs'
description: 'Connect to spice, using official Spice SDKs'
pagination_prev: null
pagination_next: null
sidebar_position: 12
---

import DocCardList from '@theme/DocCardList';

<DocCardList />
61 changes: 61 additions & 0 deletions spiceaidocs/docs/sdks/javascript/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
title: 'JavaScript SDK'
description: 'Connect to spice using Spice.js SDK'
pagination_prev: null
pagination_next: null
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# JavaScript SDK for Spice.ai

https://github.com/spiceai/spice.js

### Install

<Tabs>
<TabItem value="npm" label="npm" default>
```shell
npm i @spiceai/spice
```
</TabItem>
<TabItem value="yarn" label="yarn">
```shell
yarn add @spiceai/spice
```
</TabItem>
<TabItem value="pnpm" label="pnpm">
```shell
pnpm add @spiceai/spice
```
</TabItem>
</Tabs>

### Connect to spice runtime

Create a `SpiceClient` using default configuration:

```js
import { SpiceClient } from '@spiceai/spice';

const main = async () => {
const spiceClient = new SpiceClient();

const table = await spiceClient.query(
'SELECT trip_distance, total_amount FROM taxi_trips ORDER BY trip_distance DESC LIMIT 10;'
);

console.table(table.toArray());
};

main();
```

Or pass custom flight address:

```js
const spiceClient = new SpiceClient({
flight_url: 'localhost:50052'
});
```
46 changes: 46 additions & 0 deletions spiceaidocs/docs/sdks/python/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
title: 'Python SDK'
description: 'Connect to spice using spice python SDK'
pagination_prev: null
pagination_next: null
---

# Python SDK for Spice.ai

https://github.com/spiceai/spicepy

### Install

```shell
pip install git+https://github.com/spiceai/spicepy@v2.0.0
```

### Connect to spice runtime

```python
from spicepy import Client

client = Client()

data = client.query(
'SELECT trip_distance, total_amount FROM taxi_trips ORDER BY trip_distance DESC LIMIT 10;',
timeout=5*60
)
pd = data.read_pandas()
```

Or pass custom flight address:

```python
from spicepy import Client

client = Client(
flight_url="grpc://localhost:50052"
)

data = client.query(
'SELECT trip_distance, total_amount FROM taxi_trips ORDER BY trip_distance DESC LIMIT 10;',
timeout=5*60
)
pd = data.read_pandas()
```
56 changes: 56 additions & 0 deletions spiceaidocs/docs/sdks/rust/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
title: 'Rust SDK'
description: 'Connect to spice using spice rust SDK'
pagination_prev: null
pagination_next: null
---

# Rust SDK for Spice.ai

https://github.com/spiceai/spice-rs


### Install

```shell
cargo add spiceai
```

### Connect to spice runtime

Create a `SpiceClient` using default configuration:

```rust
use spiceai::ClientBuilder;

#[tokio::main]
async fn main() {
let mut client = ClientBuilder::new()
.build()
.await
.unwrap();

let data = client.query(
"SELECT trip_distance, total_amount FROM taxi_trips ORDER BY trip_distance DESC LIMIT 10;"
).await;
}
```

Or pass custom flight address:

```rust
use spiceai::ClientBuilder;

#[tokio::main]
async fn main() {
let mut client = ClientBuilder::new()
.flight_url("http://localhost:50052")
.build()
.await
.unwrap();

let data = client.query(
"SELECT trip_distance, total_amount FROM taxi_trips ORDER BY trip_distance DESC LIMIT 10;"
).await;
}
```