Documentation
¶
Overview ¶
Package youtube is Crawlora's YouTube API client for 14 endpoints, covering search, channels, videos, playlists, comments, captions, and transcripts. API documentation: https://crawlora.net/docs?utm_source=pkg.go.dev&utm_medium=referral&utm_campaign=platform-clients&utm_content=youtube-go-api-docs
Index ¶
- Constants
- func OperationIDs() []string
- type Client
- func (c *Client) Call(ctx context.Context, operationID string, params Params) (any, error)
- func (c *Client) Captions(ctx context.Context, params Params) (any, error)
- func (c *Client) ChannelPlaylists(ctx context.Context, params Params) (any, error)
- func (c *Client) ChannelSearch(ctx context.Context, params Params) (any, error)
- func (c *Client) ChannelShorts(ctx context.Context, params Params) (any, error)
- func (c *Client) ChannelVideos(ctx context.Context, params Params) (any, error)
- func (c *Client) Close() error
- func (c *Client) Comments(ctx context.Context, params Params) (any, error)
- func (c *Client) Playlist(ctx context.Context, params Params) (any, error)
- func (c *Client) Profile(ctx context.Context, params Params) (any, error)
- func (c *Client) Search(ctx context.Context, params Params) (any, error)
- func (c *Client) Suggest(ctx context.Context, params Params) (any, error)
- func (c *Client) Tag(ctx context.Context, params Params) (any, error)
- func (c *Client) Transcript(ctx context.Context, params Params) (any, error)
- func (c *Client) TranscriptLanguages(ctx context.Context, params Params) (any, error)
- func (c *Client) Video(ctx context.Context, params Params) (any, error)
- type Params
Examples ¶
Constants ¶
const ( DefaultBaseURL = "https://api.crawlora.net/api/v1" Version = "0.2.0" )
const OperationCount = 14
OperationCount reports how many selected-platform operations this module exposes.
Variables ¶
This section is empty.
Functions ¶
func OperationIDs ¶
func OperationIDs() []string
OperationIDs returns the selected operation IDs in stable sorted order.
Types ¶
type Client ¶
Client calls only the operation IDs included in this platform module.
func NewClient ¶
NewClient creates a client using the supplied API key, or CRAWLORA_API_KEY when empty.
func (*Client) Call ¶
Call executes a selected platform operation by operation ID.
Example ¶
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("Content-Type", "application/json")
_, _ = w.Write([]byte(`{"ok":true}`))
}))
defer server.Close()
client := NewClient("your-crawlora-api-key")
client.BaseURL = server.URL + "/api/v1"
client.HTTPClient = server.Client()
result, err := client.Call(context.Background(), "youtube-captions", Params{"id": "sample-id"})
if err != nil {
panic(err)
}
fmt.Println(result.(map[string]any)["ok"])
Output: true
func (*Client) ChannelPlaylists ¶
ChannelPlaylists calls the youtube-channel-playlists operation.
func (*Client) ChannelSearch ¶
ChannelSearch calls the youtube-channel-search operation.
func (*Client) ChannelShorts ¶
ChannelShorts calls the youtube-channel-shorts operation.
func (*Client) ChannelVideos ¶
ChannelVideos calls the youtube-channel-videos operation.
func (*Client) Transcript ¶
Transcript calls the youtube-transcript operation.
func (*Client) TranscriptLanguages ¶
TranscriptLanguages calls the youtube-transcript-languages operation.