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

@galaxyproject/galaxy-api-client

v25.1.0

Published

A client library for the Galaxy API

Readme

Galaxy API Client

A standalone client library for the Galaxy API, built using the type definitions from the main Galaxy client.

Installation

npm install @galaxyproject/galaxy-api-client

Usage

Basic Usage

import { createGalaxyApi } from "@galaxyproject/galaxy-api-client";

// Create an instance of the Galaxy API client with a specific base URL
const api = createGalaxyApi("https://usegalaxy.org");

// Alternatively, use the default (current origin)
// const api = createGalaxyApi();

// Example: Get a list of histories
const { data, error } = await api.GET("/api/histories");

if (error) {
    console.error("Error fetching histories:", error);
} else {
    console.log("Histories:", data);
}

// For backward compatibility
import { GalaxyApi } from "@galaxyproject/galaxy-api-client";
const legacyApi = GalaxyApi(); // Uses current origin

Usage with API Keys and Custom Headers

import { createGalaxyApi } from "@galaxyproject/galaxy-api-client";

// Create a client with API key authentication and custom headers
const api = createGalaxyApi({
    baseUrl: "https://usegalaxy.org",
    apiKey: "your-api-key-here",
    headers: {
        Accept: "application/json",
    },
    fetchOptions: {
        credentials: "include", // Include cookies for CORS requests
        cache: "no-cache", // Don't cache responses
    },
});

// Now all requests will include the API key header and custom options
const { data, error } = await api.GET("/api/histories");

Type Safety

This package provides TypeScript types for Galaxy API endpoints and models:

import { createGalaxyApi, type HistorySummary, type DatasetEntry } from "@galaxyproject/galaxy-api-client";

const api = createGalaxyApi();

// Type-safe API calls
const { data: histories } = await api.GET("/api/histories");
// histories is typed as HistorySummary[] | undefined

// You can use the types for your variables
const myHistory: HistorySummary = {
    id: "123",
    name: "My History",
    // ...other required properties
};

Examples

See more in src/example.ts that demonstrate how to use the client:

Basic Example

import { createGalaxyApi } from "@galaxyproject/galaxy-api-client";

// Create a client with a specific Galaxy instance
const api = createGalaxyApi("https://usegalaxy.org");

// Example: Get a list of tools
async function getTools() {
    const { data, error } = await api.GET("/api/tools");

    if (error) {
        console.error("Error fetching tools:", error);
        return [];
    }

    // Log tool count
    console.log(`Found ${data.length} tools`);

    return data;
}

Notes

This package uses a symlink to reference API type definitions from the main Galaxy client while providing a standalone client implementation. This approach was chosen to:

  1. Minimize duplication of type definitions
  2. Ensure type definitions stay in sync with the main codebase
  3. Allow the client to work independently of Galaxy's internal utilities

Development

To work on this package:

  1. Make changes to the API type definitions in the main Galaxy client

  2. The type changes will automatically be available in this package via symlinks

  3. Synchronize the version with Galaxy:

    # Update the version in package.json from Galaxy's version.py
    npm run sync-version
  4. Build the library for distribution:

    # Install dependencies
    npm install
    
    # Build the library
    npm run build
    
    # Watch mode for development
    npm run dev

Version Synchronization

This package maintains version parity with Galaxy to indicate API compatibility. The version number in package.json is derived from Galaxy's lib/galaxy/version.py file but formatted to comply with npm's semver requirements.

Important: npm does not allow republishing the same version, even for development versions. When making changes to the client API during development:

  1. Manually increment the version before publishing:

    # Example: Update from 25.0.0-dev.0 to 25.0.0-dev.1
    npm version prerelease --preid=dev
  2. Or edit the npm version directly in package.json:

    {
        "version": "25.0.0-dev.1"
    }

There's also a script to automate this process of syncing with galaxy version that we may want to use in other contexts, too?:

# Using npm script
npm run sync-version

The script will:

  1. Read the version from Galaxy's version.py file
  2. Convert it to npm-compatible semver format
  3. Update the version in package.json if different

Version synchronization should be performed before each release to ensure the client API version accurately reflects the Galaxy API version it supports.

Testing

The package includes a few vitest tests as a sanity check, but we could do a lot more here:

# Run tests
npm test

# Run tests with watch mode (during development)
npm run test:watch

The tests verify:

  • Client creation with default and custom base URLs
  • Basic API interaction with proper typing
  • Error handling