amzapi / selling-partner-api-sdk Goto Github PK
View Code? Open in Web Editor NEWGolang toolkit for working with Amazon's Selling Partner API (SP-API)
Home Page: https://gopkg.me/selling-partner-api-sdk
License: MIT License
Golang toolkit for working with Amazon's Selling Partner API (SP-API)
Home Page: https://gopkg.me/selling-partner-api-sdk
License: MIT License
Currently, we are requiring static credentials (in the form of access key and secret key). But if we are running in aws (e.g. ec2, ecs, lambda), then we already have temporary credentials (iam role). In these cases, I would like to not use an iam user. See: https://github.com/amzapi/selling-partner-api-sdk/blob/cf9bdde067d8ef6e33eafc1dc3e607ecd05a0b60/pkg/selling-partner/selling-partner.go
Can we use a credential provider chain from the aws-sdk to handle all cases? See: https://docs.aws.amazon.com/sdk-for-go/api/aws/credentials/#NewChainCredentials. Or we make the credentials object configurable.
There is already a function that does the process of step 2 of the documentation: https://github.com/amzn/selling-partner-api-docs/blob/main/guides/use-case-guides/feeds-api-use-case-guide-2020-09-04.md
Is there a plan to include the call to restrictedDataToken
?
It would be nice to have it, as an option
GetTransportDetailsWithResponse
parsing time ""Fri Jan 12 00:00:00 GMT 2024"" as ""2006-01-02T15:04:05Z07:00"": cannot parse "Fri Jan 12 00:00:00 GMT 2024"" as "2006"
fbaInbound.DateStringType serialize to string not with YYYY-MM-DD
Hi,
my experience with go is quite limited, since I just moved from python to go.
Is there a chance you could give a working example for a request / download of a report e.g.
GET_FLAT_FILE_ORDER_REPORT_DATA_SHIPPING.
Your first example the markets works, but I cannot retrieve a report yet.
Thank you very much in advance.
Although ShippingAddress
exists in the API response, there is no such field in Order
struct.
The base path was changed for Feeds to v2021-06-30 from v2020-09-04 but that was the only change that was made. There were changes that were made to the responses from Amazon that are not implemented and make feeds not usable.
The CreateFeedDocumentResult no longer has EncryptionDetails as a parameter.
https://github.com/amzapi/selling-partner-api-sdk/blob/master/feeds/types.gen.go#L35
The CreateFeedResponse no longer has a result of errors and now is just the values of Feeds and nextToken.
Essentially everything that had Payload as a response is no longer there.
Trying to use selling-partner-api-sdk with go.mod and getting the following error:
module declares its path as: gopkg.me/selling-partner-api-sdk
but was required as: github.com/amzapi/selling-partner-api-sdk
I think the gopkg.me doesn't work anymore
Any ideas how to fix this issue?
Please define some license on the project to allow pkg.go.dev (linked to in README.md) to display the documentation.
Example: https://pkg.go.dev/gopkg.me/selling-partner-api-sdk@master/pkg/selling-partner
Details about the package not displayed as the license is missing.
You can check their license policy for more details.
Hi guys,
The SP API returns the following error while providing a NextToken:
{ "errors": [ { "code": "InvalidInput", "message": "We could not decode your NextToken. Possible reasons include: a transmission error, improper quoting or a truncation problem.", "details": "" } ] }
The NextToken provided by Amazon was : Abjn8igatlp/YYuZQbKv1QafEPREmauvizt1MIhPYZacG7+f+fPp64jrgtdOS1N57G4NpRGNu/aHNkPWD9qzA98ytOVgN7d/KyNtf5fepe1HnywimSSQDRGmrXufpM2ZiOxqNBW1w66S68vI7Bqws+weLxD7b1CV0+mtVKXnPdiRy61Whm3WZuhTmqWGK9KSllhc4XvGqg5e0zIeaOVNezxWEXvdeDL7Zg54wKetRXLQp0zNIsrUkDRYOWseR6JecVkxA+q0fZYwE7+t4NjazyEZY027dXAVTSGshRBy6ZQghiSCZ3PIKk1DNEBSp27+sHmkcG/7LbJaHp4fabNqjZzx3vUsLaRi/IBQt3FQQzIESYt/Ti7LLVglFmAtnnBygOSv44FefAZ4FtaSjjwjko+Dl5QhYGtU3tAf+LbCLV+BA1KyEG2j/Km8ERy2ZulUV3HBz6/4NisG51E48qXehQ==
And the encoded NextToken passed in the query param by the SDK is :
NextToken=Abjn8igatlp%2FYYuZQbKv1QafEPREmauvizt1MIhPYZacG7%20f%20fPp64jrgtdOS1N57G4NpRGNu%2FaHNkPWD9qzA98ytOVgN7d%2FKyNtf5fepe1HnywimSSQDRGmrXufpM2ZiOxqNBW1w66S68vI7Bqws%20weLxD7b1CV0%20mtVKXnPdiRy61Whm3WZuhTmqWGK9KSllhc4XvGqg5e0zIeaOVNezxWEXvdeDL7Zg54wKetRXLQp0zNIsrUkDRYOWseR6JecVkxA%20q0fZYwE7%20t4NjazyEZY027dXAVTSGshRBy6ZQghiSCZ3PIKk1DNEBSp27%20sHmkcG%2F7LbJaHp4fabNqjZzx3vUsLaRi%2FIBQt3FQQzIESYt%2FTi7LLVglFmAtnnBygOSv44FefAZ4FtaSjjwjko%20Dl5QhYGtU3tAf%20LbCLV%20BA1KyEG2j%2FKm8ERy2ZulUV3HBz6%2F4NisG51E48qXehQ%3D%3D
A URL decode of the encoded token returns :
Abjn8igatlp/YYuZQbKv1QafEPREmauvizt1MIhPYZacG7 f fPp64jrgtdOS1N57G4NpRGNu/aHNkPWD9qzA98ytOVgN7d/KyNtf5fepe1HnywimSSQDRGmrXufpM2ZiOxqNBW1w66S68vI7Bqws weLxD7b1CV0 mtVKXnPdiRy61Whm3WZuhTmqWGK9KSllhc4XvGqg5e0zIeaOVNezxWEXvdeDL7Zg54wKetRXLQp0zNIsrUkDRYOWseR6JecVkxA q0fZYwE7 t4NjazyEZY027dXAVTSGshRBy6ZQghiSCZ3PIKk1DNEBSp27 sHmkcG/7LbJaHp4fabNqjZzx3vUsLaRi/IBQt3FQQzIESYt/Ti7LLVglFmAtnnBygOSv44FefAZ4FtaSjjwjko Dl5QhYGtU3tAf LbCLV BA1KyEG2j/Km8ERy2ZulUV3HBz6/4NisG51E48qXehQ==
As you can see the +
characters have been converted to spaces... destroying the token.
Any idea to solve this please?
Thanks
The docs and also the referenced spec defines the operation sendInvoice (POST /messaging/v1/orders/{amazonOrderId}/messages/invoice) which is not implemented/generated in the SDKs messaging API.
Hey team.
I try to get buyer customer infomation but it not work
The result always return empty
This is my code testing:
package main
import (
"context"
"fmt"
"net/http"
"github.com/amzapi/selling-partner-api-sdk/ordersV0"
sp "github.com/amzapi/selling-partner-api-sdk/pkg/selling-partner"
"github.com/google/uuid"
"github.com/pkg/errors"
)
var (
ClientID = "Your ClientID"
ClientSecret = "Your ClientSecret"
RefreshToken = "Your RefreshToken"
orderId = "Your OrderId"
)
func main() {
sellingPartner, err := sp.NewSellingPartner(&sp.Config{
ClientID: ClientID,
ClientSecret: ClientSecret,
RefreshToken: RefreshToken,
})
if err != nil {
panic(err)
}
endpoint := "https://sellingpartnerapi-na.amazon.com"
seller, err := ordersV0.NewClientWithResponses(endpoint,
ordersV0.WithRequestBefore(func(ctx context.Context, req *http.Request) error {
req.Header.Add("X-Amzn-Requestid", uuid.New().String()) //tracking requests
err = sellingPartner.AuthorizeRequest(req)
if err != nil {
return errors.Wrap(err, "sign error")
}
return nil
}),
)
if err != nil {
panic(err)
}
ctx := context.Background()
resp, err := seller.GetOrderItemsBuyerInfoWithResponse(ctx, orderId, &ordersV0.GetOrderItemsBuyerInfoParams{})
if err != nil {
fmt.Println("[GetOrderItemsBuyerInfoWithResponse] err : ", err)
panic(err)
}
fmt.Println(string(resp.Body))
}
The example result . BuyerCustomizedInfo
always is empty
{"payload":{"OrderItems":[{"OrderItemId":"98587589265001","BuyerCustomizedInfo":{}}],"AmazonOrderId":"113-8246998-1524200"}}
Go version: go version go1.22.2 linux/amd64
amzapi/selling-partner-api-sdk latest
Permission:
获取listing信息应该用啥方法?
REQ:
GET /orders/v0/orders?CreatedAfter=2022-04-14T15%3A43%3A01Z&CreatedBefore=2022-04-19T15%3A43%3A01Z&FulfillmentChannels=AFN&MarketplaceIds=A1AM78C64UM0Y8&MaxResultsPerPage=20&OrderStatuses=Unshipped HTTP/1.1
Host: sellingpartnerapi-na.amazon.com
Authorization: ***
User-Agent: selling-partner-api-sdk/v1.0 (Language=go/1.17.6; Platform=darwin-amd64)
X-Amz-Access-Token: ***
X-Amz-Date: 20220419T154306Z
X-Amz-Security-Token: ***
X-Amzn-Requestid: f4400f7e-d0eb-4112-accf-96d5cbf1e5b0
RES:
HTTP/2.0 400 Bad Request
Content-Length: 185
Content-Type: application/json
Date: Tue, 19 Apr 2022 15:43:03 GMT
X-Amz-Apigw-Id: Q1bFNEjKoAMFpwQ=
X-Amzn-Ratelimit-Limit: 0.0167
X-Amzn-Requestid: f4400f7e-d0eb-4112-accf-96d5cbf1e5b0
X-Amzn-Trace-Id: Root=1-625ed887-1ef8fa3b43d1674d231133e6
{
"errors": [
{
"code": "InvalidInput",
"message": "The input you have submitted is not valid. Please check your input and try again.",
"details": ""
}
]
}
Hi @gopkg-dev
Can you please provide some examples how to fetch the catalogue items with your library.
I hardly see any examples. There is only one example to GetMarketplaceParticipationsWithResponse
.
Please provide some more examples how to use the SDK.
Thanks
DumpRequest = POST /fba/outbound/2020-07-01/fulfillmentOrders HTTP/1.1
Host: sandbox.sellingpartnerapi-na.amazon.com
Authorization: AWS4-HMAC-SHA256 Credential=ASIA43E7AIHHOTY4FBL5/20210113/us-east-1/execute-api/aws4_request, SignedHeaders=content-type;host;x-amz-access-token;x-amz-date;x-amz-security-token;x-amzn-requestid, Signature=4d57cabf3695d4f186399783dadddc2f6a37325569d7902d7ad0decf7b42c605
Content-Type: application/json
X-Amz-Access-Token: Atza|IwEBIMhY3hqnYQrMvu_VlJ5euqXQS4iuH_jGdOoYsG--e6CzIJPa3Y2x73td6JY7kKwAz94-WcLLGCrfHo1L5qH98nbk1O09duX1we46PtXAz_Vcqk3Vk59UuUPG9fwHLo96eKookLHdVmEqzW8xu2A9Khvlxb9Rs6TrPCtOnEOHtIkKTBm2XBGikTjgusUxHG1yAJCTPyT3CJZBMSh6EMEe_uGHQ8oj4LrAKfA4IPMq46F3IRDW2JUUhrPDS6YJ-zBRIyPHD6tF71vqpYZWl32yvDV6wKlIsrsawkEY9p1300V0Qhme47JJXcy78PLuE1qpajFpaG1VKztCcP1hRXVMi-Ey
X-Amz-Date: 20210113T155956Z
X-Amz-Security-Token: FwoGZXIvYXdzECEaDKS+Gh0KHu4uEWEQXSLIAZPUpb2G+yUr12mM1KN5y/pp+x6037Q7k79haXFBayGckwRqXcDsELHkFi9e2Ssj6mZj0jNeq5zT5S8Fystai0KX5wEU/nVeKJVe/KbQxgTOzARcDaiqnp9R02aO/0xSzB9iWvXj+C7kfa/rkVCUJeWbcat88ggayLTZ/xDPL9spk2PIxQ3AFjL0fgCz1KiolQQIC7u/liNqDbhTCqU7rFN1nnMpnl75uqDxIN/SGirHgB2YeT5eXMmW9TrWw9qJ8Lvg6N3hBjHsKPyx/P8FMi2W6NqFml69e2Qhc9m9NcF/fU6+s3OaXuaFLQM01I0+eQmvVCYiYueMQSWBN80=
X-Amzn-Requestid: 7f72891d-50a2-4cfa-8357-b6bec7c46f22
{"codSettings":{"codCharge":{"currencyCode":"USD","value":"10.00"},"codChargeTax":{"currencyCode":"USD","value":"2.00"},"isCodRequired":false,"shippingCharge":{"currencyCode":"USD","value":"5.00"},"shippingChargeTax":{"currencyCode":"USD","value":"3.00"}},"destinationAddress":{"addressLine1":"1234 Amazon Way","addressLine2":"Suite 123","addressLine3":"Lane1","countryCode":"US","districtOrCounty":"","name":"Amazon","stateOrRegion":"MI"},"displayableOrderComment":"TestOrder","displayableOrderDate":"2020-01-09T19:46:45.809Z","displayableOrderId":"TestOrder-FBAOutbound","fulfillmentAction":"Ship","items":[{"quantity":3,"sellerFulfillmentOrderItemId":"OrderItemID1","sellerSku":"CR-47K6-H6QN"},{"quantity":1,"sellerFulfillmentOrderItemId":"OrderItemID2","sellerSku":"PSMM-TEST-SKU-Jan-21_19_59_44-0738"}],"marketplaceId":"ATVPDKIKX0DER","notificationEmails":["test1%40amazon.com","test2%40amazon.com"],"sellerFulfillmentOrderId":"FBATestOrder-1","shippingSpeedCategory":"Standard"}
Response:
err 400 Bad Request
Code:
func (s service) CreateOrder(request fbaOutbound.CreateFulfillmentOrderJSONRequestBody) error {
ctx := context.Background()
order, err := s.amazonService.CreateFulfillmentOrderWithResponse(ctx, request)
if err != nil {
log.Println("err", err)
return err
}
log.Println("order", order)
return nil
}
GetLabelsParams struct not found those params 'PageSize' and 'PageStartIndex', but they can be found in the api document?
hello, i googled " go-sdk-codegen" found nothing. What tool did u use to make this project? i wanna learn and use it on listings service sp-api. thank you
你好,请问是如何通过json文件生成代码库中的代码模版的?我觉得十分简洁,清爽,可否分享一下工具?或者有什么学习途径吗?作为菜鸟十分好奇,感激!
https://github.com/gopkg-dev/selling-partner-api-sdk/tree/master/ordersV0
types.gen.go:123
GetOrderItemsResponse.Payload.OrderItems.ProductInfo.ProductInfoDetail.NumberOfItems
At types.gen.go:529, the type of NumberOfItems is *int, but the actually response is string
Hello, thank you for the useful SDK.
I think there may be some APIs where ResponseAfter is not called.
example 1: https://github.com/amzapi/selling-partner-api-sdk/blob/master/fees/api.gen.go#L179
func (c *Client) GetMyFeesEstimateForASIN(ctx context.Context, asin string, body GetMyFeesEstimateForASINJSONRequestBody) (*http.Response, error) {
req, err := NewGetMyFeesEstimateForASINRequest(c.Endpoint, asin, body)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if c.RequestBefore != nil {
err = c.RequestBefore(ctx, req)
if err != nil {
return nil, err
}
}
return c.Client.Do(req)
}
example 2: https://github.com/amzapi/selling-partner-api-sdk/blob/master/fbaOutbound/api.gen.go#L373
func (c *Client) GetFulfillmentPreview(ctx context.Context, body GetFulfillmentPreviewJSONRequestBody) (*http.Response, error) {
req, err := NewGetFulfillmentPreviewRequest(c.Endpoint, body)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if c.RequestBefore != nil {
err = c.RequestBefore(ctx, req)
if err != nil {
return nil, err
}
}
return c.Client.Do(req)
}
I don't know why this happens because I think the code is automatically generated, but I think these are not the your intended implementation.
Please let me know if there is anything I can do to help fix it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.