sociopath

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: Apache-2.0 Imports: 68 Imported by: 0

Documentation

Overview

Package sociopath provides a unified API for fetching social media profiles.

Basic usage:

profile, err := sociopath.Fetch(ctx, "https://mastodon.social/@johndoe")
if err != nil {
    log.Fatal(err)
}
fmt.Println(profile.Name, profile.Bio)

For platforms requiring authentication (LinkedIn, Twitter):

profile, err := sociopath.Fetch(ctx, "https://linkedin.com/in/johndoe",
    sociopath.WithCookies(map[string]string{"li_at": "...", "JSESSIONID": "..."}))

Or use platform packages directly:

import "github.com/codeGROOVE-dev/sociopath/pkg/linkedin"
client, _ := linkedin.New(ctx, linkedin.WithBrowserCookies())
profile, _ := client.Fetch(ctx, "https://linkedin.com/in/johndoe")

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAuthRequired    = profile.ErrAuthRequired
	ErrNoCookies       = profile.ErrNoCookies
	ErrProfileNotFound = profile.ErrProfileNotFound
	ErrRateLimited     = profile.ErrRateLimited
)

Re-export common errors.

Functions

func Fetch

func Fetch(ctx context.Context, url string, opts ...Option) (*profile.Profile, error)

Fetch retrieves a profile from the given URL. The platform is automatically detected from the URL.

func FetchEmail added in v0.7.8

func FetchEmail(ctx context.Context, emails []string, opts ...Option) ([]*profile.Profile, error)

FetchEmail fetches profiles from email-based services (Gravatar, Mail.ru, Google, GitHub). It returns all profiles found for the given email addresses.

func FetchEmailRecursive added in v0.7.9

func FetchEmailRecursive(ctx context.Context, emails []string, opts ...Option) ([]*profile.Profile, error)

FetchEmailRecursive fetches profiles from email-based services and recursively follows links.

func FetchRecursive

func FetchRecursive(ctx context.Context, url string, opts ...Option) ([]*profile.Profile, error)

FetchRecursive fetches a profile and recursively fetches all social links found. It deduplicates by URL and skips same-platform links for single-account platforms.

func FetchRecursiveWithGuess

func FetchRecursiveWithGuess(ctx context.Context, url string, opts ...Option) ([]*profile.Profile, error)

FetchRecursiveWithGuess is like FetchRecursive but also guesses related profiles based on discovered usernames. Guessed profiles are marked with IsGuess=true and include confidence scores.

func GuessFromUsername

func GuessFromUsername(ctx context.Context, username string, opts ...Option) ([]*profile.Profile, error)

GuessFromUsername guesses profiles across platforms based on a username. It creates a synthetic profile with the username and searches for matching profiles on supported platforms. All returned profiles are marked with IsGuess=true and include confidence scores.

func PlatformForURL

func PlatformForURL(url string) string

PlatformForURL returns the platform name for a URL, or "website" if unknown. This uses the platform registry for matching.

Types

type HTTPCache

type HTTPCache = httpcache.Cache

HTTPCache re-exports httpcache.Cache for convenience.

type Option

type Option func(*config)

Option configures a Fetch call.

func WithBrowserCookies

func WithBrowserCookies() Option

WithBrowserCookies enables reading cookies from browser stores.

func WithCookies

func WithCookies(cookies map[string]string) Option

WithCookies sets explicit cookie values for authenticated platforms.

func WithEmailHints added in v0.7.8

func WithEmailHints(emails ...string) Option

WithEmailHints provides email addresses to associate with profiles. These emails are stored in Fields["email_hints"] and can be used for additional lookups (Gravatar, Google GAIA ID resolution, etc.).

func WithGitHubToken added in v0.5.1

func WithGitHubToken(token string) Option

WithGitHubToken sets the GitHub API token for authenticated requests.

func WithHTTPCache

func WithHTTPCache(cache httpcache.Cacher) Option

WithHTTPCache sets the HTTP cache for responses.

func WithLogger

func WithLogger(logger *slog.Logger) Option

WithLogger sets a custom logger.

type Profile

type Profile = profile.Profile

Profile re-exports profile.Profile for convenience.

Jump to

Keyboard shortcuts

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