GithubHelp home page GithubHelp logo

bizon / selling-partner-api-sdk Goto Github PK

View Code? Open in Web Editor NEW
35.0 1.0 7.0 134.48 MB

A modularized SDK library for Amazon Selling Partner API (fully typed in TypeScript)

Home Page: https://bizon.github.io/selling-partner-api-sdk/

License: MIT License

TypeScript 99.94% Mustache 0.06%
amazon sellercentral vendorcentral amazon-marketplace typescript nodejs sdk bizon brand-analytics retail-analytics

selling-partner-api-sdk's People

Contributors

antanasmisiunas avatar bizon-bot avatar dependabot[bot] avatar github-actions[bot] avatar my42 avatar tusbar avatar

Stargazers

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

Watchers

 avatar

selling-partner-api-sdk's Issues

(Bug) Invalid input content type

I am trying to cancel fulfillment order using cancelFulfillmentOrder

I saw this issue on version 1.10.3 so I upgraded to 2.1.1 and upgraded Auth library as well.

For some reason I get this content type error. Is it possible that Amazon has new requirement for content type? Maybe charset=utf8 is not set. I don't recall having this issue before.

[
  {
    code: 'InvalidInput',
    message: 'Invalid Input',
    details: 'Content type must be set to application/json; charset=utf-8.'
  }
]

How I use it

await this.client.cancelFulfillmentOrder({
  sellerFulfillmentOrderId: id
})
.then((response) => {})

Getting error code 429: "QuotaExceeded"

I have an array of orders that I loop through to get order items for each of them, using getOrderItems(). I've set retry: true it'll work for a few retries. Sometimes I'm able to loop though the entire array, but other times I'll get a 429 response. Is there anything I can do for it to keep retrying until it completes the loop?

Issue with Auth Types on Catalog APIs

I have a working API using the @sp-api-sdk/catalog-items-api-2022-04-01 package and the @sp-api-sdk/auth;

However, there is some data needed that is only available in the @sp-api-sdk/catalog-items-api-2020-12-01 package.

When I try to use the @sp-api-sdk/catalog-items-api-2020-12-01 with the the @sp-api-sdk/auth package. I am getting the following error:

`/@sp-api-sdk/auth/dist/types/src/index").SellingPartnerApiAuth' is not assignable to type

@sp-api-sdk/catalog-items-api-2020-12-01/node_modules/@sp-api-sdk/auth/dist/types/src/index").SellingPartnerApiAuth'.

Types of property 'accessToken' are incompatible.

AccessTokenFactory' is not assignable to type 'import("/@sp-api-sdk/catalog-items-api-2020-12-01/node_modules/@sp-api-sdk/auth/dist/types/src/access-token").AccessTokenFactory'.
Types have separate declarations of a private property 'value'.ts(2322)
axios.d.ts(21, 5): The expected type comes from property 'auth' which is declared here on type 'ClientConfiguration'`

Where am I off track? It seems that I may need a different auth package/config for the 2020 API?

Any guidance is appreciated!

[Bug] omit sessionToken if undefined

For self-authorized sellers who obtain an access token using a refresh token, when attempting to assume roles with SST, an undefined sessionToken results in an InvalidClientTokenId error. It seems that the undefined value is being converted to the string 'undefined'..

    const auth = new SellingPartnerApiAuth({
      clientId: '',
      clientSecret: '',
      accessKeyId: '',
      secretAccessKey: '',
      refreshToken: 'Atzr|',
      role: { arn: '' },
    });

    const client = new OrdersApiClient({
      auth,
      region: 'na',
    });

    const {
      data: { payload },
    } = await client.getOrders({
      marketplaceIds: ['ATVPDKIKX0DER'],
      createdAfter: new Date('2022-01-01').toISOString(),
    });
    console.log(payload?.Orders.length);

| +1648ms InvalidClientTokenId: The security token included in the request is invalid
| +1648ms at throwDefaultError (/Users/.../node_modules/.pnpm/@smithy[email protected]/node_modules/@smithy/smithy-client/dist-es/default-error-handler.js:5:22)

The issue was resolved by commenting out the sessionToken parameter in the "@sp-api-sdk/auth/sts" module. This modification allowed the functionality to work correctly.

