Code Monkey home page Code Monkey logo

amzn-sp-api-go's Introduction

Amazon Selling Partner API in Go

GoDoc License

Selling Partner API or SP-API is the next generation suite of API-based automation functionality for Amazon's Selling Partners and is an evolution of (the legacy) Amazon Marketplace Web Service (Amazon MWS) APIs, which have been offering sellers programmatic access to critical Amazon features for more than 10 years. SP-API is available in production in all the marketplaces where Amazon MWS is available.

This package provides an easy way to communicate with SP-API.

How does this work

Amazon provides swagger models for each API, and using that you will be able to form requests to the API. Some more steps are needed to have a successful call to the API, including authentication, signing the request, etc.

This package will make it easier to make authenticated requests to SP-API. The HTTP client(s) are generated from the swagger models specs using go-swagger.

To keep the client(s) up to date, there is a schedule job that runs to fetch the Selling Partner API models from Amazon's Github account, regenerate the client(s), and commit the changes to a new branch called next.

When we think that next branch is stable enough to be used, we will merge it into the master branch and create a new version out of the new or updated models.

Installation

go get github.com/renabled/amzn-sp-api-go

Example

import (
  "fmt"

  "github.com/renabled/amzn-sp-api-go/api/sellers/sellers_client/sellers"
  "github.com/renabled/amzn-sp-api-go/selling_partner"
)

// Initilize your config
config := selling_partner.NewConfig(
  "_accessKeyId_",
  "_secretKey_",
  "_roleArn_",
  "_refreshToken_",
  "_clientID_",
  "_clientSecret_",
  "region", // NA, EU or FE
)

// Create a selling partner client providing the config
cli := selling_partner.New(config)

// Transport that require auth
transport := cli.ClientTransport(
  context.Background(),
  /* selling_partner.Grantless(), selling_partner.Debug() */)

// Call sellers
sellersCli := sellers.New(transport, nil)

// Make the actual request
res, err := sellersCli.GetMarketplaceParticipations(sellers.NewGetMarketplaceParticipationsParams())

fmt.Println(res, err)

amzn-sp-api-go's People

Contributors

amrnt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

amzn-sp-api-go's Issues

关于roleARN参数

您好,关于 roleArn 参数有一些困惑,我只需要使用其中部分 API,而这部分 API 是不依赖这个参数的,我现在该怎么做呢?

Error casting issue

Thanks for sharing a great always up-to-date API client!

The errors returned have custom error types, e.g. *catalog.SearchCatalogItemsBadRequest but it's not easy to print the error messages. It just prints &{Errors:[0x14000b0a4c0]} because the errors are pointers.

Is there a better way than going through every possible error type, like below?

	var printError = func(errs *models.ErrorList) {
		for i := 0; i < len(errs.Errors); i++ {
			fmt.Println(errs.Errors[i].Message)
		}
	}

	if err != nil {
		switch err.(type) {
		case *catalog.SearchCatalogItemsBadRequest:
			er := err.(*catalog.SearchCatalogItemsBadRequest)
			printError(er.Payload)
		case *catalog.SearchCatalogItemsForbidden:
			er := err.(*catalog.SearchCatalogItemsForbidden)
			printError(er.Payload)
			
		//case etc..
		default:
			fmt.Println(err.Error())
		}
		return
	}

Perhaps a helper function is needed in this library.

Support for Orders V0 API

Currently is it possible to get list of orders using this library ? I couldn't find any related code to get orders from SP-APIs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.