npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

Registry Search API: Return Exact Match for Short Queries

As part of the API rate-limiting, the npm registry search API returns no results for any search query that is fewer than four characters. (Note: the npm blog entry about rate-limiting incorrectly specifies this limit as three characters.)

This is disingenuous because there ARE packages with names that are shorter than four characters and those packages currently cannot be searched by name.

I propose that the search API be changed so that queries with fewer than four characters return precisely one exact match, if a package of that name exists. This keeps the server load low but simultaneously makes the search API much better. After all, a search for “aa” shouldn’t return zero results when there IS a package named “aa”. Since you allow package names shorter than four characters, the search API should be capable of finding them.

As a workaround in my app, I currently just query the package API endpoint when a user searches for something shorter than four characters. While that works for me, improving the search API to at least return SOMETHING for short queries would be better than the current situation, where so many packages aren’t searchable by name.

So…I guess the answer is that all packages with 3 or fewer characters in their name aren’t searchable via the API?