content

package
v0.0.0-...-3a9e237 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: Apache-2.0, MIT Imports: 10 Imported by: 0

Documentation

Overview

Package content provides a client for the Longport Content OpenAPI. It covers community topics, replies, and related data.

Index

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.

See: https://open.longportapp.com/docs/api?op=create_topic

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

func (c *ContentContext) News(ctx context.Context, symbol string) (items []*NewsItem, err error)

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.

See: https://open.longportapp.com/docs/api?op=topic_detail

func (*ContentContext) Topics

func (c *ContentContext) Topics(ctx context.Context, symbol string) (items []*TopicItem, err error)

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}"
	Hashtags  []string // optional, max 5
}

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
	// Shares count
	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
	Hashtags      []string
	Images        []TopicImage
	LikesCount    int64
	CommentsCount int64
	ViewsCount    int64
	SharesCount   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

type TopicAuthor struct {
	MemberID string
	Name     string
	Avatar   string
}

TopicAuthor is the author of a topic or reply.

type TopicImage

type TopicImage struct {
	URL string
	Sm  string
	Lg  string
}

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
	// Shares count
	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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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