tangled
alpha
login
or
join now
mackuba.eu
/
ratproto
2
fork
atom
Ruby CLI tool for accessing Bluesky API / ATProto
2
fork
atom
overview
issues
pulls
pipelines
added readme
mackuba.eu
2 months ago
dbc99c4f
5129a3a7
+130
-17
1 changed file
expand all
collapse all
unified
split
README.md
+130
-17
README.md
···
1
1
-
# Ratproto
1
1
+
# RatProto – Ruby ATProto Tool 🐀
2
2
+
3
3
+
`rat` is a small command-line tool for working with the **Bluesky AT Protocol** from Ruby.
4
4
+
5
5
+
It builds on top of the existing ATProto Ruby gems:
6
6
+
7
7
+
- [`minisky`](https://ruby.sdk.blue/minisky/) — XRPC client for PDS/AppView
8
8
+
- [`skyfall`](https://ruby.sdk.blue/skyfall/) — firehose & Jetstream streaming
9
9
+
- [`didkit`](https://ruby.sdk.blue/didkit/) — DID & handle resolution
10
10
+
11
11
+
You can use `rat` to:
12
12
+
13
13
+
- fetch AT Protocol records
14
14
+
- stream firehose / Jetstream commits with optional filters
15
15
+
- resolve DIDs & handles
16
16
+
2
17
3
3
-
TODO: Delete this and the text below, and describe your gem
18
18
+
> [!CAUTION]
19
19
+
> Here be dragons - currently 100% vibe-coded using ChatGPT. Seems to be working correctly. Will be rewritten manually in the next version :)
4
20
5
5
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ratproto`. To experiment with that code, run `bin/console` for an interactive prompt.
6
21
7
22
## Installation
8
23
9
9
-
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
24
24
+
```
25
25
+
gem install ratproto
26
26
+
```
27
27
+
28
28
+
29
29
+
## Usage
30
30
+
31
31
+
```
32
32
+
rat fetch at://<did>/<collection>/<rkey>
33
33
+
rat stream <relay.host> [options]
34
34
+
rat resolve <did-or-handle>
35
35
+
```
36
36
+
37
37
+
38
38
+
### Fetching a record
39
39
+
40
40
+
Use an at:// URI to fetch a record directly from the user’s PDS:
41
41
+
42
42
+
```
43
43
+
rat fetch at://did:plc:abcd1234/app.bsky.feed.post/3kz4vx5j
44
44
+
```
45
45
+
46
46
+
Example output:
47
47
+
48
48
+
```
49
49
+
{
50
50
+
"$type": "app.bsky.feed.post",
51
51
+
"text": "hello world 👋",
52
52
+
"createdAt": "2025-01-01T12:34:56.789Z"
53
53
+
}
54
54
+
```
55
55
+
56
56
+
### Resolving a DID or handle
57
57
+
58
58
+
You can resolve either a DID:
59
59
+
60
60
+
```
61
61
+
rat resolve did:plc:abcd1234
62
62
+
```
63
63
+
64
64
+
or a handle:
65
65
+
66
66
+
```
67
67
+
rat resolve @example.com
68
68
+
```
69
69
+
70
70
+
Example output:
71
71
+
72
72
+
```
73
73
+
did:plc:abcd1234
74
74
+
{
75
75
+
"@context": "...",
76
76
+
"id": "did:plc:abcd1234",
77
77
+
...
78
78
+
}
79
79
+
```
80
80
+
81
81
+
### Streaming commit events
82
82
+
83
83
+
Rat can connect to either a relay/PDS firehose, or a Jetstream JSON stream:
84
84
+
85
85
+
```
86
86
+
rat stream bsky.network
87
87
+
```
88
88
+
89
89
+
You’ll see output like:
90
90
+
91
91
+
```
92
92
+
[2025-01-02T12:34:56+01:00] did:plc:abcd1234 :create app.bsky.feed.post 3rblblbl {"text":"hi"}
93
93
+
[2025-01-02T12:34:57+01:00] did:plc:efgh5678 :delete app.bsky.graph.follow 3szxczxc
94
94
+
```
95
95
+
96
96
+
Press Ctrl-C to disconnect.
97
97
+
98
98
+
To use Jetstream, add `--jetstream` or `-j`:
99
99
+
100
100
+
```
101
101
+
rat stream -j jetstream1.us-east.bsky.network
102
102
+
```
103
103
+
104
104
+
#### Filtering by DID and/or collection
105
105
+
106
106
+
You can filter on DID:
107
107
+
108
108
+
```
109
109
+
rat stream jetstream1.us-east.bsky.network \
110
110
+
--jetstream \
111
111
+
--did did:plc:abcd1234,did:plc:wxyz9999
112
112
+
```
10
113
11
11
-
Install the gem and add to the application's Gemfile by executing:
114
114
+
Or collection:
12
115
13
13
-
```bash
14
14
-
bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
116
116
+
```
117
117
+
rat stream jetstream1.us-east.bsky.network \
118
118
+
--jetstream \
119
119
+
--collection app.bsky.feed.post
15
120
```
16
121
17
17
-
If bundler is not being used to manage dependencies, install the gem by executing:
122
122
+
Or both:
18
123
19
19
-
```bash
20
20
-
gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
124
124
+
```
125
125
+
rat stream jetstream1.us-east.bsky.network \
126
126
+
--jetstream \
127
127
+
-d did:plc:abcd1234 \
128
128
+
-c app.bsky.feed.post,app.bsky.graph.follow
21
129
```
22
130
23
23
-
## Usage
131
131
+
You can repeat both options instead if you prefer:
24
132
25
25
-
TODO: Write usage instructions here
133
133
+
```
134
134
+
rat stream host --jetstream -d did:1 -d did:2 -c app.bsky.feed.post
135
135
+
```
26
136
27
27
-
## Development
137
137
+
#### Starting from a cursor
28
138
29
29
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
139
139
+
```
140
140
+
rat stream host -r 12345
141
141
+
```
142
142
+
30
143
31
31
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
144
144
+
## Credits
32
145
33
33
-
## Contributing
146
146
+
Copyright © 2026 Kuba Suder ([@mackuba.eu](https://bsky.app/profile/mackuba.eu)) & ChatGPT.
34
147
35
35
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ratproto.
148
148
+
The code is available under the terms of the [zlib license](https://choosealicense.com/licenses/zlib/) (permissive, similar to MIT).