yougopher

module
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: MIT

README

Yougopher

Go Reference codecov Go Report Card

A YouTube API toolkit in Go focused on live chat bot functionality.

Installation

go get github.com/Its-donkey/yougopher

Features

  • OAuth 2.0 - Authorization code flow, device flow, service accounts
  • Quota Tracking - Built-in YouTube API quota management
  • Data API - Videos, channels, playlists, search, comments, subscriptions
  • Live Streaming - Live chat polling, moderation, broadcasts, stream management
  • Analytics - Channel statistics, views, demographics, revenue
  • Caching - In-memory cache with TTL support
  • Middleware - Logging, retry, metrics, rate limiting

Requirements

  • Go 1.23 or later
  • YouTube Data API v3 credentials

Quick Start

package main

import (
    "context"
    "log"

    "github.com/Its-donkey/yougopher/youtube/auth"
    "github.com/Its-donkey/yougopher/youtube/core"
    "github.com/Its-donkey/yougopher/youtube/streaming"
)

func main() {
    ctx := context.Background()

    // Initialize clients
    client := core.NewClient()
    authClient := auth.NewAuthClient(auth.Config{
        ClientID:     "your-client-id",
        ClientSecret: "your-client-secret",
        RedirectURL:  "http://localhost:8080/callback",
    })

    // Create chat bot
    bot, err := streaming.NewChatBotClient(client, authClient, "live-chat-id")
    if err != nil {
        log.Fatal(err)
    }

    // Register message handler
    bot.OnMessage(func(msg *streaming.ChatMessage) {
        log.Printf("[%s] %s", msg.Author.DisplayName, msg.Message)
    })

    // Connect and start listening
    if err := bot.Connect(ctx); err != nil {
        log.Fatal(err)
    }
    defer bot.Close()

    select {} // Keep running
}

Packages

Package Description
youtube/core HTTP client, errors, quota tracking, cache, middleware
youtube/auth OAuth 2.0 flows, device flow, service accounts, token management
youtube/streaming Live chat bot, polling, moderation, broadcasts
youtube/data Videos, channels, playlists, search, comments, subscriptions
youtube/analytics YouTube Analytics API (channel stats, demographics, revenue)

Documentation

Example Projects

See docs/examples/ for complete working applications:

License

MIT License - see LICENSE for details.

Directories

Path Synopsis
docs
examples/analytics command
Example: Analytics Dashboard
Example: Analytics Dashboard
examples/chatbot command
Example: Basic Chat Bot
Example: Basic Chat Bot
examples/modbot command
Example: Moderation Bot
Example: Moderation Bot
youtube
analytics
Package analytics provides access to the YouTube Analytics API.
Package analytics provides access to the YouTube Analytics API.
auth
Package auth provides OAuth 2.0 authentication for YouTube APIs.
Package auth provides OAuth 2.0 authentication for YouTube APIs.
core
Package core provides the base HTTP client, error types, quota tracking, caching, and middleware for interacting with YouTube APIs.
Package core provides the base HTTP client, error types, quota tracking, caching, and middleware for interacting with YouTube APIs.
data
Package data provides access to the YouTube Data API v3.
Package data provides access to the YouTube Data API v3.
streaming
Package streaming provides live chat bot functionality for YouTube Live.
Package streaming provides live chat bot functionality for YouTube Live.

Jump to

Keyboard shortcuts

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