salamoonder

package module
v0.0.0-...-2a406a4 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 15 Imported by: 0

README ΒΆ

Salamoonder SDK

A straightforward Go wrapper for Salamoonder's API, designed for easy integration and efficient usage. Perfect for solving captchas and bypassing bot detection on various platforms.

Go Version

Features

  • Simple and intuitive API
  • Support for multiple captcha types:
    • Akamai Web Sensor
    • Akamai SBSD (Sensor Based Script Detection)
    • Kasada protection bypass
    • DataDome (Slider & Interstitial)
    • Incapsula/Imperva
  • Built-in TLS fingerprinting with Chrome profiles
  • Comprehensive error handling and logging
  • Modern Go with proper error handling
  • Production-ready with proper session management
  • Concurrent task processing support

Installation

go get github.com/salamoonder/salamoonder-go

Requirements

  • Go >= 1.21

Quick Start

package main

import (
    "fmt"
    "log"
    
    "github.com/salamoonder/salamoonder-go"
)

func main() {
    client := salamoonder.New("YOUR_API_KEY")
    
    // Create and solve a Kasada captcha task
    taskID, err := client.Task.CreateTask("KasadaCaptchaSolver", map[string]interface{}{
        "pjs_url": "https://example.com/script.js",
        "cd_only": "false",
    })
    if err != nil {
        log.Fatal(err)
    }
    
    // Poll for the result
    solution, err := client.Task.GetTaskResult(taskID)
    if err != nil {
        log.Fatal(err)
    }
    
    fmt.Println("Solution:", solution)
}

Usage Examples

Akamai Web Sensor
// Configuration
const (
    URL        = "https://example.com/"
    USER_AGENT = `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36`
    API_KEY    = "sr-YOUR-KEY"
    PROXY      = ""
)

client := salamoonder.New(API_KEY)

akamaiData, err := client.Akamai.FetchAndExtract(URL, USER_AGENT, PROXY)
if err != nil {
    log.Printf("ERROR: Failed to retrieve Akamai data: %v", err)
    return
}

// Solve 3 sensors (requires 3 API calls, you pay per sensor)
data := ""
for i := 0; i < 3; i++ {
    taskID, err := client.Task.CreateTask("AkamaiWebSensorSolver", map[string]interface{}{
        "url":        akamaiData["base_url"],
        "abck":       akamaiData["abck"],
        "bmsz":       akamaiData["bm_sz"],
        "script":     akamaiData["script_data"],
        "sensor_url": akamaiData["akamai_url"],
        "user_agent": USER_AGENT,
        "count":      i,
        "data":       data,
    })
    
    result, err := client.Task.GetTaskResult(taskID)
    payload := result["payload"].(string)
    data = result["data"].(string)
    
    cookie, err := client.Akamai.PostSensor(
        akamaiData["akamai_url"].(string),
        payload, USER_AGENT, URL, PROXY,
    )
}

log.Printf("SUCCESS: Successfully solved Akamai on %s", URL)
Kasada
// Kasada Captcha Challenge (Login Example)
client := salamoonder.New("sr-YOUR-KEY")

taskID, err := client.Task.CreateTask("KasadaCaptchaSolver", map[string]interface{}{
    "pjs_url": "https://example.com/149e9513-01fa-4fb0-aad4-566afd725d1b/2d206a39-8ed7-437e-a3be-862e0f06eea3/p.js",
    "cd_only": "false",
})

result, err := client.Task.GetTaskResult(taskID)

headers := map[string]string{
    "x-kpsdk-cd":     result["x-kpsdk-cd"].(string),
    "x-kpsdk-ct":     result["x-kpsdk-ct"].(string),
    "user-agent":     result["user-agent"].(string),
    "content-type":   "application/json",
}

payload := map[string]interface{}{
    "UserName": "USERNAME",
    "Password": "PASSWORD",
}

response, err := client.PostJSON("https://example.com/auth/v2/customer/login", payload, headers, "")

