Search by

socialdept / atp-client

socialdept

Type-safe AT Protocol HTTP client with OAuth 2.0 support for Laravel

Package info

github.com/socialdept/atp-client

pkg:composer/socialdept/atp-client

Statistics

Installs: 2 898

Dependents: 5

Suggesters: 0

Stars: 2

Open Issues: 0


README

AtpClient Header

Type-safe AT Protocol HTTP client with OAuth 2.0 support for Laravel.


This Laravel package talks to Bluesky and the AT Protocol. It signs users in with OAuth 2.0 (PKCE, PAR and DPoP) or app passwords, keeps their sessions refreshed, and gives you a typed API for posts, profiles, the social graph, feeds and raw repository writes. It also verifies service auth tokens and forwards XRPC calls to a user's PDS. To learn all about it, head over to the documentation.

Here are a few short examples of what you can do.

Sign in with an app password and post:

use SocialDept\AtpClient\Facades\Atp;

$client = Atp::login('yourhandle.bsky.social', 'your-app-password');

$client->bsky->post->create('Hello from Laravel!');

Send a user through OAuth:

$auth = Atp::oauth()->authorize('user.bsky.social');

return redirect($auth->url);

Act as a user whose session you stored:

$timeline = Atp::as($did)->bsky->feed->getTimeline(limit: 50);

Accept calls from other AT Protocol services:

Route::get('/xrpc/com.example.doThing', DoThingController::class)
    ->middleware('atp.service-auth:com.example.doThing');

Fake the client in tests:

Atp::fake();

Documentation

You'll find the documentation on https://socialde.pt/docs/atp-client.

Find yourself stuck using the package? Found a bug? Do you have general questions or suggestions for improving it? Feel free to create an issue on GitHub.

Testing

vendor/bin/phpunit

Changelog

Please see the changelog for recent changes.

Contributing

Please see CONTRIBUTING for details.

License

The MIT License (MIT). Please see the license file for more information.