blueskyapi

package
v0.0.0-...-f2a0a00 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2025 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteRecord

func DeleteRecord(pds string, token string, id string, my_did string, collection string) error

func GetURIComponents

func GetURIComponents(uri string) (string, string, string)

Gets the URI components

@param uri: The URI to ge split @return: collection, repo, rkey

func GetUserAuthData

func GetUserAuthData(handle string) (*string, *string, error)

This function is to get: the user DID and the user's PDS this should **ONLY** be used during authentication.

@results: userDID, userPDS, error

func GetUserInfo

func GetUserInfo(pds string, token string, screen_name string, nocache bool) (*bridge.TwitterUser, error)

func GetUsersInfo

func GetUsersInfo(pds string, token string, items []string, ignoreCache bool) ([]*bridge.TwitterUser, error)

func InitConfig

func InitConfig(config *config.Config)

func ResolveDIDFromHandle

func ResolveDIDFromHandle(handle string) (*string, error)

func ResolvePDSFromDID

func ResolvePDSFromDID(userDID string) (*string, error)

func SendRequest

func SendRequest(token *string, method string, url string, body io.Reader) (*http.Response, error)

func SendRequestWithContentType

func SendRequestWithContentType(token *string, method string, url string, body io.Reader, content_type string) (*http.Response, error)

func UpdateRecord

func UpdateRecord(pds string, token string, collection string, repo string, rkey string, swapRecord string, newRecord interface{}) error

Types

type AspectRatio

type AspectRatio struct {
	Height int `json:"height"`
	Width  int `json:"width"`
}

type AuthRequest

type AuthRequest struct {
	Identifier string `json:"identifier"`
	Password   string `json:"password"`
}

type AuthResponse

type AuthResponse struct {
	AccessJwt  string `json:"accessJwt"`
	RefreshJwt string `json:"refreshJwt"`
	DID        string `json:"did"`
}

func Authenticate

func Authenticate(username, password string) (*AuthResponse, *string, error)

func RefreshToken

func RefreshToken(pds string, refreshToken string) (*AuthResponse, error)

type Blob

type Blob struct {
	Type     string `json:"$type"`
	Ref      Ref    `json:"ref"`
	MimeType string `json:"mimeType"`
	Size     int    `json:"size"`
}

func UploadBlob

func UploadBlob(pds string, token string, data []byte, content_type string) (*Blob, error)

type Commit

type Commit struct {
	CID string `json:"cid"`
	Rev string `json:"rev"`
}

type CreatePostRecord

type CreatePostRecord struct {
	Type      string        `json:"$type"`
	Text      string        `json:"text"`
	CreatedAt FTime         `json:"createdAt"`
	Reply     *ReplySubject `json:"reply,omitempty"`
	Facets    []Facet       `json:"facets,omitempty"`
	Embed     *Embed        `json:"embed,omitempty"`
}

type CreateRecordPayload

type CreateRecordPayload struct {
	Collection string      `json:"collection"`
	Repo       string      `json:"repo"`
	Record     interface{} `json:"record"`
}

Reposting/Retweeting

type CreateRecordResult

type CreateRecordResult struct {
	Subject
	Commit           Commit `json:"commit"`
	ValidationStatus string `json:"validationStatus"`
}

type DIDDoc

type DIDDoc struct {
	// yes i know this isn't all of the fields, but it's good enuff
	Service []struct {
		ID              string `json:"id"`
		Type            string `json:"type"`
		ServiceEndpoint string `json:"serviceEndpoint"`
	} `json:"service"`
}

type DeleteRecordPayload

type DeleteRecordPayload struct {
	Collection string `json:"collection"`
	Repo       string `json:"repo"`
	RKey       string `json:"rkey"`
}

type Embed

type Embed struct {
	Type     string         `json:"$type"`
	Images   []Image        `json:"images,omitempty"`
	External *ExternalImage `json:"external,omitempty"`
	Media    *MoreImages    `json:"media,omitempty"`
	*Video   `json:",omitempty"`
}

type ExternalImage

type ExternalImage struct {
	Uri   string `json:"uri"`
	Thumb Blob   `json:"thumb"`
}

doesn't contain everything, but who cares

type FTime

type FTime struct {
	time.Time
}

func (*FTime) UnmarshalJSON

func (ct *FTime) UnmarshalJSON(b []byte) error

type Facet

type Facet struct {
	Features []Feature `json:"features"`
	Index    Index     `json:"index"`
}

type Feature

type Feature struct {
	Type string `json:"$type"`
	Tag  string `json:"tag"`
	Did  string `json:"did,omitempty"`
	Uri  string `json:"uri,omitempty"`
}

type Feed

