1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# jetstream
the Zig SDK for [Jetstream v2](https://bsky.network/docs/jetstream/): live
subscriptions, filtered archive replay, and replay-to-live cutover. follows
the official Go client's shape, with multi-host live failover. built on
[zat](https://tangled.org/zat.dev/zat) for AT Protocol support.
## install
requires Zig 0.17.0.
```sh
zig fetch --save https://tangled.org/zat.dev/jetstream/archive/v0.1.7.tar.gz
```
add the module to your executable in `build.zig`:
```zig
const jetstream = b.dependency("jetstream", .{}).module("jetstream");
exe.root_module.addImport("jetstream", jetstream);
```
see the [changelog](CHANGELOG.md) for release changes.
## use
subscribe to live posts without an API key:
```zig
const std = @import("std");
const jetstream = @import("jetstream");
const Handler = struct {
pub fn onEvent(_: *@This(), event: jetstream.Event) bool {
std.debug.print("{d} {s}\n", .{ event.seq, event.did });
return true;
}
};
pub fn main(init: std.process.Init) !void {
var handler = Handler{};
try jetstream.subscribe(init.io, init.gpa, .{
.hosts = &.{"https://stream.waow.tech"},
.collections = &.{"app.bsky.feed.post"},
.kinds = &.{.commit},
}, &handler);
}
```
provide multiple hosts for [live failover](docs/failover.md). use
`after_seq` for archive replay, or `live_cursor` to resume within live
retention; the [client contract](docs/client.md) covers cursor scope,
authentication, and error handling. return `false` from `onEvent` to stop.
## develop
```sh
zig build test --summary all
zig build
checks/run ci
```
the loopback checks require Go 1.27, Bash, and jq. they compare the local SDK
with the pinned official Go client and record bounded live/catch-up measurements.
see [verification and release gates](docs/verification.md).
## docs
[docs/](docs/) covers the client contract, failover, and upstream comparisons.
[examples/](examples/) contains bounded consumers and smoke programs.
## license
[MIT](LICENSE)