npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

paapi5-typescript-sdk

v0.2.0

Published

*Unofficial* TypeScript SDK for Product Advertising API 5.0

Downloads

10,944

Readme

paapi5-typescript-sdk

Unofficial TypeScript SDK for Product Advertising API 5.0

Installation

In order to install this SDK, you just have to run you well-known npm or yarn scripts:

npm i -S paapi5-typescript-sdk

Or

yarn add paapi5-typescript-sdk

And there you go! Enjoy 😎

API

Everything is exported from the SDK: requests' classes, models, utility types, helper and so on..

If you want to import everything

import * as SDK from 'paapi5-typescript-sdk';

And use what you need later

const request = new SDK.SearchItemsRequest(/* ... */);

You can refer to the Amazon Product Advertising API 5.0 for further details about every request

Auth

In order to validate all the requests against the APIs, I've implemented almost from scratch the AWS V4 signing process, creating the SignHelper class.

This is intended for interal use, but if you want to use it for other purposes, here you can find an example:

import { HttpMethod, SignHelper, Region } from 'paapi5-typescript-sdk'

const timestamp = 1609426121130;

const path = '/paapi5/getbrowsenodes';
const method = HttpMethod.POST;
const service = 'ProductAdvertisingAPI';

const accessKey = 'accessKey';
const secretKey = 'secretKey';

const signHelper = new SignHelper(accessKey, secretKey);

const headers = {
    host: 'webservices.amazon.it',
    'x-amz-target': 'com.amazon.paapi5.v1.ProductAdvertisingAPIv1.GetBrowseNodes',
    'x-amz-date': signHelper.toAmzDate(timestamp),
    'content-encoding': 'amz-1.0',
    'content-type': 'application/json; charset=utf-8',
};

const header = signHelper.getAuthorizationHeader(path, method, {}, headers, Region.ITALY, service, timestamp);

// 'AWS4-HMAC-SHA256 Credential=accessKey/20201231/eu-west-1/ProductAdvertisingAPI/aws4_request, SignedHeaders=content-encoding;content-type;host;x-amz-date;x-amz-target, Signature=ba741bfb87f9bf3b9b343d72e4f76dc9f169f2e86a047423d783a2169f03c595'

Http

This folder only contains some types, interfaces and enums

Models (resources)

This folder only contains some types, interfaces and enums

Link to Amazon documentation

Requests

Here you can find all the classes you need in order to communicate with the APIs

CommonRequest

This is intended to be just a parent class to be extended by all the other specific classes.

Its only purposes are:

  • Instantiate a SignHelper for internal use
  • Prepare all the request's parameters including the URL, the headers and the payload
  • Abstracts away the send() method so that all the sub-classes don't need to implement it

Example

import { CommonRequest, PartnerType, Host, Region } from 'paapi5-typescript-sdk'

const commonRequest = new CommonRequest(
    'partnerTag',
    PartnerType.ASSOCIATES,
    'accessKey',
    'secretKey',
    Host.Italy,
    Region.Italy
);

// Not an real request, just an example
const data = await commonRequest.send();

GetBrowseNodesRequest

Amazon documentation here

Example

import { GetBrowseNodesRequest, PartnerType, Host, Region } from 'paapi5-typescript-sdk'

const request = new GetBrowseNodesRequest(
    { /* parameters */ }
    'partnerTag',
    PartnerType.ASSOCIATES,
    'accessKey',
    'secretKey',
    Host.Italy,
    Region.Italy
);

const data = await request.send();

GetItemsRequest

Amazon documentation here

Example

import { GetItemsRequest, PartnerType, Host, Region } from 'paapi5-typescript-sdk'

const request = new GetItemsRequest(
    { /* parameters */ }
    'partnerTag',
    PartnerType.ASSOCIATES,
    'accessKey',
    'secretKey',
    Host.Italy,
    Region.Italy
);

const data = await request.send();

GetVariationsRequest

Amazon documentation here

Example

import { GetVariationsRequest, PartnerType, Host, Region } from 'paapi5-typescript-sdk'

const request = new GetVariationsRequest(
    { /* parameters */ }
    'partnerTag',
    PartnerType.ASSOCIATES,
    'accessKey',
    'secretKey',
    Host.Italy,
    Region.Italy
);

const data = await request.send();

SearchItemsRequest

Amazon documentation here

Example

import { SearchItemsRequest, PartnerType, Host, Region } from 'paapi5-typescript-sdk'

const request = new SearchItemsRequest(
    { /* parameters */ }
    'partnerTag',
    PartnerType.ASSOCIATES,
    'accessKey',
    'secretKey',
    Host.Italy,
    Region.Italy
);

const data = await request.send();