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

tradegecko-headless

v1.2.0

Published

TradeGecko headless CLI

Downloads

4

Readme

TradeGecko Headless CLI

Headless TradeGecko interaction CLI for those without API access or for automating calls not yet published in the TradeGecko API Reference.

Install

npm install --global tradegecko-headless

If you receive the error ERROR: Failed to download Chromium, please see the NPM article on preventing premission errors.

Given that a Chrome headless instance will need to be launched, it is advised that a local install be used if permission issues exist.

Usage

The following usage examples should be read sequentially as it references results from previous commands.

It is also recommended that all result files be viewed or manipulated with jq.

Command pattern

To use the CLI, identify the command you want to execute and provide any parameters and options.

tgcli [command] [options]

To see the full list of commands, execute

tgcli --help

Set username and password

Username and password can be provided as environment variables or as parameters. It is recommended that environment variables be used.

export TG_USERNAME="[email protected]"
export TG_PASSWORD="bar"

Download a list of resources

Download 2nd and 3rd oldest variants resource, keeping only fields id and created_at and save them to file variants.json

tgcli tg:resource-list:download variants variants.json --limit=2 --offset=1 --fields=id,created_at

Sample output

Signing in ...
Getting variants count ...
Getting variants ...
 ████████████████████████████████████████ 100% | ETA: 0s | 2/2
Saving variants to file ...
Done

Sample output file contents

[{"id":1,"created_at":"2017-01-11T11:00:00.000Z"},{"id":2,"created_at":"2017-01-11T12:00:00.000Z"}]

Perform fetch actions on a JSON object list

Make a fetch call using variants.json and output results to fetched-variants.json. The fetch call should make a GET call to get the variant by id.

tgcli tg:resource-list:fetch variants.json fetched-variants.json GET "variants/{{id}}"

Sample output

Signing in ...
Performing fetches ...
 ████████████████████████████████████████ 100% | ETA: 0s | 2/2
Saving responses to file ...
Done

Sample output file contents

Plese note the following outputs have been shortended for readability.

[{"variant":{"id":1,"created_at":"2017-01-11T11:00:00.000Z","updated_at":"...","committed_stock_levels":{}}},{"variant":{"id":2,"created_at":"2017-01-11T12:00:00.000Z","updated_at":"...","committed_stock_levels":{}}}]

Commands

For a full list of commands, execute the program with --help. All commands should be prefixed with tgcli.

|Command|Description| |-------|-----------| |tg:resource-list:download [resource] [file]|Download a list of a given resource| |tg:resource-list:fetch [listFile] [responsesFile] [method] [endpoint]|Perform fetch action on each record of a provided resource list JSON file| |tg:resource:count [resource]|Get the total records of a given resource| |tg:ajax:fetch [method] [endpoint]|Perform a fetch call against the TradeGecko AJAX API, see the MDN entry for Fetch API for details|

Known TradeGecko resources

The following list of resources were obtained by observing Chrome debugger XHR activity for connections related to https://go.tradegecko.com/ajax

  • channels
  • products
  • variants

Although not fully tested, most resources listed in the TradeGecko API Reference should be available as well.

Built with