type Feed struct {
	Post  Post `json:"post"`
	Reply struct {
		Root   Post `json:"root"`
		Parent Post `json:"parent"`
	} `json:"reply"`
	Reason      *PostReason `json:"reason"`
	FeedContext string      `json:"feedContext"`
}

type FollowersTimeline

type FollowersTimeline struct {
	Subject   User   `json:"subject"`
	Followers []User `json:"followers"`
	Cursor    string `json:"cursor"`
}

type FollowsTimeline

type FollowsTimeline struct {
	Subject   User   `json:"subject"`
	Followers []User `json:"follows"`
	Cursor    string `json:"cursor"`
}

type Image

type Image struct {
	Alt         string      `json:"alt"`
	AspectRatio AspectRatio `json:"aspectRatio"`
	Image       Blob        `json:"image"`
}

type Index

type Index struct {
	ByteEnd   int `json:"byteEnd"`
	ByteStart int `json:"byteStart"`
}

type ItemByWithDate

type ItemByWithDate struct {
	IndexedAt time.Time `json:"indexedAt"`
	CreatedAt FTime     `json:"createdAt"`
	Actor     User      `json:"actor"`
}

type Likes

type Likes struct {
	Subject
	Cursor string           `json:"cursor"`
	Likes  []ItemByWithDate `json:"likes"`
}

func GetPostLikes

func GetPostLikes(pds string, token string, uri string, limit int) (*Likes, error)

type ListDetailed

type ListDetailed struct {
	List   ListInfo   `json:"list"`
	Cursor string     `json:"cursor"`
	Items  []ListItem `json:"items"`
}

func GetList

func GetList(pds string, token string, listURI string, limit int, cursor string) (*ListDetailed, error)

type ListInfo

type ListInfo struct {
	URI     string `json:"uri"`
	CID     string `json:"cid"`
	Creator User   `json:"creator"`
	Name    string `json:"name"`

	Description       string     `json:"description"`
	DescriptionFacets []Facet    `json:"descriptionFacets"`
	Avatar            string     `json:"avatar"`
	ListItemCount     int        `json:"listItemCount"`
	IndexedAt         time.Time  `json:"indexedAt"`
	Viewer            PostViewer `json:"viewer"`
}

type ListItem

type ListItem struct {
	URI     string `json:"uri"`
	Subject User   `json:"subject"`
}

type Lists

type Lists struct {
	Lists  []ListInfo `json:"lists"`
	Cursor string     `json:"cursor"`
}

func GetUsersLists

func GetUsersLists(pds string, token string, actor string, limit int, cursor string) (*Lists, error)

type MoreImages

type MoreImages struct {
	Images []Image `json:"images,omitempty"`
}

type Notification

type Notification struct {
	URI           string                `json:"uri"`
	CID           string                `json:"cid"`
	Author        User                  `json:"author"`
	Reason        string                `json:"reason"`
	ReasonSubject string                `json:"reasonSubject"`
	Record        PostInteractionRecord `json:"record"` // i think this is the correct object?
	IsRead        bool                  `json:"isRead"`
	IndexedAt     time.Time             `json:"indexedAt"`
}

type Notifications

type Notifications struct {
	Notifications []Notification `json:"notifications"`
	Cursor        string         `json:"cursor"`
	Priority      bool           `json:"priority"`
	SeenAt        time.Time      `json:"seenAt"`
}

func GetMentions

func GetMentions(pds string, token string, limit int, context string) (*Notifications, error)

func GetNotifications

func GetNotifications(pds string, token string, limit int, context string) (*Notifications, error)

type OtherActorSuggestions

type OtherActorSuggestions struct {
	Actors []User `json:"suggestions"`
}

type Post

type Post struct {
	Subject
	Author User       `json:"author"`
	Record PostRecord `json:"record"`
	// Embed  Embed      `json:"embed"`
	ReplyCount  int        `json:"replyCount"`
	RepostCount int        `json:"repostCount"`
	LikeCount   int        `json:"likeCount"`
	QuoteCount  int        `json:"quoteCount"`
	IndexedAt   time.Time  `json:"indexedAt"`
	Viewer      PostViewer `json:"viewer"`
}

func PostSearch

func PostSearch(pds string, token string, query string, since *time.Time, until *time.Time) ([]Post, error)

type PostInteractionRecord

type PostInteractionRecord struct {
	Type      string      `json:"$type"`
	CreatedAt string      `json:"createdAt"`
	Subject   interface{} `json:"subject"`
}

type PostReason

type PostReason struct {
	Type      string    `json:"$type"`
	By        User      `json:"by"`
	IndexedAt time.Time `json:"indexedAt"`
}

Specifically for reposts

type PostRecord

