Skip to content

Repository files navigation

go SDK for amazon-sp-api

Port of https://github.com/amz-tools/amazon-sp-api. Credits due to the contributors of that repository: https://github.com/amz-tools

The client handles calls to the Amazon Selling Partner API. It wraps up all the necessary stuff such as requesting access token, security token and signing requests with AWS4 signature.

(Looking for Amazon Ads API SDK? Here it is: https://github.com/amazinsellers/amazon-ads-api-sdk-go)

Prerequisites

Make sure that you followed the Selling Partner API Developer Guide and have successfully completed the steps Registering as a developer, Registering your Selling Partner API application and have a valid refresh_token (if you use the client only for your own seller account the easiest way is using the self authorization as described in the developer guide).

Installation

go get -u github.com/amazinsellers/amazon-sp-api-sdk-go

Getting Started

Before you can use the client you need to add your app client and aws user credentials as environment variables:

Usage

A sample to get a catalog item:

package main 

import (
	"github.com/amazinsellers/amazon-sp-api-sdk-go"
	"github.com/amazinsellers/amazon-sp-api-sdk-go/resources"
)

func main() {
	spConfig := amazonspapi.NewSellingPartnerConfig()
	spConfig.Options.Debug = true
	spConfig.RefreshToken = "Atzr|XXXXXXXXXXXXXXXXXXXXXXXXXXXX..."
	spConfig.Region = "eu"

	sp, err := amazonspapi.NewSellingPartner(spConfig)

	if err != nil {
		println(err.Error())
		return
	}

	params := resources.SellingPartnerParams{
		Operation: "getCatalogItem",
		Query: map[string]interface{}{
			"MarketplaceId": "A1F83G8C2ARO7P",
		},
		PathParams: map[string]string{
			"asin": "B08SB9WBG8",
		},
	}

	resp, err := sp.CallAPI(params)
	if err != nil {
		println(err.Error())
		return
	}

	println(*resp)
}

Call the API

The .CallAPI() function takes an object as input:

  • Operation: Required, the operation you want to request see SP API References
  • PathParams: The input paramaters added to the path of the operation
  • Query: The input parameters added to the query string of the operation
  • Body: The input parameters added to the body of the operation

TODO

  1. Download reports
  2. Upload files

About

No description, website, or topics provided.

Resources

Stars

7 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages