Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/moomerman/atproto
Implementation of the ATProtocol client spec in Elixir.
https://github.com/moomerman/atproto
Last synced: 3 months ago
JSON representation
Implementation of the ATProtocol client spec in Elixir.
- Host: GitHub
- URL: https://github.com/moomerman/atproto
- Owner: moomerman
- License: mit
- Created: 2023-04-28T15:08:20.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-04-30T13:02:53.000Z (over 1 year ago)
- Last Synced: 2024-09-19T17:36:07.582Z (4 months ago)
- Language: Elixir
- Homepage:
- Size: 15.6 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-atproto - Implementation of the ATProtocol client spec in Elixir
README
# ATProto
Implementation of the [ATProtocol](https://atproto.com/docs) client spec in Elixir.
## Installation
The package can be installed by adding `atproto` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:atproto, "~> 0.1.0"}
]
end
```The docs can be found at .
## Usage
`ATProtocol` uses [XRPC](https://github.com/moomerman/xrpc) for API communication, so we need to build an `XRPC.Client` and then we can call `ATProto` or `ATProto.BSky` functions.
Unauthenticated example:
```elixir
XRPC.Client.new("https://bsky.social")
|> ATProto.resolve_handle("atproto.com"){:ok, %{"did" => "did:plc:ewvi7nxzyoun6zhxrhs64oiz"}}
```Authenticated example:
```elixir
client = XRPC.Client.new("https://bsky.social"){:ok, session} = ATProto.create_session(client, "[email protected]", "xxxx-xxxx-xxxx-xxxx")
client
|> Map.put(:access_token, session.access_jwt)
|> ATProto.BSky.get_profile("atproto.com"){:ok,
%ATProto.BSky.ProfileViewDetailed{
avatar: "https://cdn.bsky.social/imgproxy/EoCjH1lIwK1YNFuG_xYYK76vuHhEAQKWAkzlz8BSO_Q/rs:fill:1000:1000:1:0/plain/bafkreibjfgx2gprinfvicegelk5kosd6y2frmqpqzwqkg7usac74l3t2v4@jpeg",
banner: "https://cdn.bsky.social/imgproxy/Goxx1Ze2lScFMdlEXE0pVTzXBxsIuwbdxhYkWo1CVUA/rs:fill:3000:1000:1:0/plain/bafkreib4xwiqhxbqidwwatoqj7mrx6mr7wlc5s6blicq5wq2qsq37ynx5y@jpeg",
description: "Social networking technology created by Bluesky.",
did: "did:plc:ewvi7nxzyoun6zhxrhs64oiz",
display_name: "AT Protocol",
followers_count: 1965,
follows_count: 11,
handle: "atproto.com",
posts_count: 10,
...
}}
```Creating a new post on Blue Sky:
```elixir
{:ok, session} = ....
XRPC.Client.new("https://bsky.social", session.access_jwt)
|> ATProto.BSky.create_post("atproto.com", text: "Hello Elixir 💜")
```