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

ollama-library-scraper

v1.1.0

Published

A TypeScript library for scraping model information from the Ollama model library website. Extract details, tags, and metadata from ollama.com/library with a simple, type-safe API.

Downloads

149

Readme

Ollama Library Scraper

npm version CI License: MIT TypeScript

Programmatically access Ollama's model library with a type-safe TypeScript API. Search models, extract metadata, compare variants, and retrieve download statistics—no HTML parsing required.

Installation

npm install ollama-library-scraper
yarn add ollama-library-scraper
pnpm add ollama-library-scraper
bun add ollama-library-scraper

Quick Start

import { OllamaScraper } from 'ollama-library-scraper';

const scraper = new OllamaScraper();

// Get all models
const models = await scraper.getModelListing();
console.log(`Found ${models.length} models`);

// Get specific model details
const details = await scraper.getModelDetails('llama3.1');
console.log(details);

Usage

Basic Usage

// ES Modules
import { OllamaScraper } from 'ollama-library-scraper';

// CommonJS
const { OllamaScraper } = require('ollama-library-scraper');

const scraper = new OllamaScraper();

// Get all models
const models = await scraper.getModelListing();
console.log(`Found ${models.length} models`);

// Search for models
const qwenModels = await scraper.getModelListing({
  query: 'qwen',
  sort: 'newest',
});

// Get model details
const details = await scraper.getModelDetails('qwen3-coder');
console.log(details);

// Get model tags
const tags = await scraper.getModelTags('qwen3-coder');
console.log(`Model has ${tags.length} tags`);

Advanced Examples

// Search with different sort options
const popularModels = await scraper.getModelListing({
  sort: 'most-popular',
});

const newestCodeModels = await scraper.getModelListing({
  query: 'code',
  sort: 'newest',
});

// Get details for a specific tag
const tagDetails = await scraper.getModelDetails('qwen3-coder', '30b-a3b-q4_K_M');

// Filter models by capabilities
const visionModels = (await scraper.getModelListing()).filter(model =>
  model.capabilities?.includes('vision')
);

const toolsModels = (await scraper.getModelListing()).filter(model =>
  model.capabilities?.includes('tools')
);

Real-World Examples

Find the most popular code models

const popularCodeModels = await scraper.getModelListing({
  query: 'code',
  sort: 'most-popular',
});

console.log('Top code models:', popularCodeModels.slice(0, 5));

Get all vision-capable models

const allModels = await scraper.getModelListing();
const visionModels = allModels.filter(model => model.capabilities?.includes('vision'));

console.log(`Found ${visionModels.length} vision models`);

Compare model sizes across variants

const modelName = 'llama3.1';
const tags = await scraper.getModelTags(modelName);

tags.forEach(tag => {
  console.log(`${tag.name}: ${tag.size}`);
});

Build a model recommendation system

async function recommendModels(userQuery: string) {
  const models = await scraper.getModelListing({
    query: userQuery,
    sort: 'most-popular',
  });

  return models.slice(0, 10).map(model => ({
    name: model.name,
    description: model.description,
    popularity: model.pulls,
    capabilities: model.capabilities || [],
  }));
}

const recommendations = await recommendModels('chat');

API Reference

OllamaScraper Class

getModelListing(options?)

Fetches the list of models from the Ollama library.

Parameters:

  • options (optional):
    • query?: string - Search query to filter models
    • sort?: SortOption - Sort order ('newest' | 'most-popular' | 'oldest' | 'alphabetical')

Returns: Promise<ModelListItem[]>

getModelDetails(modelName, tag?)

Gets detailed information about a specific model.

Parameters:

  • modelName: string - The name of the model (e.g., 'qwen3-coder')
  • tag?: string - Optional specific tag/version (e.g., '30b-a3b-q4_K_M')

Returns: Promise<ModelDetails>

getModelTags(modelName)

Retrieves all available tags for a specific model.

Parameters:

  • modelName: string - The name of the model

Returns: Promise<ModelTag[]>

Data Types

ModelListItem

interface ModelListItem {
  name: string; // e.g., "qwen3-coder"
  description: string; // Model description
  parameters: string[]; // e.g., ["30b", "480b"]
  pulls: string; // e.g., "17.9K"
  tags: number; // Number of available tags
  lastUpdated: string; // e.g., "2 days ago"
  url: string; // Full URL to model page
  capabilities?: string[]; // e.g., ["tools", "vision", "thinking", "embedding"]
}

ModelDetails

interface ModelDetails {
  name: string;
  description: string;
  downloads: string; // e.g., "18K"
  lastUpdated: string;
  readmeHtml?: string; // Raw HTML content from readme section
  readmeMarkdown?: string; // Converted Markdown content
  models: {
    name: string; // Tag name
    size: string; // e.g., "19GB"
    contextWindow?: string; // e.g., "256K"
    inputType?: string; // e.g., "Text", "Vision"
    lastUpdated: string;
  }[];
}

ModelTag

interface ModelTag {
  name: string; // Tag name
  size: string; // Model size (e.g., "19GB")
  digest: string; // Model digest hash (12 chars)
  modifiedAt: string; // Last modified date
  contextWindow?: string; // e.g., "256K"
  inputType?: string; // e.g., "Text", "Vision"
  aliases?: string[]; // e.g., ["latest"]
}

SortOption

type SortOption = 'newest' | 'most-popular' | 'oldest' | 'alphabetical';

Development

Setup

# Clone the repository
git clone https://github.com/helgesverre/ollama-library-scraper.git
cd ollama-library-scraper

# Install dependencies
npm install

# Run development mode
npm run dev

Scripts

  • npm run build - Build the TypeScript project
  • npm run dev - Run the example script in development mode
  • npm test - Run tests
  • npm run test:watch - Run tests in watch mode
  • npm run test:coverage - Run tests with coverage report
  • npm run format - Format all code files with Prettier
  • npm run format:check - Check code formatting
  • npm run lint - Run linting and formatting checks

Testing

The project uses Vitest for testing. Tests mock the HTTP requests to avoid hitting the actual website during testing.

# Run tests
npm test

# Run tests with coverage
npm run test:coverage

Error Handling

All methods throw errors with descriptive messages:

try {
  const models = await scraper.getModelListing();
} catch (error) {
  console.error('Failed to fetch models:', error.message);
}

Why Use This Library?

  • Avoid Manual HTML Parsing - Pre-built selectors and parsing logic
  • Type Safety - Full TypeScript definitions prevent runtime errors
  • Maintained - Regularly updated to match ollama.com structure changes
  • Well Tested - Comprehensive test suite ensures reliability
  • Simple API - Three main methods cover all use cases
  • Framework Agnostic - Works with any Node.js framework or runtime
  • No Official API - Ollama doesn't provide an API for their model library; this is the only programmatic way to access it

Important Notes

  • ⚠️ No Rate Limiting: Implement your own delays to be respectful of ollama.com servers
  • 🔄 HTML Changes: The scraper depends on ollama.com's HTML structure, which may change
  • 📦 No Caching: Each call makes a fresh HTTP request - implement caching if needed
  • 🌐 Network Required: All methods require internet connectivity
  • 🛡️ Error Handling: Always wrap calls in try-catch blocks for production use

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.