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 = null, Client client = new Client);
@safe this(Client : HttpClientBase)(string endpoint, shared AtprotoAuth auth = null, 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 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
@safe string resolveHandle(string handle);
Resolve handle
Parameters:
string handle handle of user
Returns: did
@safe JSONValue createRecord(JSONValue record, string collection = "app.bsky.feed.post", string rkey = null, bool validate = true, 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 upload result data
@safe void deleteRecord(string collection, string rkey, string swapRecord = null, string swapCommit = null);
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 upload 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);
@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
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
alias EmbedData = std.sumtype.SumType!(EmbedImage[], EmbedExternal, StrongRef, EmbedRecordWithMedia).SumType;
@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, string[] langs = null);
@safe PostRef sendPost(string message, EmbedData embed, ReplyRef replyRef = ReplyRef.init, string[] langs = null);
@safe PostRef sendPost(string message, string[] langs = null);
@safe PostRef sendPost(string message, app.bsky.embed.Images.Image image, string[] langs = null);
@safe PostRef sendPost(string message, app.bsky.embed.Images images, string[] langs = null);
@safe PostRef sendPost(string message, EmbedImage image, string[] langs = null);
@safe PostRef sendPost(string message, EmbedImage[] images, string[] langs = null);
@safe PostRef sendPost(string message, app.bsky.embed.External external, string[] langs = null);
@safe PostRef sendPost(string message, EmbedExternal external, string[] langs = null);
@safe PostRef sendPost(string message, app.bsky.embed.Record record, string[] langs = null);
@safe PostRef sendPost(string message, EmbedRecord record, string[] langs = null);
@safe PostRef sendPost(string message, app.bsky.embed.RecordWithMedia rwm, string[] langs = null);
@safe PostRef sendPost(string message, EmbedRecordWithMedia recordWithMedia, string[] langs = null);
@safe PostRef sendPost(string message, EmbedRecord record, EmbedImage image, string[] langs = null);
@safe PostRef sendPost(string message, EmbedRecord record, EmbedImage[] image, string[] langs = null);
@safe PostRef sendPost(string message, EmbedRecord record, EmbedExternal external, string[] langs = null);
@safe PostRef sendReplyPost(string uri, string message, Embed embed = Embed.init, string[] langs = null);
@safe PostRef sendReplyPost(string uri, string message, app.bsky.embed.Images images, string[] langs = null);
@safe PostRef sendReplyPost(string uri, string message, app.bsky.embed.Images.Image[] images, string[] langs = null);
@safe PostRef sendReplyPost(string uri, string message, app.bsky.embed.Images.Image image, string[] langs = null);
@safe PostRef sendReplyPost(string uri, string message, EmbedImage image, string[] langs = null);
@safe PostRef sendReplyPost(string uri, string message, EmbedImage[] images, string[] langs = null);
@safe PostRef sendReplyPost(string uri, string message, app.bsky.embed.External external, string[] langs = null);
@safe PostRef sendReplyPost(string uri, string message, EmbedExternal external, string[] langs = null);
@safe PostRef sendReplyPost(string uri, string message, app.bsky.embed.Record record, string[] langs = null);
@safe PostRef sendReplyPost(string uri, string message, EmbedRecord record, string[] langs = null);
@safe PostRef sendReplyPost(string uri, string message, app.bsky.embed.RecordWithMedia recordWithMedia, string[] langs = null);
@safe PostRef sendReplyPost(string uri, string message, EmbedRecordWithMedia recordWithMedia, string[] langs = null);
@safe PostRef sendQuotePost(string uri, string message, string[] langs = null);
@safe PostRef sendQuotePost(string uri, string message, app.bsky.embed.Images images, string[] langs = null);
@safe PostRef sendQuotePost(string uri, string message, app.bsky.embed.Images.Image[] images, string[] langs = null);
@safe PostRef sendQuotePost(string uri, string message, app.bsky.embed.Images.Image image, string[] langs = null);
@safe PostRef sendQuotePost(string uri, string message, EmbedImage image, string[] langs = null);
@safe PostRef sendQuotePost(string uri, string message, EmbedImage[] images, string[] langs = null);
@safe PostRef sendQuotePost(string uri, string message, app.bsky.embed.External external, string[] langs = null);
@safe PostRef sendQuotePost(string uri, string message, EmbedExternal external, string[] langs = null);
Post message
Parameters:
app.bsky.embed.Record record Record of post
string message Main text of post
string[] langs Array of language of post, default (null) is nothing
app.bsky.embed.Images images Embed images of post
@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