CleanShot 2023-07-05 at 14 52 30@2x CleanShot 2023-07-05 at 14 57 52@2x

Region is missing

I am trying to getOrders

aws/node_modules/.pnpm/@[email protected]/node_modules/@aws-sdk/config-resolver/dist-cjs/regionConfig/config.js:10
        throw new Error("Region is missing");

Error: Region is missing
    at default (/aws/node_modules/.pnpm/@[email protected]/node_modules/@aws-sdk/config-resolver/dist-cjs/regionConfig/config.js:10:15)
    at aws/node_modules/.pnpm/@[email protected]/node_modules/@aws-sdk/node-config-provider/dist-cjs/fromStatic.js:6:83
    at /aws/node_modules/.pnpm/@[email protected]/node_modules/@aws-sdk/property-provider/dist-cjs/chain.js:11:28
    at async coalesceProvider (/aws/node_modules/.pnpm/@[email protected]/node_modules/@aws-sdk/property-provider/dist-cjs/memoize.js:14:24)
    at asyncaws/node_modules/.pnpm/@[email protected]/node_modules/@aws-sdk/property-provider/dist-cjs/memoize.js:26:28
    at async Object.region (/aws/node_modules/.pnpm/@[email protected]/node_modules/@aws-sdk/config-resolver/dist-cjs/regionConfig/resolveRegionConfig.js:17:36)
    at async getEndpointFromRegion (aws/node_modules/.pnpm/@[email protected]/node_modules/@aws-sdk/config-resolver/dist-cjs/endpointsConfig/utils/getEndpointFromRegion.js:7:20)
    at async buildHttpRpcRequest (aws/node_modules/.pnpm/@[email protected]/node_modules/@aws-sdk/client-sts/dist-cjs/protocols/Aws_query.js:1029:68)
    at async aws/node_modules/.pnpm/@[email protected]/node_modules/@aws-sdk/middleware-serde/dist-cjs/serializerMiddleware.js:5:21
    at async aws/node_modules/.pnpm/@[email protected]/node_modules/@aws-sdk/middleware-logger/dist-cjs/loggerMiddleware.js:6:22

Here is the code:

    const auth = new SellingPartnerApiAuth({
      clientId: process.env.LWA_CLIENT_ID,
      clientSecret: process.env.LWA_CLIENT_SECRET,
      refreshToken: process.env.LWA_APP_REFRESH_TOKEN,
      accessKeyId: process.env.AWS_ACCESS_KEY_ID,
      secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
      role: {
        arn: process.env.AWS_SELLING_PARTNER_ROLE,
      },
    })

    const client = new OrdersApiClient({
      auth,
      region: 'na'
    })

    const res = client.getOrders(
      {
        marketplaceIds: ['ATVPDKIKX0DER']
      }
    );

address error for amazon STS while trying to use financesAPI

how do i solve this? i have been getting this error for a few days while making any call to financials api..

Error: getaddrinfo ENOTFOUND sts.eu.amazonaws.com at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26) { errno: -3008, code: 'ENOTFOUND', syscall: 'getaddrinfo', hostname: 'sts.eu.amazonaws.com', '$metadata': { attempts: 1, totalRetryDelay: 0 } }

I think it is trying to contact an invalid address, how can I change the STS address to the global endpoint sts.amazonaws.com?

TypeError - Cannot read properties of undefined (reading 'packageJson')

Happy Friday :)

Context

I would like to create a private Amazon SP-API application. I have used a few (auth, catalog, pricing, fees) sub-packages from this library to get the data I would like for my application.

This app would be something like ScoutIQ that helps me check some details that interest me. I am trying to host this application on Netlify to be served. I have used the sub-packages with the Netlify functions to make the API calls.

Everything works fine in the dev environment, I could make actual API calls with valid data so that means my credentials are correct.

When I deploy the application to Netlify the build succeeds but whenever I call the functions that will eventually make the API call using this library I get this error

TypeError - Cannot read properties of undefined (reading 'packageJson')

Stack Trace by Netlify