// Kasada Payload  
data, err := client.Kasada.ParseKasadaScript(scriptURL, USER_AGENT, PROXY)
taskID, err = client.Task.CreateTask("KasadaPayloadSolver", map[string]interface{}{
    "url":            "https://example.com",
    "script_url":     data["script_url"],
    "script_content": data["script_content"],
})
result, err = client.Task.GetTaskResult(taskID)
postSolution, err := client.Kasada.PostPayload("https://example.com", result, USER_AGENT, PROXY, false)
DataDome
client := salamoonder.New("sr-YOUR-KEY")

// Slider captcha - Full workflow
headers := map[string]string{"User-Agent": USER_AGENT}
response, err := client.Get(URL, headers, PROXY)
cookies := response.Cookies["datadome"]

if cookies == "" {
    log.Println("No DataDome cookie found")
    return
}

constructedURL, err := client.Datadome.ParseSliderURL(string(response.Body), cookies, URL)

taskID, err := client.Task.CreateTask("DataDomeSliderSolver", map[string]interface{}{
    "captcha_url":  constructedURL,
    "user_agent":   USER_AGENT,
    "country_code": "ch",
})

result, err := client.Task.GetTaskResult(taskID)

// Parse solved cookie
cookieStr := result["cookie"].(string)
solvedCookie := strings.Split(strings.Split(cookieStr, "datadome=")[1], ";")[0]

client.SessionCookies.Set("datadome", solvedCookie, ".example.com")

// Validate bypass
response, err = client.Get(URL, headers, "")
if response.StatusCode == 200 {
    log.Printf("SUCCESS: Successfully bypassed DD Slider")
}

// Interstitial follows same pattern with ParseInterstitialURL
Direct Client Methods

For custom HTTP requests with TLS client impersonation:

client := salamoonder.New("YOUR_API_KEY")

// GET request
response, err := client.Get("https://example.com", 
    map[string]string{"User-Agent": "Custom UA"},
    "http://proxy:port",
)
if err != nil {
    log.Fatal(err)
}

// POST request
postResponse, err := client.Post("https://example.com/api",
    []byte(`{"key": "value"}`),
    map[string]string{"Content-Type": "application/json"},
    "",
)
if err != nil {
    log.Fatal(err)
}

API Reference

Salamoonder Struct

Main entry point for the library.

client := salamoonder.New("api_key")

Parameters:

  • apiKey (string) - Your Salamoonder API key (required)

Properties:

  • Task - Tasks API instance (recommended for solving captchas)
  • Akamai, AkamaiSBSD, Datadome, Kasada - Low-level solver instances (advanced use only)
  • SessionCookies - Session information and cookies

Methods:

  • Get(url, headers, proxy) - Make a GET request
  • Post(url, body, headers, proxy) - Make a POST request
  • PostBytes(url, body, headers, proxy) - Make a POST request with binary body

Supported Anti-Bot Solutions

πŸ”’ Kasada
  • Script extraction and parsing
  • Payload solving
  • Challenge submission
πŸ›‘οΈ Akamai Bot Manager
  • Web sensor data extraction
  • SBSD (Sensor Based Script Detection) support
  • Cookie management
πŸ” DataDome
  • Slider captcha URL parsing
  • Interstitial challenge support
πŸ”’ Incapsula/Imperva
  • Reese84 challenge solving
  • UTMVC cookie generation

Supported Captcha Types

  • KasadaCaptchaSolver
  • KasadaPayloadSolver
  • AkamaiWebSensorSolver
  • AkamaiSBSDSolver
  • DataDomeSliderSolver
  • DataDomeInterstitialSolver
  • IncapsulaReese84Solver
  • IncapsulaUTMVCSolver

Module Exports

You can import individual components if needed:

// Main class and main exports
import "github.com/salamoonder/salamoonder-go"

// Error types
// APIError and MissingAPIKeyError are exported from the main package

// For advanced/low-level operations only
// All utility structs (Akamai, AkamaiSBSD, Datadome, Kasada) are accessible
// through the main client instance

Note: The utility instances (Akamai, AkamaiSBSD, Datadome, Kasada) are for low-level operations. For most use cases, use the Tasks API through the main client.

Error Handling

import (
    "fmt"
    "log"
    
    "github.com/salamoonder/salamoonder-go"
)

