# AddressZen Ruby SDK

[`addresszen`](https://rubygems.org/gems/addresszen) calls the AddressZen API from Ruby 3.3 or later, with one method per operation and no runtime dependencies.

```bash
gem install addresszen
```

verify.rbruby

```ruby
require "addresszen"

client = AddressZen::Client.new(api_key: "ak_test")
result = client.address_verify(query: "1010 Cauthen Ln, Alamogordo, NM 88310").result

if result.is_a?(AddressZen::Types::UsaVerifyMatch)
  puts "#{result.address_line_one}, #{result.city}, #{result.state} #{result.zip_code}"
end
```

Each API operation is one method on the client, named from its operation ID, such as `address_verify` or `find_address`. Path parameters are positional and everything else is a keyword argument. Every method returns an object built from the API response.

## Features

Every operation in the API has a method. The ones most integrations need have a guide:

* [Address verification](/docs/sdks/ruby/address-verify.md): correct and standardize a US address against USPS data
* [Autocomplete](/docs/sdks/ruby/autocomplete.md): suggest addresses as the user types, in the US and other countries
* [Email validation](/docs/sdks/ruby/email-validation.md): check that an address can receive mail
* [Phone validation](/docs/sdks/ruby/phone-validation.md): check a number from any country and format it
* [API keys](/docs/sdks/ruby/keys.md) and [licensees](/docs/sdks/ruby/licensees.md): balances, limits, usage and sub-licensing

Place search and saved configs are on the [endpoint pages](/docs/sdks/ruby/endpoints.md), one per method.

## Why the SDK

* **No dependencies.** The SDK sends requests with Net::HTTP and parses them with the standard library's JSON. To use another HTTP client, pass your own [transport](/docs/sdks/ruby/setup.md#custom-transport).
* **Generated from the OpenAPI spec.** Every response is an object with one reader per field. Every dataset's native record has its own class, such as `PafAddress`.
* **RBS signatures.** The gem ships a signature for every method and reader, for Steep, Ruby LSP and other tools that read RBS.
* **No hidden retries.** A billable lookup repeats only when your code repeats it.

## Coding agents

* **Agent skill.** `npx skills add addresszen/skills` installs the `azn-ruby-sdk` skill, built from these pages.
* **[Endpoints](/docs/sdks/ruby/endpoints.md).** Every operation, grouped by API area, with its parameters, response class and a tested example.
* **Markdown pages.** Add `.md` to any page URL for plain markdown, such as [`/docs/sdks/ruby/errors.md`](/docs/sdks/ruby/errors.md).
* **[llms.txt](https://docs.addresszen.com/llms.txt).** An index of every page on this site.
* **[OpenAPI spec](https://openapi.addresszen.com/openapi.json).** The API contract the SDK is generated from.

## Authenticate

Pass your API key to `AddressZen::Client.new` as `api_key:`. Key, licensee and configuration operations also need a Management Key, passed as `management_key:`. Keep the Management Key on your server. See [setup](/docs/sdks/ruby/setup.md).

## Errors

An HTTP error raises `AddressZen::ApiError` with the HTTP status and the API error code and message. A failed connection raises `AddressZen::TransportError`. Both inherit from `AddressZen::Error`, so one `rescue` covers the SDK. See [error handling](/docs/sdks/ruby/errors.md).