TypeError: Cannot read properties of undefined (reading 'packageJson')
    at node_modules/@sp-api-sdk/auth/dist/cjs/src/utils/package.js (/var/task/netlify/functions/pricing.js:19601:34)
    at __require (/var/task/netlify/functions/pricing.js:37:50)
    at node_modules/@sp-api-sdk/auth/dist/cjs/src/utils/axios.js (/var/task/netlify/functions/pricing.js:19613:21)
    at __require (/var/task/netlify/functions/pricing.js:37:50)
    at node_modules/@sp-api-sdk/auth/dist/cjs/src/access-token.js (/var/task/netlify/functions/pricing.js:19630:19)
    at __require (/var/task/netlify/functions/pricing.js:37:50)
    at node_modules/@sp-api-sdk/auth/dist/cjs/src/index.js (/var/task/netlify/functions/pricing.js:30983:26)
    at __require (/var/task/netlify/functions/pricing.js:37:50)
    at node_modules/@sp-api-sdk/auth/dist/cjs/index.js (/var/task/netlify/functions/pricing.js:31073:26)
    at __require (/var/task/netlify/functions/pricing.js:37:50)

Does anyone know what is wrong with this setup?

npm install not working

I am trying to use npm install but I get the following error:

npm ERR! /Users/maximiliandoelle/.npm/_logs/2023-04-19T05_17_35_086Z-debug-0.log
(base) maximiliandoelle@Maximilians-MBP selling % npm install @sp-api-sdk/catalog-items-api-2022-04-01
npm ERR! code ETARGET
npm ERR! notarget No matching version found for @sp-api-sdk/[email protected].
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/maximiliandoelle/.npm/_logs/2023-04-19T05_18_11_629Z-debug-0.log
(base) maximiliandoelle@Maximilians-MBP selling % npm install
npm ERR! code ETARGET
npm ERR! notarget No matching version found for @sp-api-sdk/[email protected].
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/maximiliandoelle/.npm/_logs/2023-04-19T05_18_17_158Z-debug-0.log
(base) maximiliandoelle@Maximilians-MBP selling % yarn install
zsh: command not found: yarn

Am also looking for a freelancer to help a noob like me :) If you are interested, drop me a line at maxdoelle(at)gmail.com

Error using "na" region.

Hi, first of all, I'd like to thank you for your help.

I'm attempting to configure the selling-partner-api-sdk to retrieve the inventory information from my Amazon seller partner account, but I am encountering an error "region is missing" from the "@AWS-SDK" package. I have already defined the region in the instance of "FbaInventoryApiClient." I'm not sure if this is an error or just a bad implementation,

This is my code (All values in upper are constants):

        const auth = new SellingPartnerApiAuth({
            clientId: CLIENT_ID,
            clientSecret: ACCESS_SECRET_KEY,
            refreshToken: REFRESH_TOKEN,
            accessKeyId: ACCESS_KEY_ID,
            secretAccessKey: ACCESS_SECRET_KEY,
            role: {
                arn: ARN,
            },
        });

        const client = new FbaInventoryApiClient({
            auth,
            region: "na", // as the ts docs says.
        });

        const specs = {
            granularityType: "Marketplace",
            granularityId: MARKETPLACE_ID,
            marketplaceIds: [MARKETPLACE_ID],
        };


        client.getInventorySummaries(specs);

I got the next error:
image

Trying to debug, I found that the "sts property of the SellingPartnerApiAuth has an undefined value in region property as you can see in the following image:
image

Thanks for your answer

Requesting vendorDetails in getCatalogItem results in 400 response error

When using catalog-items-api-2022-04-01...

This works:

await client.getCatalogItem({
    asin,
    marketplaceIds: [marketplace.marketplaceId],
});

This also works:

await client.getCatalogItem({
    asin,
    marketplaceIds: [marketplace.marketplaceId],
    includedData: ["summaries"],
});

However, this results in a 400:

await client.getCatalogItem({
    asin,
    marketplaceIds: [marketplace.marketplaceId],
    includedData: ["summaries", "vendorDetails"],
});

Is this because "Vendor details are available to vendors only"? If so, how do I specify myself as a vendor when making this request? Thanks.

Types have separate declarations of a private property 'clientId'.

i get this error in my project.
Types have separate declarations of a private property 'clientId'.

i have already installed for orders, catalog and listing api from @sp-api-sdk everything is working fine. but except with listings restrictions package.

i use same package version of authentication. which is version 2.0.2

Screenshot 2023-11-22 at 09 49 47

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.