type PostRecord struct {
	Type      string        `json:"$type"`
	CreatedAt FTime         `json:"createdAt"`
	Embed     Embed         `json:"embed,omitempty"`
	Facets    []Facet       `json:"facets,omitempty"`
	Langs     []string      `json:"langs,omitempty"`
	Text      string        `json:"text,omitempty"`
	Reply     *ReplySubject `json:"reply,omitempty"`
}

type PostSearchResult

type PostSearchResult struct {
	Posts     []Post `json:"posts"`
	HitsTotal int    `json:"hitsTotal"`
	Cursor    string `json:"cursor"`
}

type PostViewer

type PostViewer struct {
	Repost            *string `json:"repost"`
	Like              *string `json:"like"` // Can someone please tell me why this is a string.
	Muted             bool    `json:"muted"`
	BlockedBy         bool    `json:"blockedBy"`
	ThreadMute        bool    `json:"threadMute"`
	ReplyDisabled     bool    `json:"replyDisabled"`
	EmbeddingDisabled bool    `json:"embeddingDisabled"`
	Pinned            bool    `json:"pinned"`
}

type ProperSubjectInteractionRecord

type ProperSubjectInteractionRecord struct {
	Type      string  `json:"$type"`
	CreatedAt string  `json:"createdAt"`
	Subject   Subject `json:"subject"`
}

type RecordResponse

type RecordResponse struct {
	URI   string      `json:"uri"`
	CID   string      `json:"cid"`
	Value RecordValue `json:"value"`
}

func GetRecord

func GetRecord(pds string, collection string, repo string, rkey string) (*RecordResponse, error)

func GetRecordWithUri

func GetRecordWithUri(pds string, uri string) (*RecordResponse, error)

type RecordValue

type RecordValue struct {
	Reply       *ReplySubject `json:"reply,omitempty"`
	CreatedAt   FTime         `json:"createdAt,omitempty"`
	Description string        `json:"description,omitempty"`
	DisplayName string        `json:"displayName,omitempty"`
	Avatar      Blob          `json:"avatar,omitempty"`
}

type Ref

type Ref struct {
	Link string `json:"$link"`
}

type Relationships

type Relationships struct {
	DID        string `json:"did"`
	Following  string `json:"following"`
	FollowedBy string `json:"followedBy"`
}

type RelationshipsRes

type RelationshipsRes struct {
	Actor         string          `json:"actor"`
	Relationships []Relationships `json:"relationships"`
}

type ReplySubject

type ReplySubject struct {
	Root   Subject `json:"root"`
	Parent Subject `json:"parent"`
}

func GetReplyRefs

func GetReplyRefs(pds string, token string, parentURI string) (*ReplySubject, error)

thank you https://docs.bsky.app/blog/create-post#replies

type RepostedBy

type RepostedBy struct {
	Subject
	Cursor     string `json:"cursor"`
	RepostedBy []User `json:"repostedBy"`
}

func GetRetweetAuthors

func GetRetweetAuthors(pds string, token string, uri string, limit int) (*RepostedBy, error)

type Session

type Session struct {
	DID    string `json:"did"`
	Handle string `json:"handle"`
	Email  string `json:"email"`
}

func GetSession

func GetSession(pds string, token string) (*Session, error)

type Subject

type Subject struct {
	URI string `json:"uri"`
	CID string `json:"cid"`
}

type Thread

type Thread struct {
	Type    string    `json:"$type"`
	Post    Post      `json:"post"`
	Parent  *Thread   `json:"parent"`
	Replies *[]Thread `json:"replies"`
}

type ThreadRoot

type ThreadRoot struct {
	Thread Thread `json:"thread"`
}

This is solely for the purpose of unmarshalling the response from the API

func GetPost

func GetPost(pds string, token string, uri string, depth int, parentHeight int) (*ThreadRoot, error)

func LikePost

func LikePost(pds string, token string, id string, my_did string) (*ThreadRoot, error)

func ReTweet

func ReTweet(pds string, token string, id string, my_did string) (*ThreadRoot, *string, error)

func UnlikePost

func UnlikePost(pds string, token string, id string, my_did string) (*ThreadRoot, error)

func UpdateStatus

func UpdateStatus(pds string, token string, my_did string, status string, in_reply_to *string, mentions []bridge.FacetParsing, urls []bridge.FacetParsing, tags []bridge.FacetParsing, imageBlob *Blob, imageRes []int) (*ThreadRoot, error)

This handles both normal & replys

type Timeline

type Timeline struct {
	Feed   []Feed `json:"feed"`
	Cursor string `json:"cursor"`
}

func GetActorLikes

func GetActorLikes(pds string, token string, context string, actor string, limit int) (*Timeline, error)

