bsky.client

Bluesky client
License: BSL-1.0
struct FetchRange(T);
const @safe bool empty();
const @trusted T front();
@safe void popFront();
@safe void setFetchLength(size_t len);
class Bluesky;
Bluesky client
alias ReplyRef = bsky.lexicons.app.bsky.feed.Post.ReplyRef;
alias PostRef = bsky.lexicons.com.atproto.repo.StrongRef;
alias Post = bsky.post.Post;
@trusted this(Client = CurlHttpClient!())(string endpoint, AtprotoAuth auth = null, Client client = new Client);
@trusted this(Client : HttpClientBase)(string endpoint, AtprotoAuth auth = null, Client client);
@safe this(Client = CurlHttpClient!())(string endpoint, shared AtprotoAuth auth, Client client = new Client);
@safe this(Client : HttpClientBase)(string endpoint, shared AtprotoAuth auth, Client client);
@trusted this(Client = CurlHttpClient!())(AtprotoAuth auth, Client client = new Client);
@trusted this(Client : HttpClientBase)(AtprotoAuth auth, Client client);
@safe this(Client = CurlHttpClient!())(shared AtprotoAuth auth, Client client = new Client);
@safe this(Client : HttpClientBase)(shared AtprotoAuth auth, Client client);
@safe this(Client = CurlHttpClient!())(Client client = new Client);
@safe this(Client : HttpClientBase)(Client client);
Constructor
@trusted void login(AtprotoAuth auth);
@safe void login(shared AtprotoAuth auth);
@safe void login(Client = CurlHttpClient!())(string id, string password, Client client = null);
@safe void login(Client : HttpClientBase)(string id, string password, Client client);
Login
@safe void logout();
Logout
const @safe bool available();
Account availability
enum AutoUpdateStrategy: int;
Auto update access token types
none
herf
before5min
expired
@safe void autoUpdateAccessTokens(bool cond);
@safe void autoUpdateAccessTokens(AutoUpdateStrategy type);
const @safe AutoUpdateStrategy autoUpdateAccessTokens();
Auto update access tokens
@safe JSONValue getProfile(string name = null);
@trusted Profile profile(string name = null);
@trusted JSONValue getProfiles(string[] actors);
@safe Profile[] fetchProfiles(string[] names);
@safe FetchRange!Profile profiles(string[] names);
Profile
  • getProfile : Raw API execution.
  • profile : Get target profile.
  • getProfiles : Raw API execution.
  • fetchProfiles : Execute multiple APIs to get all data.
  • profiles : Range to perform API execution when needed.
Parameters:
string name did or handle, default is user of current session.
string[] names did or handle list
string[] actors did or handle list, max length is 25
@safe JSONValue getFollowers(string actor, string cursor = null, size_t limit = 100);
@safe User[] fetchFollowers(string name, size_t len = 100);
@safe User[] fetchFollowers();
@safe FetchRange!User followers(string name, size_t limit = 100);
@safe FetchRange!User followers();
Followers
  • getFollowers : Raw API execution.
  • fetchFollowers : Execute multiple APIs to get all data.
  • followers : Range to perform API execution when needed.
Parameters:
string name did or handle, default is user of current session.
string actor did or handle, default is user of current session.
string cursor Cursor for sequential data retrieval.
size_t len Number of data to be acquired at one time.
size_t limit Number to retrieve in a single API run.
@safe JSONValue getFollows(string actor, string cursor = null, size_t limit = 50);
@safe User[] fetchFollows(string name, size_t len = 100);
@safe User[] fetchFollows();
@safe FetchRange!User follows(string name, size_t limit = 100);
@safe FetchRange!User follows();
Follows
  • getFollows : Raw API execution
  • fetchFollows : Execute multiple APIs to get all data.
  • follows : Range to perform API execution when needed.
