/amazon-stock

Kotlin library to retrieve the current stock from an amazon article using Product Advertising API.

Primary LanguageKotlinMIT LicenseMIT

Amazon Stock

This library allows retrieving the current stock from an amazon offer.

Maven metadata URI Build Status GitHub license

Getting started

Maven

<dependency>
    <groupId>de.kevcodez.amazon</groupId>
    <artifactId>stock</artifactId>
    <version>0.1.0</version>
</dependency>

Gradle

compile "de.kevcodez.amazon:stock:0.1.0"

Example

val stockService = StockService(
    AmazonConfig(
        endpoint = "webservices.amazon.de",
        accessKeyId = "xxx",
        secretKey = "yyy",
        associateTag = "<your-associate-tag>"
    )
)

val stock = stockservice.getStockInformation(listOf("B01BPJK4S2"))
println(stock)

[StockInformation(price=12.9, stock=9, asin=B01BPJK4S2)]

How does it work?

To retrieve the stock, an API call to the Product Advertising API is done. By entering an usually high amount of 999 as requested stock during a CartCreate-Call, the available stock is returned.

Getting API access

Go to Sign up for the Product Advertising API and get your access token/secret key.