Skip to content

Commit 93ba051

Browse files
committed
feat: async sa index
1 parent a466759 commit 93ba051

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

docs/attach/index.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# scratchattach
2+
3+
Scratchattach is a scratch-API wrapper. This directory documents the WIP asynchronous API.
4+
5+
## Logging in
6+
7+
### Logging in with username & password:
8+
9+
```py
10+
import os
11+
import asyncio
12+
import scratchattach.async_api as sa
13+
from dotenv import load_dotenv
14+
15+
load_dotenv()
16+
17+
async def main():
18+
async with await sa.login(os.environ["SA_USERNAME"], os.environ["SA_PASSWORD"]) as sess:
19+
print(sess.user_id)
20+
21+
if __name__ == "__main__":
22+
asyncio.run(main())
23+
```
24+
25+
### Logging in with session id
26+
27+
```py
28+
import os
29+
import asyncio
30+
import scratchattach.async_api as sa
31+
from dotenv import load_dotenv
32+
33+
load_dotenv()
34+
35+
async def main():
36+
async with await sa.login_by_id(os.environ["SA_ID"]) as sess:
37+
print(sess.user_id)
38+
39+
if __name__ == "__main__":
40+
asyncio.run(main())
41+
```

0 commit comments

Comments
 (0)