Parameters:
string name did or handle, default is user of current session.
string actor did or handle, default is user of current session.
string cursor Cursor for sequential data retrieval.
size_t limit Number to retrieve in a single API run.
struct TimelineResult;
Result of get timeline
Feed[] feed;
string cursor;
@safe JSONValue getTimeline(string cursor, size_t limit);
@safe TimelineResult fetchTimeline(string cursor, size_t len = 100);
@safe Feed[] fetchTimeline(size_t len);
@safe FetchRange!Feed timeline(string cursor, size_t limit = 100);
@safe FetchRange!Feed timeline(size_t limit = 100);
Get timeline
  • getTimeline : Raw API execution.
  • fetchTimeline : Execute multiple APIs to get all data.
  • timeline : Range to perform API execution when needed.
Params cursor = Cursor for sequential data retrieval. len = Number of data to be acquired at one time. limit = Number to retrieve in a single API run.
alias AuthorFeedResult = TimelineResult;
@safe JSONValue getAuthorFeed(string actor, string cursor, size_t limit = 50);
@safe AuthorFeedResult fetchAuthorFeed(string name, string cursor, size_t len = 100);
@safe FetchRange!Feed authorFeed(string name, string cursor, size_t limit = 100);
@safe FetchRange!Feed authorFeed(string name, size_t limit = 100);
@safe FetchRange!Feed authorFeed(size_t limit = 100);
Posts and reposts by any user
  • getAuthorFeed :
  • fetchAuthorFeed :
  • authorFeed :
