Documentation
¶
Overview ¶
Package misarblog is the official Go client for the Misar.Blog developer API.
Base URL is https://api.misar.io/blog/v1 — the blog gateway strips /api, so request paths never carry an /api prefix. Authenticate with a developer key (mbk_...) or an OAuth 2.1 access token, sent as a Bearer token.
blog := misarblog.New("mbk_...")
me, err := blog.Me.Get(context.Background())
Index ¶
- Constants
- func EmbedURL(username, slug, theme string) string
- type AIResource
- type APIError
- type AddToSeriesRequest
- type AnalyticsResource
- type AnalyticsSummary
- type Article
- type ArticleListResult
- type ArticleReactions
- type ArticleSummary
- type ArticlesResource
- func (r *ArticlesResource) CreateDraft(ctx context.Context, req *CreateDraftRequest) (*MutateArticleResult, error)
- func (r *ArticlesResource) Get(ctx context.Context, slug string) (*Article, error)
- func (r *ArticlesResource) List(ctx context.Context, p *ListArticlesParams) (*ArticleListResult, error)
- func (r *ArticlesResource) Publish(ctx context.Context, req *PublishArticleRequest) (*MutateArticleResult, error)
- func (r *ArticlesResource) Recommendations(ctx context.Context, articleID string, limit int) (*RecommendationsResult, error)
- func (r *ArticlesResource) Search(ctx context.Context, p *SearchParams) (*SearchResult, error)
- func (r *ArticlesResource) Update(ctx context.Context, slug string, req *UpdateArticleRequest) (*MutateArticleResult, error)
- type Client
- type Comment
- type CommentAuthor
- type CommentsResource
- type CommentsResult
- type CompleteRequest
- type CompletionResponse
- type CreateDraftRequest
- type CreateSeriesRequest
- type FollowStatus
- type FollowsResource
- type GenerateImageRequest
- type GeneratedImage
- type ImagesResource
- type ListArticlesParams
- type MeResource
- type MutateArticleResult
- type NetworkError
- type Option
- type Plan
- type PlanLimitError
- type PlanResource
- type Profile
- type PublishArticleRequest
- type ReactionCounts
- type ReactionMutationResult
- type ReactionsResource
- func (r *ReactionsResource) Add(ctx context.Context, articleID, reactionType string) (*ReactionMutationResult, error)
- func (r *ReactionsResource) Get(ctx context.Context, articleID string) (*ArticleReactions, error)
- func (r *ReactionsResource) Remove(ctx context.Context, articleID, reactionType string) (*ReactionMutationResult, error)
- type RecommendationsResult
- type SearchParams
- type SearchResult
- type Series
- type SeriesListResult
- type SeriesResource
- type StartTrialRequest
- type TitleResult
- type TitlesRequest
- type TitlesResponse
- type TokenResult
- type TrialResource
- type TrialStatus
- type UpdateArticleRequest
- type UpsellFunnelParams
- type UpsellFunnelResource
Constants ¶
const EMBED_BASE = "https://misar.blog"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AIResource ¶
type AIResource struct {
// contains filtered or unexported fields
}
func (*AIResource) Complete ¶
func (r *AIResource) Complete(ctx context.Context, req *CompleteRequest) (*CompletionResponse, error)
func (*AIResource) Titles ¶
func (r *AIResource) Titles(ctx context.Context, req *TitlesRequest) (*TitlesResponse, error)
type APIError ¶
type APIError struct {
Status int `json:"-"`
Message string `json:"error"`
RequiredScope string `json:"required_scope,omitempty"` // present on 403 scope failures
GrantedScopes []string `json:"granted_scopes,omitempty"` // present on 403 scope failures
}
APIError is returned when the Misar.Blog API responds with a non-2xx status.
type AddToSeriesRequest ¶
type AnalyticsResource ¶
type AnalyticsResource struct {
// contains filtered or unexported fields
}
func (*AnalyticsResource) Summary ¶
func (r *AnalyticsResource) Summary(ctx context.Context, days int) (*AnalyticsSummary, error)
type AnalyticsSummary ¶
type Article ¶
type Article struct {
ArticleSummary
ContentMarkdown *string `json:"content_markdown"`
ContentHTML *string `json:"content_html"`
Visibility string `json:"visibility"`
UpdatedAt *string `json:"updated_at"`
ReadCount int `json:"read_count"`
FeaturedImage *string `json:"featured_image_url"`
EditorURL string `json:"editor_url"`
}
type ArticleListResult ¶
type ArticleListResult struct {
Articles []ArticleSummary `json:"articles"`
Total int `json:"total"`
}
type ArticleReactions ¶
type ArticleReactions struct {
ArticleID string `json:"article_id"`
Counts ReactionCounts `json:"counts"`
Total int `json:"total"`
UserReactions []string `json:"user_reactions"`
}
type ArticleSummary ¶
type ArticleSummary struct {
ID string `json:"id"`
Slug string `json:"slug"`
Title string `json:"title"`
Excerpt *string `json:"excerpt"`
Status string `json:"status"`
Tags []string `json:"tags"`
PublishedAt *string `json:"published_at"`
CreatedAt string `json:"created_at"`
ViewCount int `json:"view_count"`
IsPremium bool `json:"is_premium"`
PriceCents int `json:"price_cents"`
URL string `json:"url"`
}
type ArticlesResource ¶
type ArticlesResource struct {
// contains filtered or unexported fields
}
func (*ArticlesResource) CreateDraft ¶
func (r *ArticlesResource) CreateDraft(ctx context.Context, req *CreateDraftRequest) (*MutateArticleResult, error)
func (*ArticlesResource) List ¶
func (r *ArticlesResource) List(ctx context.Context, p *ListArticlesParams) (*ArticleListResult, error)
func (*ArticlesResource) Publish ¶
func (r *ArticlesResource) Publish(ctx context.Context, req *PublishArticleRequest) (*MutateArticleResult, error)
func (*ArticlesResource) Recommendations ¶
func (r *ArticlesResource) Recommendations(ctx context.Context, articleID string, limit int) (*RecommendationsResult, error)
func (*ArticlesResource) Search ¶
func (r *ArticlesResource) Search(ctx context.Context, p *SearchParams) (*SearchResult, error)
func (*ArticlesResource) Update ¶
func (r *ArticlesResource) Update(ctx context.Context, slug string, req *UpdateArticleRequest) (*MutateArticleResult, error)
type Client ¶
type Client struct {
Articles *ArticlesResource
AI *AIResource
Images *ImagesResource
Analytics *AnalyticsResource
Me *MeResource
Plan *PlanResource
Reactions *ReactionsResource
Series *SeriesResource
Comments *CommentsResource
Follows *FollowsResource
Trial *TrialResource
UpsellFunnel *UpsellFunnelResource
// contains filtered or unexported fields
}
type Comment ¶
type Comment struct {
ID string `json:"id"`
ArticleID string `json:"article_id"`
UserID string `json:"user_id"`
ParentID *string `json:"parent_id"`
Content string `json:"content"`
IsEdited bool `json:"is_edited"`
IsHidden bool `json:"is_hidden"`
ReplyCount int `json:"reply_count"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
User CommentAuthor `json:"user"`
// Replies is nested one level deep; nil on reply objects themselves.
Replies []Comment `json:"replies,omitempty"`
}
type CommentAuthor ¶
type CommentsResource ¶
type CommentsResource struct {
// contains filtered or unexported fields
}
func (*CommentsResource) List ¶
func (r *CommentsResource) List(ctx context.Context, articleID string, limit, offset int) (*CommentsResult, error)
List returns an article's comment thread, newest first, with replies nested one level deep. limit defaults to 20 (max 100) and offset to 0 when zero.
type CommentsResult ¶
type CompleteRequest ¶
type CompletionResponse ¶
type CreateDraftRequest ¶
type CreateSeriesRequest ¶
type FollowStatus ¶
type FollowsResource ¶
type FollowsResource struct {
// contains filtered or unexported fields
}
func (*FollowsResource) Status ¶
func (r *FollowsResource) Status(ctx context.Context, userID string) (*FollowStatus, error)
Status returns a profile's follower/following counts plus whether the key's owner follows it.
type GenerateImageRequest ¶
type GeneratedImage ¶
type ImagesResource ¶
type ImagesResource struct {
// contains filtered or unexported fields
}
func (*ImagesResource) Generate ¶
func (r *ImagesResource) Generate(ctx context.Context, req *GenerateImageRequest) (*GeneratedImage, error)
type ListArticlesParams ¶
type ListArticlesParams struct {
Status string // draft|published|scheduled|archived|flagged|all
Visibility string // public|subscribers|paid|private|webhook_only
WebhookOnly *bool
Sort string // newest|views
Limit int
}
ListArticlesParams are the optional filters for ArticlesResource.List.
type MeResource ¶
type MeResource struct {
// contains filtered or unexported fields
}
type MutateArticleResult ¶
type MutateArticleResult struct {
ID string `json:"id"`
Slug string `json:"slug"`
Title string `json:"title"`
Status string `json:"status"`
URL string `json:"url,omitempty"`
EditorURL string `json:"editor_url,omitempty"`
PublishedAt *string `json:"published_at,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
}
type NetworkError ¶
NetworkError wraps a transport-level failure (the request never reached the API).
func (*NetworkError) Error ¶
func (e *NetworkError) Error() string
func (*NetworkError) Unwrap ¶
func (e *NetworkError) Unwrap() error
type Option ¶
type Option func(*Client)
func WithBaseURL ¶
WithBaseURL overrides the API base (default https://api.misar.io/blog/v1).
func WithHTTPClient ¶
WithHTTPClient injects a custom *http.Client (used by tests).
func WithMaxRetries ¶
WithMaxRetries sets the total number of attempts for 429/5xx and transport errors.
func WithTimeout ¶
WithTimeout sets the per-request timeout.
type PlanLimitError ¶
type PlanLimitError struct {
Status int
// Message is the human-readable headline plus call-to-action.
Message string
// Plan is the account's current plan slug.
Plan string
// UpgradeURL points at the pricing page for this account.
UpgradeURL string
// RetryAfter is seconds until the allowance resets, 0 when not supplied.
RetryAfter int
// Upgrade is the full upgrade offer from the response body.
Upgrade map[string]any
}
PlanLimitError is returned when the subscription attached to the API key blocks the call. The API signals this with code "plan_limit_exceeded" and answers 429 when a metered allowance is exhausted (retryable once the period rolls over) or 402 when the feature is locked outright.
It is surfaced as a distinct type rather than a generic 429 because retrying cannot help until the allowance resets or the plan changes — the SDK stops retrying as soon as it sees this code.
func (*PlanLimitError) Error ¶
func (e *PlanLimitError) Error() string
type PlanResource ¶
type PlanResource struct {
// contains filtered or unexported fields
}
type PublishArticleRequest ¶
type PublishArticleRequest struct {
Title string `json:"title"`
BodyMarkdown string `json:"body_markdown"`
Tags []string `json:"tags,omitempty"`
CoverImageURL string `json:"cover_image_url,omitempty"`
ScheduleAt string `json:"schedule_at,omitempty"`
Visibility string `json:"visibility,omitempty"`
}
PublishArticleRequest is the body for ArticlesResource.Publish.
type ReactionCounts ¶
type ReactionMutationResult ¶
type ReactionsResource ¶
type ReactionsResource struct {
// contains filtered or unexported fields
}
func (*ReactionsResource) Add ¶
func (r *ReactionsResource) Add(ctx context.Context, articleID, reactionType string) (*ReactionMutationResult, error)
func (*ReactionsResource) Get ¶
func (r *ReactionsResource) Get(ctx context.Context, articleID string) (*ArticleReactions, error)
func (*ReactionsResource) Remove ¶
func (r *ReactionsResource) Remove(ctx context.Context, articleID, reactionType string) (*ReactionMutationResult, error)
type RecommendationsResult ¶
type SearchParams ¶
type SearchResult ¶
type SeriesListResult ¶
type SeriesListResult struct {
Series []Series `json:"series"`
}
type SeriesResource ¶
type SeriesResource struct {
// contains filtered or unexported fields
}
func (*SeriesResource) AddArticle ¶
func (r *SeriesResource) AddArticle(ctx context.Context, slug string, req *AddToSeriesRequest) (map[string]any, error)
func (*SeriesResource) Create ¶
func (r *SeriesResource) Create(ctx context.Context, req *CreateSeriesRequest) (*Series, error)
func (*SeriesResource) List ¶
func (r *SeriesResource) List(ctx context.Context) (*SeriesListResult, error)
type StartTrialRequest ¶
type TitleResult ¶
type TitlesRequest ¶
type TitlesResponse ¶
type TitlesResponse struct {
Titles []TitleResult `json:"titles"`
Raw string `json:"raw"`
}
type TokenResult ¶
func RefreshToken ¶
func RefreshToken(token, baseURL string) (*TokenResult, error)
type TrialResource ¶
type TrialResource struct {
// contains filtered or unexported fields
}
func (*TrialResource) Start ¶
func (r *TrialResource) Start(ctx context.Context, req *StartTrialRequest) (map[string]any, error)
func (*TrialResource) Status ¶
func (r *TrialResource) Status(ctx context.Context) (*TrialStatus, error)
type TrialStatus ¶
type UpdateArticleRequest ¶
type UpdateArticleRequest struct {
Title *string `json:"title,omitempty"`
BodyMarkdown *string `json:"body_markdown,omitempty"`
Tags *[]string `json:"tags,omitempty"`
Publish *bool `json:"publish,omitempty"`
}
UpdateArticleRequest is the body for ArticlesResource.Update. Use pointers so zero values are distinguishable from "unset".
type UpsellFunnelParams ¶
type UpsellFunnelResource ¶
type UpsellFunnelResource struct {
// contains filtered or unexported fields
}
func (*UpsellFunnelResource) Get ¶
func (r *UpsellFunnelResource) Get(ctx context.Context, p *UpsellFunnelParams) (map[string]any, error)