func main() {
    client := salamoonder.New("YOUR_API_KEY")
    
    taskID, err := client.Task.CreateTask("KasadaCaptchaSolver", map[string]interface{}{
        "pjs_url": "https://example.com/script.js",
        "cd_only": "false",
    })
    
    if err != nil {
        if apiErr, ok := err.(*salamoonder.APIError); ok {
            fmt.Printf("API error: %s (Code: %d)\n", apiErr.Message, apiErr.StatusCode)
        } else if _, ok := err.(*salamoonder.MissingAPIKeyError); ok {
            fmt.Println("API key is required")
        } else {
            fmt.Printf("Unexpected error: %v\n", err)
        }
        return
    }
    
    result, err := client.Task.GetTaskResult(taskID)
    if err != nil {
        fmt.Printf("Task failed: %v\n", err)
        return
    }
    
    fmt.Printf("Success: %+v\n", result)
}

Configuration

Proxy Support
// All methods support proxy parameter
result, err := client.Akamai.FetchAndExtract(
    "https://example.com",
    "Mozilla/5.0...",
    "http://username:password@proxy.example.com:8080",
)

Logging

Enable debug logging to see detailed information:

import "log"

// The SDK uses structured logging with timestamps
// All operations are logged automatically with appropriate levels
// Format: YYYY-MM-DD HH:MM:SS - name - LEVEL - message

Performance Tips

  • Reuse the same client instance for multiple operations
  • Process multiple tasks concurrently with goroutines
  • Implement proper error handling and retries
// Good: Reuse client for multiple operations and process concurrently
client := salamoonder.New("YOUR_API_KEY")

var wg sync.WaitGroup
results := make(chan map[string]interface{}, len(taskIDs))

for _, taskID := range taskIDs {
    wg.Add(1)
    go func(id string) {
        defer wg.Done()
        result, err := client.Task.GetTaskResult(id)
        if err == nil {
            results <- result
        }
    }(taskID)
}

wg.Wait()
close(results)

// Process results
for result := range results {
    fmt.Printf("Result: %+v\n", result)
}

License

MIT - See LICENSE file for details

Support

For issues, feature requests, or questions, please visit:

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

View Source
const (
	LevelDEBUG   = 10
	LevelINFO    = 20
	LevelWARNING = 30
	LevelERROR   = 40
)
View Source
const (
	Version = "1.0.0"
	Author  = "Salamoonder"
	Email   = "support@salamoonder.com"
	License = "MIT"
)

Variables ΒΆ

View Source
var TaskFieldMap = map[string]TaskFieldMapping{
	"KasadaCaptchaSolver":        {Required: map[string]string{"pjs": "pjs_url", "cdOnly": "cd_only"}, Optional: nil},
	"KasadaPayloadSolver":        {Required: map[string]string{"url": "url", "script_content": "script_content"}, Optional: []string{"script_url"}},
	"Twitch_PublicIntegrity":     {Required: map[string]string{"access_token": "access_token", "proxy": "proxy"}, Optional: []string{"device_id", "client_id"}},
	"IncapsulaReese84Solver":     {Required: map[string]string{"website": "website", "submit_payload": "submit_payload"}, Optional: []string{"reese_url", "user_agent"}},
	"IncapsulaUTMVCSolver":       {Required: map[string]string{"website": "website"}, Optional: []string{"user_agent"}},
	"AkamaiWebSensorSolver":      {Required: map[string]string{"url": "url", "abck": "abck", "bmsz": "bmsz", "script": "script", "sensor_url": "sensor_url", "count": "count", "data": "data"}, Optional: []string{"user_agent"}},
	"AkamaiSBSDSolver":           {Required: map[string]string{"url": "url", "cookie": "cookie", "sbsd_url": "sbsd_url", "script": "script"}, Optional: []string{"user_agent"}},
	"DataDomeSliderSolver":       {Required: map[string]string{"captcha_url": "captcha_url", "challenge_page": "challenge_page", "user_agent": "user_agent"}, Optional: nil},
	"DataDomeInterstitialSolver": {Required: map[string]string{"captcha_url": "captcha_url", "challenge_page": "challenge_page", "user_agent": "user_agent"}, Optional: nil},
}

Functions ΒΆ

func ExtractSecChUa ΒΆ

func ExtractSecChUa(userAgent string) string

func IsAPIError ΒΆ

func IsAPIError(err error) bool

func IsMissingAPIKeyError ΒΆ

func IsMissingAPIKeyError(err error) bool

func SetLevel ΒΆ

func SetLevel(level int)

func SetLevelByName ΒΆ

func SetLevelByName(name string)

Types ΒΆ

type APIError ΒΆ

type APIError struct {
	Message string
}

func (*APIError) Error ΒΆ

func (e *APIError) Error() string

type AkamaiSBSD ΒΆ

type AkamaiSBSD struct {
	Client *SalamoonderSession
}

func NewAkamaiSBSD ΒΆ

func NewAkamaiSBSD(client *SalamoonderSession) *AkamaiSBSD

func (*AkamaiSBSD) FetchAndExtract ΒΆ

func (a *AkamaiSBSD) FetchAndExtract(websiteURL, userAgent string, proxy string) (map[string]string, error)

func (*AkamaiSBSD) PostSBSD ΒΆ

func (a *AkamaiSBSD) PostSBSD(sbsdPayload, postURL, userAgent, websiteURL string, proxy string) (map[string]string, error)

type AkamaiWeb ΒΆ

type AkamaiWeb struct {
	Client *SalamoonderSession
}

func NewAkamaiWeb ΒΆ

func NewAkamaiWeb(client *SalamoonderSession) *AkamaiWeb

func (*AkamaiWeb) FetchAndExtract ΒΆ

func (a *AkamaiWeb) FetchAndExtract(websiteURL, userAgent string, proxy string) (map[string]string, error)

func (*AkamaiWeb) PostSensor ΒΆ

func (a *AkamaiWeb) PostSensor(akamaiURL, sensorData, userAgent, websiteURL string, proxy string) (map[string]string, error)

type Datadome ΒΆ

type Datadome struct {
	Client *SalamoonderSession
}

func NewDatadome ΒΆ

func NewDatadome(client *SalamoonderSession) *Datadome

func (*Datadome) GetInterstitialChallenge ΒΆ

func (d *Datadome) GetInterstitialChallenge(html, dataDomeCookie, referer string, headers map[string]string, userAgent string) (map[string]interface{}, error)

func (*Datadome) GetSliderChallenge ΒΆ

func (d *Datadome) GetSliderChallenge(html, dataDomeCookie, referer string, headers map[string]string, userAgent string) (map[string]interface{}, error)

type Kasada ΒΆ

type Kasada struct {
	Client *SalamoonderSession
}

func NewKasada ΒΆ

func NewKasada(client *SalamoonderSession) *Kasada

func (*Kasada) ParseKasadaScript ΒΆ

func (k *Kasada) ParseKasadaScript(rawURL, userAgent string, proxy string) (map[string]string, error)

func (*Kasada) PostPayload ΒΆ

func (k *Kasada) PostPayload(rawURL string, solution *KasadaSolution, userAgent string, proxy string, mfc bool) (*KasadaPostResult, error)

type KasadaPostResult ΒΆ

type KasadaPostResult struct {
	Response map[string]interface{} `json:"response"`
	XKpsdkCT *string                `json:"x-kpsdk-ct"`
	XKpsdkR  *string                `json:"x-kpsdk-r"`
	XKpsdkST *string                `json:"x-kpsdk-st"`
	XKpsdkV  *string                `json:"x-kpsdk-v"`
	XKpsdkH  *string                `json:"x-kpsdk-h,omitempty"`
	XKpsdkFC *string                `json:"x-kpsdk-fc,omitempty"`
}

type KasadaSolution ΒΆ

type KasadaSolution struct {
	Headers map[string]string `json:"headers"`
	Payload string            `json:"payload"`
}

type Logger ΒΆ

type Logger struct {
	// contains filtered or unexported fields
}

func GetLogger ΒΆ

func GetLogger(name string) *Logger

func (*Logger) Debug ΒΆ

func (l *Logger) Debug(format string, args ...interface{})

func (*Logger) Error ΒΆ

