Now we are going to talk about the high-level API of Sia.
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!
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:
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.
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:
Sia Compiler
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.
2025-08-20
DevRel Engineer at Timeleap
Pl. de l'Industrie 2, 1180 Rolle, Switzerland