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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@needle-ai/needle

v1.4.2

Published

This Typescript library provides convenient access to the Needle API.

Readme

Needle Typescript Library

NPM Version

This Typescript library provides convenient acccess to Needle API. Using Needle API you can effortlessly develop RAG-based agentic applications, see below for an example. There are various functions and data types which will help you get started quickly. Some functionality will be available in REST API earlier than this library therefore we recommend taking a look the the complete documentation. Thank you for flying with us. 🚀

Note: this library is built for Node.js runtime.

Installation

This library requires Node.js >18 and a Javascript package manager to use (we recommend bun). You don't need the sources unless you want to modify it. You can install with:

npm install @needle-ai/needle

or

bun install @needle-ai/needle

or with any other package manager of your choice.

Usage ⚡️

To get started, generate an API key for your account in developer settings menu at Needle. Note that your key will be valid until you revoke it. Set the following env variable before you run your code:

export NEEDLE_API_KEY=<your-api-key>

NeedleClient reads the API key from the environment by default. If you like to override this behaviour you can pass it in as a parameter.

Retrieve context from Needle

import { Needle } from "@needle-ai/needle/v1";

const ndl = new Needle();

const prompt =
  "What techniques moved into adopt in this volume of technology radar?";

const results = await ndl.collections.search({
  collection_id: "<collection-id>",
  text: prompt,
});

Needle instantly extracts relevant passages for your prompt from your files. You can look up your collection id in the Needle dashboard.

Complete your RAG pipeline

To compose a human friendly answer use an LLM provider of your choice. For the demo, we use OpenAI in this example:

import OpenAI from "openai";
import { type ChatCompletionMessageParam } from "openai/src/resources/index.js";

const openai = new OpenAI();
const messages: ChatCompletionMessageParam[] = [
    { role: "system", content: `
        You are a helpful assistant. Answer the question based on the context.

        Context:

        ${results.map(r => r.content).join('\n')}
    ` },
    { role: "user", content: prompt }
];

const completion = await openai.chat.completions.create({
    model: "gpt-4o-mini",
    messages
});

const answer = completion.choices[0].message.content;
console.log(answer)
// -> Retrieval-Augmented Generation (RAG) is the technique that moved into "Adopt" in this volume of the Technology Radar.

This is one basic example of a RAG pipeline you can quickly implement using Needle and OpenAI. Needle API helps you with hassle-free contextualization however does not limit you to a certain RAG technique. You can furthermore add Needle search as a tool to your agentic application to allow LLMs trigger search autonomously.

Let us know what you build in our Discord channel. Similarly, if you have a feature request or a bug report, please ping us there - we are happy to help! 😉

License

needle-typescript is distributed under the terms of the MIT license.