spapi

module
v0.0.0-...-029b4cf Latest Latest
Warning

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

Go to latest
Published: May 31, 2025 License: MIT

README ยถ

Amazon SP-API Go Client

A Go client for the Amazon Selling Partner API (SP-API). This library provides convenient access to supported SP-API endpoints, OAuth2 authentication, request signing, rate limiting, and structured response decoding.

Features

  • ๐Ÿ” OAuth2 + AWS Signature Version 4 authentication
  • ๐Ÿš€ Built-in rate limiting
  • ๐Ÿ“ฆ Modular endpoint packages (inventory, listings, etc.)
  • ๐Ÿ” Struct-based request/response handling

Installation

go get github.com/chiyonn/spapi

Usage

1. Set environment variables
export SPAPI_REFRESH_TOKEN=your_refresh_token
export LWA_CLIENT_ID=your_client_id
export LWA_CLIENT_SECRET=your_client_secret
2. Initialize client and call an endpoint
package main

import (
	"fmt"
	"net/http"
	"os"
	"time"

	"github.com/chiyonn/spapi/auth"
	"github.com/chiyonn/spapi/client"
	"github.com/chiyonn/spapi/endpoint/inventory"
)

func main() {
	cfg, _ := auth.NewAuthConfig(
		os.Getenv("SPAPI_REFRESH_TOKEN"),
		os.Getenv("LWA_CLIENT_ID"),
		os.Getenv("LWA_CLIENT_SECRET"),
	)

	cli, _ := client.NewClient(&http.Client{Timeout: 10 * time.Second}, "JP", cfg, client.NewRateLimitManager())
	invAPI := inventory.NewInventoryAPI(cli)

	params := &inventory.GetInventorySummariesParams{
		GranularityType: "Marketplace",
		GranularityId:   "A1VC38T7YXB528", // Japan marketplace
	}

	res, err := invAPI.GetInventorySummaries(params)
	if err != nil {
		panic(err)
	}

	fmt.Printf("%+v\n", res)
}

Available Endpoints

Inventory API
Method Description
GetInventorySummaries Retrieves FBA inventory summaries
ListingsItems API
Method Description
PatchListingsItem Patch listings items (e.g.changing pricing)

License

This project is licensed under the MIT License, see the LICENSE.txt file for details

Directories ยถ

Path Synopsis
inventory
inventory/inventory.go
inventory/inventory.go

Jump to

Keyboard shortcuts

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