Skip to content

For Laravel and Laravel for Rust

Ship APIs you never have to break.

Date-based versioning, JSON:API, idempotency and HTTP caching for Laravel and Laravel for Rust, with one API format, a typed TypeScript client and an API reference generated from your code.

# GET a customer as this client
curl api.example.com/v1/customers/1 \
  -H "Api-Version: 2026-06-01"

{
  "data": {
    "id": "1",
    "type": "customers",
    "attributes": {
      "name": "Ada Lovelace",
      "email": "ada@example.com"
    }
  }
}

Built before the rename, this client still gets name. Nothing on its side changed.

Everything a public API needs, already built

The parts every serious API ends up writing, done once and tested, in a package you update with Composer or Cargo.

Breaking changes, without breaking clients

Your controllers only ever see the latest shape. Describe each breaking change once, under the date it ships, and older clients' requests and responses are translated on the way in and out.

  • api:version:list shows every version and what changed.
  • Deprecated versions send Deprecation and Sunset headers.
  • api:version:usage tells you who still uses an old version before you retire it.
How versioning works
final class RenameCustomerNameToFullName extends VersionChange
{
    public string $description = 'customer.name renamed to customer.full_name';

    public array $resources = ['customers'];

    public function transformRequest(array $payload, RequestContext $context): array
    {
        return $this->renameAttribute($payload, 'name', 'full_name');
    }

    public function transformResponse(array $document, ResponseContext $context): array
    {
        return $this->renameAttribute($document, 'full_name', 'name');
    }
}

Clients ask for exactly what they need

An ApiQuery lists the includes, fields, filters and sorts an endpoint allows. Clients get precise errors for everything else, so a typo never returns the wrong data.

The queries reference
final class OrderQuery extends ApiQuery
{
    protected array $includes = ['customer'];

    protected array $filters = [
        'status' => ['eq', 'in'],
        'total_cents' => ['gte', 'lte', 'gt', 'lt'],
    ];

    protected array $sorts = ['created_at', 'total_cents'];
}

# GET /v1/orders?filter[total_cents]=5
{ "errors": [{
    "status": "400",
    "code": "invalid_filter",
    "detail": "[total_cents] does not support [eq]. Available: gte, lte, gt, lt.",
    "source": { "parameter": "filter[total_cents]" }
}] }

A typed client, generated from your code

@fusion-stack/client generates TypeScript from your OpenAPI document. Include, filter and sort names are checked at compile time, resources come back flattened, and the client pins the version it was generated from. Any other language can call the same plain HTTP.

Set up a client
import { Client } from '@fusion-stack/client';
import { getV1Orders, version } from './api';

const api = new Client({
  baseUrl: 'https://api.example.com',
  version, // sent as Api-Version on every request
  token: () => auth.token,
});

const { data: orders } = await api.call(getV1Orders, {
  query: (q) => q.include('customer')
    .filter('status', 'in', ['paid', 'shipped'])
    .sort('-total_cents'),
});

orders[0]?.customer?.full_name; // string | undefined

Pick a way in

Released under the MIT License.