orcid-parser
    Preparing search index...

    ORCID API client for fetching and parsing works and work details.

    This class provides methods to interact with the ORCID public API, fetch publication data, and perform various filtering and analysis operations.

    Basic usage:

    const client = new Orcid('0000-0002-1825-0097');
    const works = await client.fetchWorks();
    console.log(`Found ${works.length} publications`);

    With custom configuration:

    const client = new Orcid('0000-0002-1825-0097', {
    timeout: 15000,
    baseURL: 'https://pub.orcid.org/v3.0'
    });
    Index

    Constructors

    • Creates a new ORCID API client.

      Parameters

      • orcidId: string

        ORCID identifier (can include or omit the full URL)

      • config: OrcidClientConfig = {}

        Optional client configuration

      Returns Orcid

      If orcidId is empty or invalid

      // With just ORCID ID
      const client1 = new Orcid('0000-0002-1825-0097');

      // With full URL
      const client2 = new Orcid('https://orcid.org/0000-0002-1825-0097');

      // With configuration
      const client3 = new Orcid('0000-0002-1825-0097', { timeout: 20000 });

    Properties

    baseURL: string

    Base URL for API requests

    orcidId: string

    The ORCID identifier for this client instance

    timeout: number

    Request timeout in milliseconds

    DEFAULT_HEADERS: Record<string, string> = ...

    Default headers for all ORCID API requests.

    Methods

    • Fetches detailed work records for specified put codes.

      Parameters

      • putCodes: number[]

        Array of put codes to fetch (maximum 100)

      Returns Promise<Work[]>

      Promise resolving to array of detailed work objects

      If more than 100 put codes are provided or API request fails

      Put codes are unique identifiers for work records in ORCID. This method uses the bulk API endpoint for efficiency.

      const works = await client.fetchWithCodes([12345, 67890]);
      
    • Fetches detailed work records for given put codes.

      Parameters

      • OptionalputCodes: string | number | string[] | number[] | null

        Put code(s) to fetch, or null/empty to fetch first 100 works

      Returns Promise<Work[]>

      Promise resolving to array of detailed work objects

      If API request fails

      • If no codes provided: fetches first 100 works
      • If single code: fetches that work
      • If array of codes: fetches all specified works (max 100)
      // Fetch first 100 works
      const all = await client.fetchWorks();

      // Fetch specific work
      const one = await client.fetchWorks(12345);

      // Fetch multiple works
      const some = await client.fetchWorks([12345, 67890]);
    • Fetches all work summaries associated with this ORCID ID.

      Returns Promise<WorkSummary[]>

      Promise resolving to array of work summaries

      If the API request fails or times out

      Work summaries contain basic metadata without full details like citations or contributors.

      const summaries = await client.fetchWorkSummaries();
      summaries.forEach(s => console.log(s.title));
    • Filters cached works by type.

      Parameters

      • types: string | string[]

        Single type or array of types to match

      Returns Promise<Work[]>

      Promise resolving to filtered array of works

      Uses cached works from getWorks.

      const articles = await client.filterByType('journal-article');
      const pubs = await client.filterByType(['journal-article', 'conference-paper']);
    • Filters cached works by publication year range.

      Parameters

      • start: number

        Start year (inclusive)

      • end: number

        End year (inclusive)

      Returns Promise<Work[]>

      Promise resolving to filtered array of works

      Uses cached works from getWorks.

      const recent = await client.filterByYearRange(2020, 2024);
      
    • Computes statistics for cached works.

      Returns Promise<OrcidStats>

      Promise resolving to statistics object

      Uses cached works from getWorks.

      const stats = await client.getStats();
      console.log(`Total: ${stats.total}`);
      console.log(`Types:`, stats.byType);
      console.log(`Year range: ${stats.yearRange.min}-${stats.yearRange.max}`);
    • Gets works associated with the ORCID, with automatic caching.

      Returns Promise<Work[]>

      Promise resolving to array of works

      If API request fails

      This method caches the results. First call fetches from API, subsequent calls return cached data. Use fetchWorks to bypass cache.

      const works = await client.getWorks();
      const sameWorks = await client.getWorks(); // Returns cached data
    • Groups cached works by a specified property.

      Parameters

      • property:
            | (keyof WorkSummary)
            | "shortDescription"
            | "citation"
            | "type"
            | "contributors"
            | "languageCode"
            | "country"

        Property key to group by

      Returns Promise<Record<string, Work[]>>

      Promise resolving to object mapping group keys to work arrays

      Uses cached works from getWorks.

      const byType = await client.groupBy('type');
      const byYear = await client.groupBy('publicationYear');
    • Sorts cached works by publication date.

      Parameters

      • order: "asc" | "desc" = 'desc'

        Sort order: 'asc' or 'desc' (default: 'desc')

      Returns Promise<Work[]>

      Promise resolving to sorted array of works

      Uses cached works from getWorks.

      const newest = await client.sortByDate('desc');
      const oldest = await client.sortByDate('asc');