At - The AT Protocol for Social Networking
use At;
my $at = At->new( service => 'https://your.atproto.service.example.com/' ); }
$at->login( 'your.identifier.here', 'hunter2' );
$at->post(
'com.atproto.repo.createRecord' => {
repo => $at->did,
collection => 'app.bsky.feed.post',
record => { '$type' => 'app.bsky.feed.post', text => 'Hello world! I posted this via the API.', createdAt => $at->now }
}
);
Unless you're designing a new client arount the AT Protocol, this is probably not what you're looking for.
Try Bluesky.pm.
At.pm attempts to keep track of rate limits according to the protocol's specs. Right now, we simply carp
about
nearing the limit but a future release will allow for devs to query these limits.
See also: https://docs.bsky.app/docs/advanced-guides/rate-limits
You'll need an authenticated session for most API calls. There are two ways to manage sessions:
-
- Username/password based (deprecated)
-
- OAuth based (still being rolled out)
Developers of new code should be aware that the AT protocol will be transitioning to OAuth in over the next year or so (2024-2025) and this distribution will comply with this change.
This module is based on perl's new (as of writing) class system which means it's (obviously) object oriented.
my $at = At->new( service => ... );
Create a new At object. Easy.
Expected parameters include:
-
service
- requiredHost for the service.
-
lexicon
Location of lexicons. This allows new AT Protocol Lexicons to be referenced without installing a new version of this module.
Defaults to
/lexicons
under the dist's share directory.
A new object is returned on success.
Create an app password backed authentication session.
my $session = $bsky->login(
identifier => '[email protected]',
password => '1111-2222-3333-4444'
);
Expected parameters include:
-
identifier
- requiredHandle or other identifier supported by the server for the authenticating user.
-
password
- requiredThis is the app password not the account's password. App passwords for Blueskyare generated at https://bsky.app/settings/app-passwords.
-
authFactorToken
Returns an authorized session on success.
Resumes an app password based session.
$bsky->resume( '...', '...' );
Expected parameters include:
accessJwt
- requiredrefreshJwt
- required
If the accessJwt
token has expired, we attempt to use the refreshJwt
to continue the session with a new token. If
that also fails, well, that's kinda it.
The new session is returned on success.
Gather the DID (Decentralized Identifiers) of the current user. Returns undef
on
failure or if the client is not authenticated.
Gather the current AT Protocol session info. You should store the accessJwt
and refreshJwt
tokens securely.
$at->get(
'com.atproto.repo.getRecord' => {
repo => $at->did,
collection => 'app.bsky.actor.profile',
rkey => 'self'
}
);
Sends an HTTP get request to the service.
Expected parameters include:
-
identifier
- requiredLexicon endpoint.
-
content
This will be passed along to the endpoint as query parameters.
On success, the content is returned. If the lexicon is known, the returned data is coerced into simple (blessed) objects.
On failure, a throwable error object is returned which will have a false boolean value.
In array context, the resonse headers are also returned.
$at->post(
'com.atproto.repo.createRecord' => {
repo => $at->did,
collection => 'app.bsky.feed.post',
record => { '$type' => 'app.bsky.feed.post', text => 'Hello world! I posted this via the API.', createdAt => $at->now->as_string }
}
);
Sends an HTTP POST request to the service.
Expected parameters include:
-
identifier
- requiredLexicon endpoint.
-
content
This will be passed along to the endpoint as encoded JSON.
On success, the content is returned. If the lexicon is known, the returned data is coerced into simple (blessed) objects.
On failure, a throwable error object is returned which will have a false boolean value.
In array context, the resonse headers are also returned.
Exception handling is carried out by returning At::Error objects which have untrue boolean values.
Bluesky - Bluesky client library
https://docs.bsky.app/docs/api/
Copyright (C) Sanko Robinson.
This library is free software; you can redistribute it and/or modify it under the terms found in the Artistic License 2. Other copyrights, terms, and conditions may apply to data transmitted through this module.
Sanko Robinson [email protected]