NAME

At - The AT Protocol for Social Networking

SYNOPSIS

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->as_string }
    }
);

DESCRIPTION

Unless you're designing a new client arount the AT Protocol, this is probably not what you're looking for.

Try Bluesky.pm.

Rate Limits

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

Session Management

You'll need an authenticated session for most API calls. There are two ways to manage sessions:

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.

Methods

This module is based on perl's new (as of writing) class system which means it's (obviously) object oriented.

new( ... )

my $at = At->new( service => ... );

Create a new At object. Easy.

Expected parameters include:

A new object is returned on success.

login( ... )

Create an app password backed authentication session.

my $session = $bsky->login(
    identifier => 'john@example.com',
    password   => '1111-2222-3333-4444'
);

Expected parameters include:

Returns an authorized session on success.

resume( ... )

Resumes an app password based session.

$bsky->resume( '...', '...' );

Expected parameters include:

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.

did( )

Gather the DID (Decentralized Identifiers) of the current user. Returns undef on failure or if the client is not authenticated.

session( )

Gather the current AT Protocol session info. You should store the accessJwt and refreshJwt tokens securely.

get( ... )

$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:

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.

post( ... )

$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:

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.

Error Handling

Exception handling is carried out by returning At::Error objects which have untrue boolean values.

See Also

Bluesky - Bluesky client library

App::bsky - Bluesky client on the command line

https://docs.bsky.app/docs/api/

LICENSE

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.

AUTHOR

Sanko Robinson sanko@cpan.org