Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

amazon-scraper-api-sdk-go

Go Reference Go Report Card license

Official Go client for Amazon Scraper API. Pay only for successful (2xx) responses — non-2xx never cost you anything. Pricing starts at $0.90 per 1,000 requests on pay-as-you-go, drops to a flat $0.50 per 1,000 requests on Custom plans. 1,000 free requests on signup, no card. Idiomatic Go types, context-aware cancellation, works with the standard net/http client under the hood.

Benchmark (live production, 2026-04)

Measured on our own infrastructure against a 30-query mixed international set:

Metric Value
Median latency (product, US) ~2.6 s
P95 latency ~6 s
P99 latency ~10.5 s
Price / 1,000 Amazon products $0.50 flat
Concurrent threads (entry paid plan) 50
Marketplaces supported 20+
Billing unit per successful (2xx) response

Install

go get github.com/ChocoData-com/amazon-scraper-api-sdk-go

Requires Go >= 1.21.

Quick start - single product

package main

import (
    "context"
    "fmt"
    "log"
    "os"

    amz "github.com/ChocoData-com/amazon-scraper-api-sdk-go"
)

func main() {
    client := amz.New(os.Getenv("ASA_API_KEY"))
    ctx := context.Background()

    product, err := client.Product(ctx, amz.ProductParams{
        Query:  "B09HN3Q81F",
        Domain: "com",
    })
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(product["title"])
    // LEGEND COOKWARE 5-Ply Stainless Steel Cookware Set, 14-Piece...
    fmt.Println(product["price"], product["currency"])
    // 549.99 USD
}

Example output (trimmed, ~55 fields in total)

map[string]any{
    "asin":                "B09HN3Q81F",
    "title":               "LEGEND COOKWARE 5-Ply Stainless Steel Cookware Set, 14-Piece...",
    "brand":               "LEGEND COOKWARE",
    "price":               549.99,
    "price_strikethrough": nil,
    "currency":            "USD",
    "rating":              4.5,
    "reviews_count":       865.0, // JSON numbers decode as float64
    "stock":               "In Stock",
    "is_prime":            true,
    "images":              []any{"https://m.media-amazon.com/images/I/71Q3a8JH5NL._AC_SY355_.jpg", "..."},
    "bullet_points":       "5-PLY STAINLESS STEEL COOKWARE HEATS EVENLY - Five layers of steel...",
}

Responses are map[string]any. Read fields with type assertions, or re-marshal into your own struct with encoding/json if you prefer strong typing.

Keyword search

results, err := client.Search(ctx, amz.SearchParams{
    Query:  "wireless headphones",
    Domain: "co.uk",
    SortBy: "avg_customer_review",
    Pages:  1,
})
if err != nil {
    log.Fatal(err)
}
products, _ := results["products"].([]any)
for _, item := range products {
    p := item.(map[string]any)
    // Sponsored cards have sponsored_position instead of organic_position.
    fmt.Printf("%v. %v - %v\n", p["organic_position"], p["title"], p["price"])
}

Async batch (up to 1,000 ASINs with webhook callback)

batch, err := client.CreateBatch(ctx, amz.BatchCreateParams{
    Endpoint: "amazon.product",
    Items: []map[string]any{
        {"query": "B09HN3Q81F", "domain": "com"},
        {"query": "B000ALVUM6", "domain": "de", "language": "de_DE"},
    },
    WebhookURL: "https://your.server/webhooks/asa",
})
if err != nil {
    log.Fatal(err)
}
fmt.Println("batch id:", batch.ID)
// SAVE THIS. Returned only once.
fmt.Println("webhook secret:", batch.WebhookSignatureSecret)

// Alternative: poll
status, _ := client.GetBatch(ctx, batch.ID)
fmt.Printf("%v / %v processed\n", status["processed_count"], status["total_count"])

Verifying webhook signatures

Webhooks carry X-ASA-Signature: sha256=<hmac-hex> over the raw body:

func asaWebhookHandler(w http.ResponseWriter, r *http.Request) {
    raw, _ := io.ReadAll(r.Body)
    sig := r.Header.Get("X-ASA-Signature")
    if !amz.VerifyWebhookSignature(sig, raw, os.Getenv("WEBHOOK_SECRET")) {
        http.Error(w, "invalid signature", http.StatusUnauthorized)
        return
    }
    var payload map[string]any
    json.Unmarshal(raw, &payload)
    // process payload["results"]
    w.WriteHeader(http.StatusOK)
}

What the API solves for you

Building a production-grade Amazon scraper in-house is a 2-4 week engineering project plus permanent maintenance. This SDK wraps Amazon Scraper API, which has already solved:

Pain point What we handle
Amazon CAPTCHAs / robot pages Auto-retried through a heavier proxy tier (datacenter, residential, premium)
Brittle CSS selectors Extractors update as Amazon changes layouts; your code doesn't
20+ marketplaces com, co.uk, de, co.jp, com.br, and more. Marketplace-specific parsing quirks handled.
Country-matched residential IPs Auto-routed by TLD
Rotating proxies + anti-fingerprinting Handled server-side
Structured JSON output Title, price, rating, reviews, variants, seller, images. Parsed.
Batch/async jobs 1,000 ASINs submitted, webhook-delivered on completion

Time saved: a greenfield Go Amazon scraper built to this spec takes roughly 80 engineer-hours. This client is 5 minutes.

Error handling

Non-2xx responses return an *amz.Error with StatusCode, Body (the parsed JSON, or nil if the body was not JSON) and a Code() method returning the API's error code. The client does not retry on its own:

product, err := client.Product(ctx, amz.ProductParams{Query: "B09HN3Q81F", Domain: "com"})
if err != nil {
    var ae *amz.Error
    if errors.As(err, &ae) {
        switch ae.Code() {
        case "INSUFFICIENT_CREDITS":
            // top up
        case "RATE_LIMITED":
            time.Sleep(time.Second)
        case "target_unreachable":
            time.Sleep(60 * time.Second) // not charged; retry once
        default:
            return err
        }
    }
}
HTTP Code When Action
400 invalid_params Bad query/domain/sort_by Fix request
401 INVALID_API_KEY Missing or revoked key Rotate key
402 INSUFFICIENT_CREDITS Balance empty Top up
404 product_not_found ASIN delisted or not on this marketplace Drop the ASIN
429 RATE_LIMITED Over request-rate budget Back off, then retry
429 CONCURRENCY_LIMIT Over plan cap Drop parallelism
502 target_unreachable Amazon blocked every internal retry Retry after 60s or more. Not charged
502 extraction_failed Unknown layout Retry later; report X-Request-Id if it persists. Not charged
503 SERVICE_OVERLOADED Global circuit breaker Honor Retry-After: 60
500 INTERNAL_ERROR Our bug Report X-Request-Id

The default HTTP timeout is 120s (the API's own ceiling); pass your own client with amz.WithHTTPClient(&http.Client{Timeout: ...}).

Flat-credit promise: non-2xx responses are free. A basic request costs 5 credits (billing unit; end-customer price is $0.90 per 1,000 basic requests PAYG). Future JS-rendered calls will cost 15 credits. X-Request-Id on every response.

Get an API key

app.amazonscraperapi.com. 1,000 free requests on signup, no credit card required.

Links

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages