---
title: "API resource — Addresses for Laravel | Roundly"
description: "AddressResource renders an address for JSON APIs with a stable shape — lines, country, primary flag, formatted label and meta."
url: https://roundly-consulting.com/open-source/docs/addresses-for-laravel/api-resource
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Addresses for Laravel](https://roundly-consulting.com/open-source/docs/addresses-for-laravel.md)

# API resource

RoundlyConsulting\\Addresses\\Http\\Resources\\AddressResource is a JsonResource with an explicit, stable shape:

```php
use App\Models\Customer;
use Illuminate\Support\Facades\Route;
use RoundlyConsulting\Addresses\Address;
use RoundlyConsulting\Addresses\Http\Resources\AddressResource;

Route::get('/customers/{customer}/addresses', function (Customer $customer) {
    return AddressResource::collection($customer->addresses);
});

Route::get('/addresses/{address}', function (Address $address) {
    return AddressResource::make($address);
});
```

| Key | Value |
| --- | --- |
| `id` | The address id. |
| `type` | The type’s string value, e.g. billing. |
| `name, city, street, postal_code` | The stored lines. |
| `country_iso` | The stored ISO code. |
| `country_name` | The resolved name, or null without a CountryResolver. |
| `is_primary` | Boolean primary flag. |
| `formatted` | The one-line label from formatted(). |
| `meta` | The meta collection, or null. |
| `created_at, updated_at` | Timestamps. |

country\_name reflects the bound CountryResolver (null without one) and formatted is the label from formatted(). The resource is final — for a different shape, write your own JsonResource over the Address model.

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/addresses-for-laravel.md)