https://docs.bsky.app/docs/api/app-bsky-feed-get-actor-likes Bluesky for SOME REASON limits viewing the likes to your own user. WHy? What is the point of having an "actor" field if you can only use 1 actor?"ADD THIS TO LOOKUP TABLE" I'm still gonna implement it, we can hope it will be expanded in the future.

func GetHotPosts

func GetHotPosts(pds string, token string, context string, feed string, limit int) (*Timeline, error)

https://docs.bsky.app/docs/api/app-bsky-feed-get-feed

func GetListTimeline

func GetListTimeline(pds string, token string, context string, listURI string, limit int) (*Timeline, error)

https://docs.bsky.app/docs/api/app-bsky-graph-get-list

func GetMediaTimeline

func GetMediaTimeline(pds string, token string, context string, actor string, limit int) (*Timeline, error)

func GetTimeline

func GetTimeline(pds string, token string, context string, feed string, limit int) (*Timeline, error)

https://docs.bsky.app/docs/api/app-bsky-feed-get-feed

type TrendingTopic

type TrendingTopic struct {
	Topic string `json:"topic"`
	Link  string `json:"link"`
}

type TrendingTopics

type TrendingTopics struct {
	Topics    []TrendingTopic `json:"topics"`
	Suggested []TrendingTopic `json:"suggested"`
}

func GetTrends

func GetTrends(pds string, token string) (*TrendingTopics, error)

This feature is still in beta, and is likely to break in the future

type UpdateRecordPayload

type UpdateRecordPayload struct {
	CreateRecordPayload
	RKey       string `json:"rkey"`
	SwapRecord string `json:"swapRecord"`
}

type User

type User struct {
	DID            string    `json:"did"`
	Handle         string    `json:"handle"`
	DisplayName    string    `json:"displayName"`
	Description    string    `json:"description"`
	Avatar         string    `json:"avatar"`
	Banner         string    `json:"banner"`
	FollowersCount int       `json:"followersCount"`
	FollowsCount   int       `json:"followsCount"`
	PostsCount     int       `json:"postsCount"`
	IndexedAt      time.Time `json:"indexedAt"`
	CreatedAt      FTime     `json:"createdAt"`
	Associated     struct {
		Lists        int      `json:"lists"`
		FeedGens     int      `json:"feedgens"`
		StarterPacks int      `json:"starterPacks"`
		Labeler      bool     `json:"labeler"`
		CreatedAt    FTime    `json:"created_at"`
		Chat         UserChat `json:"chat"`
	} `json:"associated"`
	Viewer struct {
		Muted bool `json:"muted"`
		// MutedByList
		BlockedBy bool    `json:"blockedBy"`
		Blocking  *string `json:"blocking,omitempty"`
		// BlockingByList
		Following  *string `json:"following,omitempty"`
		FollowedBy *string `json:"followedBy,omitempty"`
	} `json:"viewer"`
	Verification Verification `json:"verification"`
}

https://docs.bsky.app/docs/api/app-bsky-actor-get-profile

func FollowUser

func FollowUser(pds string, token string, targetActor string, my_did string) (*User, error)

func GetMySuggestedUsers

func GetMySuggestedUsers(pds string, token string, limit int) ([]User, error)

func GetOthersSuggestedUsers

func GetOthersSuggestedUsers(pds string, token string, limit int, actor string) ([]User, error)

func GetTopicSuggestedUsers

func GetTopicSuggestedUsers(pds string, token string, limit int, category string) ([]User, error)

func GetUserInfoRaw

func GetUserInfoRaw(pds string, token string, screen_name string) (*User, error)

func GetUsersInfoRaw

func GetUsersInfoRaw(pds string, token string, items []string, ignoreCache bool) ([]*User, error)

TODO: Combine this with GetUsersInfo... somehow

func UnfollowUser

func UnfollowUser(pds string, token string, targetActor string, my_did string) (*User, error)

func UserSearch

func UserSearch(pds string, token string, query string) ([]User, error)

func UserSearchAhead

func UserSearchAhead(pds string, token string, query string, limit int) ([]User, error)

exactly the same as usersearch but different i guess idk

type UserChat

type UserChat struct {
	AllowIncoming string `json:"allowIncoming"`
}

type UserSearchResult

type UserSearchResult struct {
	Actors []User `json:"actors"`
}

type Verification

type Verification struct {
	VerifiedStatus        string `json:"verifiedStatus"`
	TrustedVerifierStatus string `json:"trustedVerifierStatus"`
}

type Video

type Video struct {
	Alt         string      `json:"alt"`
	AspectRatio AspectRatio `json:"aspectRatio"`
	Video       *Blob       `json:"video"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL