To the next level: A Developer's Guide to Sia Schema

Now we are going to talk about the high-level API of Sia.

Sonic saying welcome to the next level

Sia the "Sonic", get it?

We know from a previous article about the low-level API of Sia that in order to serialize and deserialize your data, you have to add your fields by their type and length, and deserialize them in the same order.

While that was simple, the high-level API is even better!

Sia Compiler

If you've ever used tools like , or this concept will feel familiar. These tools let you define your data in a single schema file, and in return, they generate all the necessary code for you. The Sia compiler does the same thing for serialization.

Sia compiler requires a schema file with file extension and uses the package.

Install:

Or you can use :

Add the flag to see the available options.

For example, let's look at a schema like this:

By using this command:

You get a TypeScript output with multiple things generated for you:

  • A Person interface
  • A method to serialize the
  • A method to deserialize the

It even works with custom types, for example:

The compiler adds this to the previous code:

So you see how much simpler things get. You define all your data types that will be serialized by Sia in a schema, and the code generator creates everything you need. This allows you to focus on the rest of your app. Additionally, since the code is generated, you can modify it if you want.

One Schema, Many Languages

The library supports code generation for , , , and obviously . This has a great benefit other than supporting your favorite language. It helps distributed app and microservice developers. For example, you may have an AI service in Python and your backend is written in Golang. You can use the Sia compiler to generate your Sia serialization/deserialization methods in both languages, and they can communicate with each other.

The only blueprint needed is the schema:

A simple diagram representing how Sia compiler works

Sia Compiler

Conclusion

The Sia schema package saves you time by generating code based on your schema. This not only makes it easy to manage multiple data objects in a project but also provides a structured way to work with Sia's flat binary format. You can think of the schema as a blueprint that makes Sia's speed accessible and developer-friendly.

Hamed

Hamed

2025-08-20

DevRel Engineer at Timeleap

How was this page?

Timeleap SA.

Pl. de l'Industrie 2, 1180 Rolle, Switzerland

Logo

Social Media

Tokenomics

Info