Skip to main content

README.md

[![Hex](https://img.shields.io/hexpm/v/skir_client)](https://hex.pm/packages/skir_client)
[![build](https://github.com/gepheum/skir/workflows/Build/badge.svg)](https://github.com/gepheum/skir/actions)

# skir_client

`skir_client` is the runtime library for Gleam code generated by [Skir](https://skir.build/).

## What is Skir?

Skir is a declarative language for defining data types, constants, and APIs. Write your schema once in a `.skir` file and generate idiomatic, type-safe code in 12+ languages including Gleam, Python, Rust, Go, and more.

### Key features

- **Code generation from schema**: Define types once in a `.skir` file, generate idiomatic Gleam code automatically
- **Multiple serialization formats**: Serialize to dense JSON, readable JSON, or binary format
- **Type-safe RPC**: SkirRPC enables type-safe cross-service communication over HTTP
- **Immutable by default**: Generated types are deeply immutable with all fields required at construction
- **Schema evolution**: Evolve your schema safely without breaking existing clients
- **12+ language support**: Same schema generates code for TypeScript, Python, Java, C#, C++, Go, Kotlin, Dart, Swift, Rust, Zig, and Gleam

## Installation

```sh
gleam add skir_client
```

## Quick example

```gleam
import skir_client
import skirout/user
import gleam/io

// Construct a User
let john = user.user_new(
  user_id: 42,
  name: "John Doe",
  quote: "Coffee is just a socially acceptable form of rage.",
  pets: [user.user__pet_new(1.0, "Dumbo", "🐘")],
  subscription_status: user.SubscriptionStatusFree,
)

// Serialize to JSON
let serializer = user.user_serializer()
let john_json = skir_client.to_readable_json_code(serializer, john)
io.println(john_json)

// Deserialize from JSON
let assert Ok(restored) = skir_client.from_json_code(serializer, john_json)
```

## Learn more

- [Skir website](https://skir.build/)
- [Gleam code generation guide](https://skir.build/docs/gleam)
- [Example Gleam project](https://github.com/gepheum/skir-gleam-example)
- [Skir language reference](https://skir.build/docs/language-reference)
- [Serialization formats](https://skir.build/docs/serialization)