Documentation
¶
Overview ¶
Package content provides a client for the Longport 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 Longport 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 ¶
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 ¶
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.longportapp.com/docs/api?op=create_topic_reply
func (*ContentContext) ListTopicReplies ¶
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.longportapp.com/docs/api?op=list_topic_replies
func (*ContentContext) MyTopics ¶
func (c *ContentContext) MyTopics(ctx context.Context, opts *MyTopicsOptions) ([]*OwnedTopic, error)
MyTopics returns topics created by the currently authenticated user.
See: https://open.longportapp.com/docs/api?op=list_my_topics
func (*ContentContext) News ¶
News returns the news list for a symbol. Reference: https://open.longportapp.com/en/docs/quote/security/news
func (*ContentContext) TopicDetail ¶
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.longportapp.com/en/docs/quote/security/topics
type CreateReplyOptions ¶
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 Longport 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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
TopicAuthor is the author of a topic or reply.
type TopicImage ¶
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 ¶
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.