func (l *Logger) Error(format string, args ...interface{})

func (*Logger) Info ΒΆ

func (l *Logger) Info(format string, args ...interface{})

func (*Logger) Warning ΒΆ

func (l *Logger) Warning(format string, args ...interface{})

type MissingAPIKeyError ΒΆ

type MissingAPIKeyError struct {
	Message string
}

func (*MissingAPIKeyError) Error ΒΆ

func (e *MissingAPIKeyError) Error() string

type RequestOptions ΒΆ

type RequestOptions struct {
	Headers     map[string]string
	Proxy       string
	JSON        interface{}
	Data        []byte
	Verify      *bool
	Impersonate string
}

type Response ΒΆ

type Response struct {
	StatusCode int
	Text       string
	Headers    map[string]string
	Cookies    *SessionCookies
	URL        string
}

func (*Response) JSON ΒΆ

func (r *Response) JSON(target interface{}) error

type Salamoonder ΒΆ

type Salamoonder struct {
	Task       *Tasks
	Akamai     *AkamaiWeb
	AkamaiSBSD *AkamaiSBSD
	Datadome   *Datadome
	Kasada     *Kasada
	// contains filtered or unexported fields
}

func New ΒΆ

func New(apiKey string) (*Salamoonder, error)

func NewWithOptions ΒΆ

func NewWithOptions(apiKey, baseURL, impersonate string) (*Salamoonder, error)

func (*Salamoonder) Get ΒΆ

func (s *Salamoonder) Get(url string, opts *RequestOptions) (*Response, error)

func (*Salamoonder) Post ΒΆ

func (s *Salamoonder) Post(url string, opts *RequestOptions) (*Response, error)

func (*Salamoonder) Session ΒΆ

func (s *Salamoonder) Session() *SalamoonderSession

type SalamoonderSession ΒΆ

type SalamoonderSession struct {
	APIKey      string
	BaseURL     string
	Impersonate string
	Headers     map[string]string
	Cookies     *SessionCookies
}

func NewSalamoonderSession ΒΆ

func NewSalamoonderSession(apiKey string, baseURL string, impersonate string) (*SalamoonderSession, error)

func (*SalamoonderSession) ClearHeaders ΒΆ

func (s *SalamoonderSession) ClearHeaders()

func (*SalamoonderSession) Get ΒΆ

func (s *SalamoonderSession) Get(rawURL string, opts *RequestOptions) (*Response, error)

func (*SalamoonderSession) Post ΒΆ

func (s *SalamoonderSession) Post(rawURL string, opts *RequestOptions) (*Response, error)

func (*SalamoonderSession) PostBytes ΒΆ

func (s *SalamoonderSession) PostBytes(rawURL string, data []byte, headers map[string]string, proxy string) (*Response, error)

type SessionCookies ΒΆ

type SessionCookies struct {
	// contains filtered or unexported fields
}

func NewSessionCookies ΒΆ

func NewSessionCookies() *SessionCookies

func (*SessionCookies) Clear ΒΆ

func (sc *SessionCookies) Clear()

func (*SessionCookies) Get ΒΆ

func (sc *SessionCookies) Get(name string) string

func (*SessionCookies) GetDict ΒΆ

func (sc *SessionCookies) GetDict() map[string]string

func (*SessionCookies) GetDictForURL ΒΆ

func (sc *SessionCookies) GetDictForURL(rawURL string) map[string]string

func (*SessionCookies) Set ΒΆ

func (sc *SessionCookies) Set(name, value, domain, path string)

type TaskFieldMapping ΒΆ

type TaskFieldMapping struct {
	Required map[string]string
	Optional []string
}

type Tasks ΒΆ

type Tasks struct {
	// contains filtered or unexported fields
}

func NewTasks ΒΆ

func NewTasks(client *SalamoonderSession) *Tasks

func (*Tasks) CreateTask ΒΆ

func (t *Tasks) CreateTask(taskType string, kwargs map[string]interface{}) (string, error)

func (*Tasks) GetTaskResult ΒΆ

func (t *Tasks) GetTaskResult(taskID string, interval int) (interface{}, error)

Jump to

Keyboard shortcuts

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