Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/datawookie/trundler

Wrapper for Retail Pricing API
https://github.com/datawookie/trundler

api hacktoberfest r rstats

Last synced: 3 months ago
JSON representation

Wrapper for Retail Pricing API

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, comment = NA)

options(trundler.chatty = FALSE)
# options(tibble.width = Inf)
```

# trundler

[![Travis-CI build status](https://travis-ci.org/datawookie/trundler.svg?branch=master)](https://travis-ci.org/datawookie/trundler)
[![Codecov test coverage](https://img.shields.io/codecov/c/github/datawookie/trundler.svg)](https://codecov.io/github/datawookie/trundler)
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)

[Trundler](https://www.trundler.dev) provides access to product and historical price data from a range of online retailers.

The homepage for the {trundler} R package is at https://datawookie.github.io/trundler/.

## Installation

Install from GitHub.

```{r eval=FALSE}
remotes::install_github("datawookie/trundler")
```

If you want to be closer to the bleeding edge then you can also install from the development branch.

```{r eval=FALSE}
remotes::install_github("datawookie/trundler", ref = "dev")
```

## Usage

```{r load-package}
library(trundler)
```

Check version.

```{r check-version}
packageVersion("trundler")
```

### Set API Key

To access the full API you'll need to first specify an API key.

```{r eval=FALSE}
# Example API key (this key will not work).
set_api_key("8f9f3c4e-5dd6-4bff-3a2c-592b45cf2437")
```

```{r include=FALSE}
set_api_key(Sys.getenv("TRUNDLER_KEY"))
```

To obtain a key, please get in touch. Contact details are in `DESCRIPTION`.

You can also subscribe via [RapidAPI](https://rapidapi.com/datawookie/api/trundler).

```{r eval=FALSE}
# Example RapidAPI key (this key will not work).
set_api_key("5a1ae0ce24mshd483dae6ab7308dp129ef6jsn1f473053d6b0")
```

### Retailers

Use `retailer()` to get a list of retailers.

```{r}
retailer()
```

Or you can acccess the details for a specific retailer.

```{r}
retailer(45)
```

### Products

Get a list of products for a specific retailer.

```{r cache=TRUE}
retailer_products(5)
```

Products can be filtered by name and brand.

```{r cache=TRUE}
retailer_products(5, product = "coffee", brand = "nespresso")
```

A similar search can be applied across *all* retailers.

```{r cache=TRUE}
products(product = "hand sanitiser")
products(product = "coffee", brand = "nespresso|nescafe")
products(product = "tv", brand = "samsung|hisense")
```

Information on a specific product.

```{r}
item <- product(530290)
```

What fields are available?

```{r}
names(item)
```

Get product name, [SKU](https://en.wikipedia.org/wiki/Stock_keeping_unit) and barcodes.

```{r}
item$product
item$sku
item$barcodes
```

### Prices

Get price history data for a specific product.

```{r}
product_prices(530290)
```

### Options

You can control the volume of console output with options:

* `options(trundler.chatty = TRUE)`: provide more output; and
* `options(trundler.chatty = FALSE)`: provide less output.

## RMarkdown Template

You can use the Trundler RMarkdown template to quickly produce visualisations for product price histories. After installing the package, select "Trundler Report Template" under the "From Template" option on the **New RMarkdown** dialog.

_Note:_ You might need to restart RStudio before the template shows up in the menu.