Documentation
ΒΆ
Overview ΒΆ
Package content provides a client for the Longbridge Content OpenAPI. It covers community topics, replies, and related data.
Index ΒΆ
- type ContentContext
- func (c *ContentContext) CreateTopic(ctx context.Context, opts *CreateTopicOptions) (string, error)
- func (c *ContentContext) CreateTopicReply(ctx context.Context, topicID string, opts *CreateReplyOptions) (*TopicReply, error)
- func (c *ContentContext) ListTopicReplies(ctx context.Context, topicID string, opts *ListTopicRepliesOptions) ([]*TopicReply, error)
- func (c *ContentContext) MyTopics(ctx context.Context, opts *MyTopicsOptions) ([]*OwnedTopic, error)
- func (c *ContentContext) News(ctx context.Context, symbol string) (items []*NewsItem, err error)
- func (c *ContentContext) TopicDetail(ctx context.Context, id string) (*OwnedTopic, error)
- func (c *ContentContext) Topics(ctx context.Context, symbol string) (items []*TopicItem, err error)
- type CreateReplyOptions
- type CreateTopicOptions
- type ListTopicRepliesOptions
- type MyTopicsOptions
- type NewsItem
- type OwnedTopic
- type TopicAuthor
- type TopicImage
- type TopicItem
- type TopicReply
Constants ΒΆ
This section is empty.
Variables ΒΆ
This section is empty.
Functions ΒΆ
This section is empty.
Types ΒΆ
type ContentContext ΒΆ
type ContentContext struct {
// contains filtered or unexported fields
}
ContentContext is a client for the Longbridge Content OpenAPI.
Example:
conf, err := config.NewFromEnv()
cctx, err := content.NewFromCfg(conf)
topics, err := cctx.MyTopics(context.Background(), &content.MyTopicsOptions{Size: 20})
func NewFromCfg ΒΆ
func NewFromCfg(cfg *config.Config) (*ContentContext, error)
NewFromCfg creates a ContentContext from a *config.Config.
func NewFromEnv ΒΆ
func NewFromEnv() (*ContentContext, error)
NewFromEnv returns a ContentContext configured from environment variables.
func (*ContentContext) CreateTopic ΒΆ added in v0.23.0
func (c *ContentContext) CreateTopic(ctx context.Context, opts *CreateTopicOptions) (string, error)
CreateTopic publishes a new community topic and returns the new topic ID.
func (*ContentContext) CreateTopicReply ΒΆ added in v0.23.0
func (c *ContentContext) CreateTopicReply(ctx context.Context, topicID string, opts *CreateReplyOptions) (*TopicReply, error)
CreateTopicReply posts a reply to a topic and returns the created reply.
See: https://open.longbridge.com/docs/api?op=create_topic_reply
func (*ContentContext) ListTopicReplies ΒΆ added in v0.23.0
func (c *ContentContext) ListTopicReplies(ctx context.Context, topicID string, opts *ListTopicRepliesOptions) ([]*TopicReply, error)
ListTopicReplies returns a paginated list of replies for a topic.
See: https://open.longbridge.com/docs/api?op=list_topic_replies
func (*ContentContext) MyTopics ΒΆ added in v0.23.0
func (c *ContentContext) MyTopics(ctx context.Context, opts *MyTopicsOptions) ([]*OwnedTopic, error)
MyTopics returns topics created by the currently authenticated user.
func (*ContentContext) News ΒΆ
News returns the news list for a symbol. Reference: https://open.longbridge.com/en/docs/quote/security/news
func (*ContentContext) TopicDetail ΒΆ added in v0.23.0
func (c *ContentContext) TopicDetail(ctx context.Context, id string) (*OwnedTopic, error)
TopicDetail returns the full details of a topic by ID.
func (*ContentContext) Topics ΒΆ
Topics returns the discussion topics list for a symbol. Reference: https://open.longbridge.com/en/docs/quote/security/topics
type CreateReplyOptions ΒΆ added in v0.23.0
type CreateReplyOptions struct {
Body string // required; plain text only
ReplyToID string // optional; ID of the reply to nest under; empty or "0" = top-level
}
CreateReplyOptions holds the parameters for posting a reply to a topic.
Body is plain text only β Markdown is not rendered. Stock symbols mentioned in Body (e.g. "700.HK", "TSLA.US") are automatically recognized and linked by the platform.
Permission: the authenticated user must hold a funded Longbridge account. Rate limit: first 3 replies per topic have no interval requirement; subsequent replies require incrementally longer waits (3 s β 5 s β 8 s β 13 s β 21 s β 34 s β 55 s cap).
type CreateTopicOptions ΒΆ added in v0.23.0
type CreateTopicOptions struct {
Title string // required for topic_type "article"; optional for "post"
Body string // required; plain text for "post", Markdown for "article"
TopicType string // optional: "post" (default) | "article"
Tickers []string // optional, max 10; format: "{symbol}.{market}"
}
CreateTopicOptions holds the parameters for creating a new topic.
Stock symbols mentioned in Body (e.g. "700.HK", "TSLA.US") are automatically recognized and linked by the platform. Use Tickers to associate additional symbols not mentioned in the body.
type ListTopicRepliesOptions ΒΆ added in v0.23.0
type ListTopicRepliesOptions struct {
Page int // optional, default 1
Size int // optional, default 20, range 1β50
}
ListTopicRepliesOptions holds optional pagination parameters for listing replies on a topic.
type MyTopicsOptions ΒΆ added in v0.23.0
type MyTopicsOptions struct {
Page int // optional, default 1
Size int // optional, default 50, range 1β500
TopicType string // optional: "article" | "post"; empty returns all
}
MyTopicsOptions holds optional parameters for listing topics created by the authenticated user.
type NewsItem ΒΆ
type NewsItem struct {
// News ID
Id string
// Title
Title string
// Description
Description string
// URL
Url string
// Published time
PublishedAt time.Time
// Comments count
CommentsCount int32
// Likes count
LikesCount int32
SharesCount int32
}
NewsItem is a news article for a security.
type OwnedTopic ΒΆ added in v0.23.0
type OwnedTopic struct {
ID string
Title string
Description string
Body string
Author TopicAuthor
Tickers []string
Images []TopicImage
LikesCount int64
CommentsCount int64
ViewsCount int64
TopicType string
DetailURL string
CreatedAt time.Time
UpdatedAt time.Time
}
OwnedTopic is a full topic record returned by the topic-detail and list-mine endpoints.
type TopicAuthor ΒΆ added in v0.23.0
TopicAuthor is the author of a topic or reply.
type TopicImage ΒΆ added in v0.23.0
TopicImage is an image attached to a topic or reply.
type TopicItem ΒΆ
type TopicItem struct {
// Topic ID
Id string
// Title
Title string
// Description
Description string
// URL
Url string
// Published time
PublishedAt time.Time
// Comments count
CommentsCount int32
// Likes count
LikesCount int32
SharesCount int32
}
TopicItem is a discussion topic for a security.
type TopicReply ΒΆ added in v0.23.0
type TopicReply struct {
ID string
TopicID string
Body string
ReplyToID string
Author TopicAuthor
Images []TopicImage
LikesCount int64
CommentsCount int64
CreatedAt time.Time
}
TopicReply is a reply on a topic.