# Ruby

The Ruby SDK talks to `antd` over REST by default and also includes a gRPC client.

## Install

```bash
gem install antd
```

## Connect to the daemon

```ruby
require "antd"

client = Antd::Client.new(base_url: "http://localhost:8082")
health = client.health
puts health.network
```

## Store and retrieve data

```ruby
require "antd"

client = Antd::Client.new
result = client.data_put_public("Hello, Autonomi!")
puts result.address

data = client.data_get_public(result.address)
puts data
```

## Type mappings

| Autonomi type  | Ruby type                              |
| -------------- | -------------------------------------- |
| `HealthStatus` | model object with `ok` and `network`   |
| `PutResult`    | model object with `cost` and `address` |
| Raw data       | `String`                               |

## Error handling

```ruby
begin
  client.data_get_public("bad-address")
rescue Antd::NotFoundError
  puts "Data not found"
rescue Antd::PaymentError
  puts "Insufficient funds"
rescue Antd::AntdError => e
  puts e.message
end
```

## Full API reference

For all available daemon endpoints, see the [REST API](/developers/sdk/install/reference/rest-api.md).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.autonomi.com/developers/sdk/install/reference/language-bindings/ruby.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
