Download the PHP package gimucco/bluesky-php without Composer
On this page you can find all versions of the php package gimucco/bluesky-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gimucco/bluesky-php
More information about gimucco/bluesky-php
Files in gimucco/bluesky-php
Package bluesky-php
Short Description Bluesky / AT Protocol API client for PHP — a typed wrapper over the lexicon API, built on gimucco/atproto-php for OAuth.
License GPL-2.0-or-later
Homepage https://github.com/gimucco/bluesky-php
Informations about the package bluesky-php
bluesky-php
A typed PHP client for the Bluesky / AT Protocol API — built on gimucco/atproto-php for OAuth 2.1 / DPoP authentication.
- 93 typed API methods + 28 auto-paginators generated from official Bluesky lexicons
- 250 generated value-object types with
fromArray()/toArray() - Convenience methods for posts, threads, all 5 embed types, engagement, social graph, moderation
- PHPStan level 10 with strict-rules — fully statically typed
- OAuth 2.1 + DPoP — no app-password flow (deprecated by Bluesky)
At a glance
Cheat sheet
| Domain | Methods |
|---|---|
| Posting | post(), reply(), thread(), deletePost() |
| Embeds | EmbeddedImage, EmbeddedVideo, EmbeddedExternal, EmbeddedRecord, EmbeddedRecordWithMedia |
| Engagement | like() / unlike(), repost() / unrepost() |
| Social graph | follow() / unfollow(), block() / unblock(), mute() / unmute() |
| Reading | myProfile(), getPost() |
| Media uploads | uploadImage(), uploadVideo(), postVideo(), awaitVideo() |
| Pagination | feed->paginateTimeline(), graph->paginateFollowers(), … (28 auto-generated) + Pager::iterate() for custom shapes |
| Lexicon API | $client->actor, $client->feed, $client->graph, $client->notification, $client->repo, $client->identity, $client->server, $client->label, $client->video, $client->bookmark, $client->labeler |
| Identifiers | Did, Handle, AtUri (validated, Stringable) |
| Refs | PostRef, FollowRef, LikeRef, RepostRef, BlockRef (all Stringable to their uri) |
See examples/ for runnable code per use case.
Installation
Requirements: PHP 8.2+, ext-json, ext-fileinfo, ext-curl, ext-openssl, ext-sodium (curl/openssl/sodium come from gimucco/atproto-php).
Authentication: OAuth only
This library performs Bluesky/AT Protocol API calls. It does not handle authentication — that's gimucco/atproto-php, which implements the AT Protocol's mandatory OAuth 2.1 + DPoP + PAR profile.
There is no app-password / identifier+password flow. App passwords are deprecated; OAuth 2.1 is the only path. To use this library you set up the OAuth flow once (login redirect → callback → stored session), then restore the session by DID for subsequent API calls.
For long-running automation: log in once interactively, then reuse the persisted session indefinitely (tokens auto-refresh).
Quick start
The shortest possible example, assuming you already have a stored session:
OAuth setup (one-time)
-
Generate an ES256 key
- Host two static JSON files at HTTPS URLs (
client-metadata.jsonandjwks.json). Usebin/generate-metadatafromvendor/gimucco/atproto-phpto produce them. - Configure & build the OAuth client — see
examples/bootstrap.phpfor the runtime restore pattern.
Restoring a session at runtime
Posting
Plain text
Reply
For nested replies in a thread, also pass rootUri and rootCid of the thread root.
Thread
For long threads, throttle to avoid burst rate limits:
Note: thread() is not transactional — if a mid-thread post fails, prior posts remain published. See the method's docblock for partial-failure semantics.
All 5 embed types
A post can carry at most one embed (the EmbeddedRecordWithMedia type combines a quote with images/video). Mismatch throws InvalidArgumentException.
EmbeddedExternal rejects non-http(s) URIs at construction time.
Media
Images
Empty bytes or empty MIME string throws InvalidArgumentException.
Video
Bluesky processes videos asynchronously, but the convenience methods hide the polling. Three levels of API, in order of decreasing convenience:
All three block the calling thread — fine for CLI / cron / queue, not appropriate inside a synchronous web request. The default await timeout is 120 s (exponential backoff capped at 10 s/poll); pass a smaller timeoutSeconds from a request with a max execution budget.
Video calls do not go to the user's PDS — Bluesky operates a dedicated video processing service at https://video.bsky.app. The library handles routing transparently: each call mints a short-lived service-auth JWT via the user's PDS (com.atproto.server.getServiceAuth) with the audience set to the user's PDS DID (did:web:<pdsHost>, derived from the live session) and sends it as a plain bearer token to the video service, which validates the issuer chain back to the user's PDS. Uploads use lxm=com.atproto.repo.uploadBlob (the video service treats them as generic blob uploads); status / limits use their lexicon-defined lxm values. Re-uploading the exact same bytes (content-hash dedupe) is recognized server-side and returned as a successful job — no 409 thrown. The HTTP path uses curl with explicit timeouts (10 s connect, 120 s total upload, 30 s status) and SSL verification on. To target a different video service host, pass videoServiceUrl: 'https://your-video-service' to new Client(...).
Engagement
Social graph
follow() and block() accept handle, DID, Did, or Handle. Handles are auto-resolved to DIDs (one extra API call). mute() accepts both directly (no resolution needed).
Reading
The full generated API surface is on $client->actor, $client->feed, $client->graph, etc. See examples/notifications.php.
Pagination
34 of the 93 generated methods accept cursor and return {cursor, items}. Each gets a typed paginate* companion:
For custom shapes or non-generated endpoints, use Pager::iterate():
Typed identifiers
All five Ref classes (PostRef, FollowRef, LikeRef, RepostRef, BlockRef) are Stringable to their uri — you can pass them directly to delete methods (unfollow($followRef), etc.).
Logging
Convenience methods emit debug-level events on post/follow/like/etc. Heads up: log context includes subject DIDs and post URIs, so a shared log file becomes a who-blocks-whom audit trail. Configure your logger accordingly.
Error handling
Code generation
The src/Generated/ directory is produced from AT Protocol lexicon JSONs (which are not committed — fetched on demand via composer sync-lexicons).
Skipped namespaces (out of scope for this library): com.atproto.sync.*, chat.bsky.*, tools.ozone.*, com.atproto.admin.*, com.atproto.temp.*, com.atproto.moderation.*, app.bsky.unspecced.*.
Development
For real-API smoke tests against your test account, see tests/manual/.
Project structure
License
GPL-2.0-or-later. See LICENSE.
All versions of bluesky-php with dependencies
ext-fileinfo Version *
ext-json Version *
gimucco/atproto-php Version ^0.2
psr/http-message Version ^1.1 || ^2.0
psr/log Version ^2.0 || ^3.0