Skip to content

Posts Service ​

go
type PostsService struct{ ... }

func NewPostsService(client builder.TransportProvider) *PostsService

Access via client.Posts().

Methods ​

MethodSignatureHTTP
Get(ctx, blogId, postId) (*schemas.Post, error)GET /v3/blogs/{blogId}/posts/{postId}
List(ctx, blogId, opts...) (*schemas.PostList, error)GET /v3/blogs/{blogId}/posts
Search(ctx, blogId, q, opts...) (*schemas.PostList, error)GET .../posts/search?q=
GetByPath(ctx, blogId, path, opts...) (*schemas.Post, error)GET .../posts/bypath?path=
Insert(ctx, blogId, body *schemas.Post) (*schemas.Post, error)POST /v3/blogs/{blogId}/posts
Update(ctx, blogId, postId, body) (*schemas.Post, error)PUT .../posts/{postId}
Patch(ctx, blogId, postId, body) (*schemas.Post, error)PATCH .../posts/{postId}
Delete(ctx, blogId, postId) errorDELETE .../posts/{postId}
Publish(ctx, blogId, postId) (*schemas.Post, error)POST .../posts/{postId}/publish
Revert(ctx, blogId, postId) (*schemas.Post, error)POST .../posts/{postId}/revert

Options ​

go
type PostOption func(*builder.Builder)
OptionQuery parameterDescription
WithPageToken(t)pageTokenContinue from a cursor
WithMaxResults(n)maxResultsPage size cap
WithStartDate(d)startDateRFC 3339 lower bound
WithEndDate(d)endDateRFC 3339 upper bound
WithStatus(s)statusLIVE, DRAFT, SCHEDULED, SOFT_TRASHED
WithLabels(...labels)labelsComma-joined label filter
WithFetchImages(b)fetchImagesInclude images
WithFetchBody(b)fetchBodyInclude body content
WithOrderBy(o)orderByPUBLISHED, UPDATED
WithSortOrder(o)sortOptionDESCENDING, ASCENDING
WithView(v)viewAccess level
WithMaxComments(n)maxCommentsComments included per post
WithPostDate(d)dateDisambiguate by-path lookups
WithQuery(q)qSearch query

Status Constants ​

go
const (
    PostStatusLive        = "LIVE"
    PostStatusDraft       = "DRAFT"
    PostStatusScheduled   = "SCHEDULED"
    PostStatusSoftTrashed = "SOFT_TRASHED"
)