Parameters:
string name did or handle, default is user of current session.
string actor did or handle, default is user of current session.
alias FeedResult = TimelineResult;
@safe JSONValue getFeed(string feedUri, string cursor, size_t limit = 50);
@safe FeedResult fetchFeed(string feedUri, string cursor, size_t len = 100);
@safe FetchRange!Feed feed(string feedUri, string cursor, size_t limit = 100);
@safe FetchRange!Feed feed(string feedUri, size_t limit = 100);
Posts by any feed
alias ListFeedResult = TimelineResult;
@safe JSONValue getListFeed(string listUri, string cursor, size_t limit = 50);
@safe auto fetchListFeed(string listUri, string cursor, size_t len);
@safe FetchRange!Feed listFeed(string listUri, string cursor, size_t limit = 100);
@safe FetchRange!Feed listFeed(string listUri, size_t limit = 100);
Posts by any feed
struct SearchPostsResult;
Result of search posts
string cursor;
size_t hitsTotal;
Post[] posts;
@safe JSONValue searchPosts(string query, string cursor, size_t limit = 50);
@safe SearchPostsResult fetchSearchPosts(string query, string cursor, size_t len = 100);
@safe Post[] fetchSearchPosts(string query, size_t len = 100);
@safe FetchRange!Post searchPostItems(string query, string cursor, size_t limit = 100);
@safe FetchRange!Post searchPostItems(string query, size_t limit = 100);
Search posts
@safe JSONValue getPosts(string[] uris);
@safe Post[] fetchPosts(string[] uris);
@safe auto getPostItems(Range)(Range uris)
if(is(imported!"std.range".ElementType!Range : string));
struct GetPostThreadResult;
app.bsky.feed.ThreadViewPost.Node thread;
app.bsky.feed.ThreadgateView threadgate;
@safe JSONValue getPostThread(string uri, size_t depth = 6, size_t parentHeight = 80);
@trusted auto fetchPostThread(string uri, size_t depth = 6, size_t parentHeight = 80);
Get posts in a thread
struct GetRepostResult;
User[] repostedBy;
string cursor;
@safe JSONValue getRepostedBy(string uri, string cursor, size_t limit = 50);
@safe GetRepostResult fetchRepostedByUsers(string uri, string cursor, size_t len = 100);
@safe User[] fetchRepostedByUsers(string uri, size_t len = 100);
@safe FetchRange!User repostedByUsers(string uri, string cursor, size_t limit = 100);
@safe FetchRange!User repostedByUsers(string uri, size_t limit = 100);
Users who has reposted the post
struct Like;
struct GetLikeResult;
SysTime indexedAt;
SysTime createdAt;
User actor;
@safe JSONValue getLikes(string uri, string cursor, size_t limit = 50);
@safe GetLikeResult fetchLikeUsers(string uri, string cursor, size_t len = 100);
@safe Like[] fetchLikeUsers(string uri, size_t len = 100);
@safe FetchRange!Like likeUsers(string uri, string cursor, size_t limit = 100);
@safe FetchRange!Like likeUsers(string uri, size_t limit = 100);
Users who has liked the post
struct GetQuotedByResult;
Post[] quotedBy;
string cursor;
@safe JSONValue getQuotes(string uri, string cursor, size_t limit = 50);
@safe GetQuotedByResult fetchQuotedByPosts(string uri, string cursor, size_t len = 100);
@safe Post[] fetchQuotedByPosts(string uri, size_t len = 100);
@safe FetchRange!Post quotedByPosts(string uri, string cursor, size_t limit = 100);
@safe FetchRange!Post quotedByPosts(string uri, size_t limit = 100);
Users who has reposted the post
@safe string resolveHandle(string handle);
Resolve handle
Resolve handle to DID. Usually https:///xrpc/com.atproto.identity.resolveHandle is used for resolution, but if this cannot be obtained, fall back to app.bsky.actor.getProfile.
Parameters:
string handle handle of user
Returns: did
@safe JSONValue getDidDoc(string actor);
Get DID document
Parameters:
string actor did or handle of user
Returns: did document
@safe Bluesky createPDSClient(string actor);
Create client of PDS
Parameters:
string actor did or handle of user
Returns: did document
@safe JSONValue createRecord(JSONValue record, string collection, JSONValue opts);
@safe JSONValue createRecord(JSONValue record, string collection, string rkey, bool validate, string swapCommit);
@safe JSONValue createRecord(JSONValue record, string collection = "app.bsky.feed.post", string rkey = null, string swapCommit = null);
Create repository record
Parameters:
JSONValue record Record to create as
string collection Collection of record
bool validate Can be set to 'false' to skip Lexicon schema validation of record data, 'true' to require it, or leave unset to validate only for known Lexicons.
string rkey The Record Key.
string swapCommit Compare and swap with the previous commit by CID.
Returns: JSON of result data
@safe JSONValue getRecord(string authority, string collection, string rkey);
@safe JSONValue getRecord(AtProtoURI uri);
@safe JSONValue getRecord(string uri);
Get repository record
Parameters:
string authority Author of repository.
string collection Collection of records.
string rkey The Record Key.
Returns: JSON of result data
@safe void deleteRecord(string collection, string rkey, string swapRecord = null, string swapCommit = null);
@safe void deleteRecord(AtProtoURI uri);
@safe void deleteRecord(string uri);
Delete repository record
Parameters:
string collection Collection of record
string rkey refresh key of record
string swapRecord Swap Record
string swapCommit Swap Commit
Returns: JSON of result data
struct ListRecordItem;
Record item of com.atproto.repo.listRecords API
string uri;
string cid;
JSONValue value;
struct ListRecords;
Response of com.atproto.repo.listRecords API
ListRecordItem[] records;
string cursor;
@safe JSONValue listRecords(string authority, string collection, size_t limit = 50);
@safe ListRecords fetchRecords(string authority, string collection, string cursor, size_t len = 50);
@safe ListRecordItem[] fetchRecords(string authority, string collection, size_t len = 50);
@safe ListRecordItem[] fetchRecords(string collection, size_t len = 50);
@safe FetchRange!ListRecordItem listRecordItems(string authority, string collection, size_t limit = 100);
@safe FetchRange!ListRecordItem listRecordItems(string collection, size_t limit = 100);
List-up repository records
Parameters:
string authority Author of repository.
string collection Collection of record
Returns: JSON of result data
@safe Blob uploadBlob(immutable(ubyte)[] data, string mimeType);
Upload blob data
Parameters:
immutable(ubyte)[] data Upload data
string mimeType Upload data type
Returns: JSON of upload result data
@safe StrongRef getRecordRef(string uri);
alias getPostRef = getRecordRef;
Reply data from URI
Parameters:
string uri URI of reply parent
Returns:
PostRef: bsky.lexcons.com.atproto.repo.StrongRef
struct EmbedImage;
@safe app.bsky.embed.Images.Image getEmbedImage(EmbedImage image);
@safe app.bsky.embed.Images.Image getEmbedImage(immutable(ubyte)[] imageData, string mimeType, string alt, int width = 0, int height = 0);
@safe app.bsky.embed.Images getEmbedImages(EmbedImage[] images);
Embed data of image
immutable(ubyte)[] image;
Binary of image
Limitation: < 1MB
string mimeType;
MimeType of image
string alt;
Alt text
int width;
Aspect ratio - width
int height;
Aspect ratio - height
struct EmbedExternal;
@safe app.bsky.embed.External getEmbedExternal(EmbedExternal external);
@safe app.bsky.embed.External getEmbedExternal(string uri, string title, string description, immutable(ubyte)[] thumb = null, string thumbMimeType = null);
Embed data of external link
string uri;
URL of external link
string title;
Title of external link
string description;
Descriptions
immutable(ubyte)[] thumb;
Thumbnail of external link
string thumbMimeType;
Thumbnail of external link
alias EmbedRecord = bsky.lexicons.com.atproto.repo.StrongRef;
Embed data of external link
struct EmbedRecordWithMedia;
Embed data of external link
PostRef record;
URI of record
alias Media = std.sumtype.SumType!(EmbedImage[], EmbedExternal).SumType;
Media media;
Image data
struct EmbedVideo;
@safe app.bsky.embed.Video getEmbedVideo(EmbedVideo video);
@safe app.bsky.embed.Video getEmbedVideo(immutable(ubyte)[] videoData, string mimeType, string alt, int width = 0, int height = 0);
Embed data of image
immutable(ubyte)[] video;
Binary of image
Limitation: < 1MB
string mimeType;
MimeType of image
string alt;
Alt text
int width;
Aspect ratio - width
int height;
Aspect ratio - height
struct Caption;
Caption[] captions;
Caption file
string lang;
immutable(ubyte)[] data;
@safe ReplyRef getReplyRef(string uri);
Reply data from URI
Parameters:
string uri URI of reply parent
Returns:
ReplyRef: bsky.lexcons.app.bsky.feed.ReplyRef
@safe PostRef sendPost(string message, Embed embed, ReplyRef replyRef = ReplyRef.init, JSONValue opts = JSONValue.init);
@safe PostRef sendPost(string message, JSONValue opts = JSONValue.init);
@safe PostRef sendPost(string message, app.bsky.embed.Images.Image image, JSONValue opts = JSONValue.init);
@safe PostRef sendPost(string message, app.bsky.embed.Images images, JSONValue opts = JSONValue.init);
@safe PostRef sendPost(string message, EmbedImage image, JSONValue opts = JSONValue.init);
@safe PostRef sendPost(string message, EmbedImage[] images, JSONValue opts = JSONValue.init);
@safe PostRef sendPost(string message, app.bsky.embed.External external, JSONValue opts = JSONValue.init);
@safe PostRef sendPost(string message, EmbedExternal external, JSONValue opts = JSONValue.init);
@safe PostRef sendPost(string message, app.bsky.embed.Record record, JSONValue opts = JSONValue.init);
@safe PostRef sendPost(string message, EmbedRecord record, JSONValue opts = JSONValue.init);
@safe PostRef sendPost(string message, app.bsky.embed.RecordWithMedia rwm, JSONValue opts = JSONValue.init);
@safe PostRef sendPost(string message, EmbedRecordWithMedia recordWithMedia, JSONValue opts = JSONValue.init);
@safe PostRef sendPost(string message, EmbedRecord record, EmbedImage image, JSONValue opts = JSONValue.init);
@safe PostRef sendPost(string message, EmbedRecord record, EmbedImage[] image, JSONValue opts = JSONValue.init);
@safe PostRef sendPost(string message, EmbedRecord record, EmbedExternal external, JSONValue opts = JSONValue.init);
@safe PostRef sendPost(string message, app.bsky.embed.Video video, JSONValue opts = JSONValue.init);
@safe PostRef sendPost(string message, EmbedVideo image, JSONValue opts = JSONValue.init);
@safe PostRef sendReplyPost(string uri, string message, Embed embed = Embed.init, JSONValue opts = JSONValue.init);
@safe PostRef sendReplyPost(string uri, string message, app.bsky.embed.Images images, JSONValue opts = JSONValue.init);
@safe PostRef sendReplyPost(string uri, string message, app.bsky.embed.Images.Image[] images, JSONValue opts = JSONValue.init);
@safe PostRef sendReplyPost(string uri, string message, app.bsky.embed.Images.Image image, JSONValue opts = JSONValue.init);
@safe PostRef sendReplyPost(string uri, string message, EmbedImage image, JSONValue opts = JSONValue.init);
@safe PostRef sendReplyPost(string uri, string message, EmbedImage[] images, JSONValue opts = JSONValue.init);
@safe PostRef sendReplyPost(string uri, string message, app.bsky.embed.External external, JSONValue opts = JSONValue.init);
@safe PostRef sendReplyPost(string uri, string message, EmbedExternal external, JSONValue opts = JSONValue.init);
@safe PostRef sendReplyPost(string uri, string message, app.bsky.embed.Record record, JSONValue opts = JSONValue.init);
@safe PostRef sendReplyPost(string uri, string message, EmbedRecord record, JSONValue opts = JSONValue.init);
@safe PostRef sendReplyPost(string uri, string message, app.bsky.embed.RecordWithMedia recordWithMedia, JSONValue opts = JSONValue.init);
@safe PostRef sendReplyPost(string uri, string message, EmbedRecordWithMedia recordWithMedia, JSONValue opts = JSONValue.init);
@safe PostRef sendReplyPost(string uri, string message, app.bsky.embed.Video video, JSONValue opts = JSONValue.init);
@safe PostRef sendReplyPost(string uri, string message, EmbedVideo video, JSONValue opts = JSONValue.init);
@safe PostRef sendQuotePost(string uri, string message, JSONValue opts = JSONValue.init);
@safe PostRef sendQuotePost(string uri, string message, app.bsky.embed.Images images, JSONValue opts = JSONValue.init);
@safe PostRef sendQuotePost(string uri, string message, app.bsky.embed.Images.Image[] images, JSONValue opts = JSONValue.init);
@safe PostRef sendQuotePost(string uri, string message, app.bsky.embed.Images.Image image, JSONValue opts = JSONValue.init);
@safe PostRef sendQuotePost(string uri, string message, EmbedImage image, JSONValue opts = JSONValue.init);
@safe PostRef sendQuotePost(string uri, string message, EmbedImage[] images, JSONValue opts = JSONValue.init);
@safe PostRef sendQuotePost(string uri, string message, app.bsky.embed.External external, JSONValue opts = JSONValue.init);
@safe PostRef sendQuotePost(string uri, string message, EmbedExternal external, JSONValue opts = JSONValue.init);
@safe PostRef sendQuotePost(string uri, string message, app.bsky.embed.Video video, JSONValue opts = JSONValue.init);
@safe PostRef sendQuotePost(string uri, string message, EmbedVideo video, JSONValue opts = JSONValue.init);
Post message
Parameters:
app.bsky.embed.Record record Record of post
string message Main text of post
app.bsky.embed.Images images Embed images of post
JSONValue opts Optional parameter of com.atproto.repo.createRecord
(ex1) langs: JSONValue(["record": JSONValue(["langs": JSONValue(["th", "en-US"])])])
(ex2) validation: JSONValue(["validation": true])
(ex3) optional field: JSONValue(["validation": JSONValue(false), "record": JSONValue(["optionalField": "data"])])
@safe void deletePost(string uri);
Delete posts
@trusted StrongRef markLike(string uri);
Mark like the post
@safe void deleteLike(string uri);
Delete like mark
@safe StrongRef repost(string uri);
Repost posts
@safe void deleteRepost(string uri);
Delete the repost
@safe StrongRef follow(string name);
Follow
Parameters:
string name Specify the handle or DID of the user you wish to follow
Returns: If successful, a reference to the record is returned
@safe void unfollow(string name);
Unfollow
Parameters:
string name Specify the handle or DID of the user you wish to unfollow