Skip to content

Commit 16bb76f

Browse files
chore: updated the usage guide in readme
1 parent f5e1092 commit 16bb76f

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

README.md

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
A lightweight, fast, universal and typed Bluesky API wrapper for Apps & Bots.
99
</p>
1010

11-
## ⚠️ tsky is still in development and is not ready for production use.
11+
## ⚠️ tsky is still in development and is not ready for production use
1212

1313
tsky is still in active development and is not ready for production use. If you want to contribute to the project, please read the [CONTRIBUTING.md](CONTRIBUTING.md) file or join our [Discord Server](https://discord.gg/KPD7XPUZn3).
1414

@@ -34,39 +34,38 @@ bun add tsky
3434

3535
## Usage
3636

37-
Use an identity & password login:
37+
Using a Public Agent
3838

3939
```ts
40-
import { Tsky } from 'tsky';
41-
import { CredentialManager } from '@atcute/client';
40+
import { createAgent } from '@tsky/client';
4241

43-
const manager = new CredentialManager({ service: 'https://bsky.social' });
44-
await manager.login({
45-
identifier: 'alice.tsky.dev',
46-
password: 'password',
42+
const agent = await createAgent({
43+
options: {
44+
service: 'https://public.api.bsky.app',
45+
},
4746
});
48-
```
49-
50-
or the [@atcute/oauth-browser-client](https://github.com/mary-ext/atcute/tree/trunk/packages/oauth/browser-client):
51-
52-
```ts
53-
import { Tsky } from 'tsky';
54-
import { OAuthUserAgent, finalizeAuthorization } from '@atcute/oauth-browser-client';
55-
56-
// get a session as described at: https://github.com/mary-ext/atcute/tree/trunk/packages/oauth/browser-client
5747

58-
const manager = new OAuthUserAgent(session);
48+
// Getting a user from their handle
49+
// First, we need to get the user's DID
50+
const did = await agent.resolveDIDFromHandle(handle);
51+
// Then, we can get the user's profile
52+
const profile = await agent.actor(did);
5953
```
6054

61-
and then initialize the tsky client:
55+
Using an Authenticated Agent
6256

6357
```ts
64-
const tsky = new Tsky(manager);
58+
import { createAgent } from '@tsky/client';
6559

66-
// get the profile of a user
67-
const profile = await tsky.bsky.profile('did:plc:giohuovwawlijq7jkuysq5dd');
60+
const agent = await createAgent({
61+
credentials: {
62+
identifier: "handle",
63+
password: "password"
64+
}
65+
});
6866

69-
console.log(profile.handle);
67+
// Getting the profile of the authenticated user
68+
const user_profile = await agent.user.profile();
7069
```
7170

7271
## Links

0 commit comments

Comments
 (0)