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 🙏

© 2025 – Pkg Stats / Ryan Hefner

leetcode-fetcher-cli

v0.1.2

Published

A CLi Application for local fetching of leetcode problems

Downloads

45

Readme

A CLi Application for local fetching of leetcode problems

LeetCode Node.js TypeScript


GitHub Pages Documentation is in construction 👷

Give a look to TODO.md for upcoming changes


About ✨

When solving leetcode problems, I would have like to have a tool or a utility able to automatically provides me with a number of problems and, for each of them, creates a local instance with the problem description and the provided snippet of code. Thus avoiding every time to manually copy everything locally, resolve the imports and setup the tests.

The final result of this need is leetcode-fetcher, a simple cli applications that interacts with leetcode through the GraphQL endpoint, in order to fetch problems, user statistics, run tests remotely and submit a solution.

Running the App 🚀

Cloning the repository and install locally

Up to now, to run the application you need first to clone the repository, install all the required node modules and then run.

git clone https://github.com/lmriccardo/leetcode-fetcher.git
npm install && npm run app

Please, make sure to have node.js and npm installed in your system.

Using Docker containers

Alternatively, it is possible to run the application using Docker.

docker run --rm -it -v ./:/leetcode lmriccardo/leetcode-fetcher:latest

Notice that, the bind mount -v ./:/leetcode is required to obtain the result on the host machine. When the application starts, the first command to execute must be

set FOLDER /leetcode

In order to set the correct output folder

NOTE: Within Docker containers, user login with browser is not available. The only possible solution is to load a pre-saved JSON state with a logged in user.

From NPM Packages

The last way to run the cli application is to install it via npm

npm i leetcode-fetcher-cli

The command to run the application is just

lcfetcher

How the application works 💻

When first the application starts, the following line will appear:

[Current DateTime] >> (Type help for commands): 

If you type help the list with all possible commands will appear. That is, the application works giving specific commands and then pressing ENTER to execute it. Every time, either an error or the output pops out, you will always see the initial line and new commands can be given. Here is the list with all possible commands:

| Name | Syntax | Description | |-----------|---------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | Help | help [cmd1 cmd2 ...] | Shows the helper message for each given command. If no command is provided, consider all. | | Set | set [VAR value ...] | Set the value of the specified variable. To inspect available variables use the show command. | | Unset | unset [VAR1 VAR2 ...] | Unset variables bringing back to their default values. | | Show | show [sensitive] | Shows values and informations about the application state and variables. If sensitive is given then also user cookies are shown. | | List | list | Locally fetches a number of problems from leetcode. The search is filtered using the variables set with set or unset | | Detail | detail idx | Print details about a specified problem. A problem is specified either by local indexing, or remote question IDs. | | Fetch | fetch <title\|id> value | Fetch locally a single problem from remote. The problem is specified either using the title-slug or the remote ID. | | Create | create <idx> | Create a problem instance in the provided target folder (which is a variable). The problem is specified only by the local index which means that must already exists locally. | | Save | save filepath | Saves the current state into a json file | | Load | load filepath | Loads the state from a json file | | Clear | clear | Clears the screen content | | Login | login [force] | Open a browser to perform the login and starts a leetcode session. | | Inspect | inspect [username] | Inspect a given user profile if it exists, or the current logged one | | Daily | daily [create] | Fetch the current daily question and optionally create an instance | | Quit | quit | Quit the application | | Watch | watch <question-idx\|daily> | Cache the given problem for future tests or submissions. An instance of the given problem is create if it does not exists. | | Test | test | Test the cached problem with leetcode remotely (see watch) | | Submit | submit | Submit a solution of the cached problem in leetcode (see watch) |

In order to obtain more informations about the commands, run the help command.

An output example is already present in the ./examples/python/9-palindrome-number folder. It has been obtained running the following commands:

[XXX] >> (Type help for commands): fetch id 9

Fetched Problems : 1

STATUS  IDX  ID  DIFFICULTY        TITLE        TAGS

 ❌🙉💲   0   9      Easy     Palindrome Number  Math

[XXX] >> (Type help for commands): set FOLDER ./examples/python
[XXX] >> (Type help for commands): create 0
[INFO] Result written in folder: examples\python\9-palindrome-number

Current Limitations and futures 🚧

  • Up to now, the only possible target language to save the problem code snippet is Python3.