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

@hirakinii-packages/ror-api-typescript

v0.1.1

Published

Type-safe TypeScript client for the Research Organization Registry (ROR) REST API v2

Downloads

30

Readme

ROR API v2 TypeScript Client

TypeScript npm version CI License: MIT

A robust, type-safe TypeScript client library for interacting with the Research Organization Registry (ROR) REST API (v2).

Overview

This library provides an easy-to-use interface for searching and retrieving research organization data registered in ROR. It includes type definitions that are fully compliant with the official JSON schema (v2.0/v2.1), supporting safe development in a TypeScript environment.

Key Features

  1. Health Check: Check the operational status of the ROR service (/heartbeat).
  2. List Records: Retrieve a list of ROR records.
  3. ID Lookup: Retrieve a single record by specifying a ROR ID (https://ror.org/...).
  4. Filter Search: Filter by status, organization type, country code, continent name, and more.
  5. Keyword Search: Search records using arbitrary keywords.
  6. Combined Search: Combine keyword and filter searches.
  7. Client-Id Header Support: Explicitly identify the caller via request headers (a ROR API best practice).
  8. Rate Limit Control: Automatic throttling to comply with the API usage limit (400 requests/min).

Installation

npm install ror-api-typescript
# or
yarn add ror-api-typescript
# or
pnpm add ror-api-typescript

Usage

Initialization

When initializing the client, it is recommended to specify an identifier (such as your app name or contact info) in the clientId option. This value is sent as the Client-Id request header.

import { RorClient } from 'ror-api-typescript';

const client = new RorClient({
  clientId: 'my-research-app/1.0 (mailto:[email protected])'
});

Health Check

const statusCode = await client.checkHealth();
if (statusCode === 200) {
  console.log('ROR API is up and running!');
}

List Organizations

const orgs = await client.listOrganizations();
console.log(`Fetched ${orgs.length} organizations`);

Get a Record by ROR ID

try {
  const org = await client.getOrganizationById('https://ror.org/01ggx4157');
  console.log(org.names[0]?.value); // "CERN"
} catch (error) {
  console.error('Record not found or API error', error);
}

Keyword Search

const results = await client.searchOrganizations('Harvard');
results.forEach(org => {
  console.log(`${org.id}: ${org.names[0]?.value}`);
});

Filter Search

const results = await client.filterOrganizations({
  'locations.geonames_details.country_code': 'JP',
  status: 'active',
});
console.log(`Active organizations in Japan: ${results.length}`);

Combined Keyword and Filter Search

const results = await client.searchAndFilter('university', {
  'locations.geonames_details.country_code': 'DE',
  status: 'active',
});
console.log(`Found ${results.length} records.`);
results.forEach(org => {
  console.log(`- ${org.id}: ${org.names[0]?.value}`);
});

API Reference

RorClient

| Method | Signature | Description | |--------|-----------|-------------| | checkHealth | () => Promise<number> | Returns the HTTP status code of the /heartbeat endpoint | | listOrganizations | () => Promise<RorOrganization[]> | Returns all organizations (first page) | | getOrganizationById | (rorId: string) => Promise<RorOrganization> | Returns the organization with the given ROR ID; throws if not found | | searchOrganizations | (query: string) => Promise<RorOrganization[]> | Returns organizations matching the keyword query | | filterOrganizations | (filters: FilterParams) => Promise<RorOrganization[]> | Returns organizations matching the filter parameters | | searchAndFilter | (query: string, filters: FilterParams) => Promise<RorOrganization[]> | Combines keyword search and filter |

FilterParams

Key–value pairs for the filter query parameter. Available keys:

| Key | Example value | |-----|--------------| | status | "active", "inactive", "withdrawn" | | types | "Education", "Facility", "Nonprofit" | | locations.geonames_details.country_code | "JP", "US", "DE" | | locations.geonames_details.country_name | "Japan", "United States" | | locations.geonames_details.continent_code | "AS", "EU", "NA" | | locations.geonames_details.continent_name | "Asia", "Europe" |

Exported Types

import type {
  RorOrganization,  // Full organization record
  RorClientOptions, // Constructor options
  FilterParams,     // Filter key–value map
  FilterKey,        // Union of valid filter key strings
} from 'ror-api-typescript';

Type Definitions

This library exports the RorOrganization interface, which complies with the official ROR schema (v2.0/v2.1). Since this type is applied to all return values, you benefit from IDE code completion and compile-time type checking.

A Zod schema (rorOrganizationSchema) and a type guard (isRorOrganization) are also exported for runtime validation.

import { isRorOrganization, rorOrganizationSchema } from 'ror-api-typescript';

// Type guard
if (isRorOrganization(data)) {
  console.log(data.id);
}

// Zod parse
const org = rorOrganizationSchema.parse(data);

Rate Limiting

The ROR API has a limit of 400 requests per minute. This client automatically throttles requests when approaching the limit, so you do not need to worry about receiving 429 Too Many Requests errors.

Examples

Runnable examples are available in the examples/ directory.

npx tsx examples/basic-usage.ts

License

MIT. See LICENSE for details.