NDEx JavaScript Client API Reference - v0.6.0-alpha.5
    Preparing search index...

    Class UnifiedNetworkService

    UnifiedNetworkService - Provides access to both V2/V3 network services Allows individual function calls to choose between v2 and v3 APIs

    Index

    Constructors

    Accessors

    Methods

    • Get network summary using V3 API

      Retrieves comprehensive summary information for a network including metadata, statistics, permissions, and other network properties using the V3 API.

      Parameters

      • networkUUID: string

        The UUID of the network to get summary for

      • options: AccessParams = {}

        Access options including optional access key for private networks

      Returns Promise<NetworkSummaryV3>

      Promise resolving to NetworkSummaryV3 object containing network summary information

    • Update network summary using V3 to V2 transformation

      Updates network summary information by accepting a NetworkSummaryV3 object, transforming it to the V2 format, and calling the V2 API endpoint. This provides a unified interface for updating network summaries while maintaining compatibility with the existing V2 backend infrastructure.

      Parameters

      • networkUUID: string

        The UUID of the network to update

      • networkSummaryV3: NetworkSummaryV3

        The updated network summary in V3 format

      Returns Promise<void>

      Promise that resolves when the update is complete

      // Update network summary using V3 format
      const summaryV3: NetworkSummaryV3 = {
      externalId: '12345678-1234-1234-1234-123456789abc',
      name: 'Updated Network Name',
      description: 'Updated network description',
      nodeCount: 150,
      edgeCount: 200,
      visibility: 'PUBLIC',
      owner: 'username',
      ownerUUID: 'user-uuid',
      creationTime: 1234567890,
      modificationTime: 1234567890,
      isReadOnly: false,
      isValid: true,
      hasLayout: true,
      hasSample: false,
      updatedBy: 'username',
      properties: {
      category: { t: 'string', v: 'biological' },
      version: { t: 'double', v: 2.1 }
      }
      };

      await client.networks.updateNetworkSummary('network-uuid', summaryV3);
    • Delete network

      Parameters

      • networkUUID: string

        The UUID of the network to delete

      • permanent: boolean = false

        If true, permanently delete the network. If false (default), soft delete to trash for 30 days

      Returns Promise<void>

    • Create network DOI

      Requests a DOI (Digital Object Identifier) for a network. A reference is not required to request a DOI. If you want the ability to add or modify a reference later on, set isCertified to true. When certified, the network will be permanently locked, made publicly visible, and no further changes will be allowed.

      Parameters

      • params: { networkId: string; isCertified: boolean; contactEmail: string }

        DOI request parameters

        • networkId: string

          UUID of the network to create a DOI for

        • isCertified: boolean

          If true, network will be permanently locked and made public with no further changes allowed

        • contactEmail: string

          Email address that the DOI creation confirmation should be sent to

      Returns Promise<void>

      Promise that resolves when the DOI request is submitted

      // Request a DOI for a network without certification
      await client.networks.createNetworkDOI({
      networkId: '12345678-1234-1234-1234-123456789abc',
      isCertified: false,
      contactEmail: 'user@example.com'
      });

      // Request a certified DOI (network will be permanently locked)
      await client.networks.createNetworkDOI({
      networkId: '12345678-1234-1234-1234-123456789abc',
      isCertified: true,
      contactEmail: 'user@example.com'
      });
    • Get attributes of selected nodes

      Retrieves specific attributes for a set of nodes in a network. The server will return a 404 error if the network has no attributes on nodes.

      Parameters

      • networkUUID: string

        The UUID of the network

      • nodeSelection: { ids: number[]; attributeNames: string[] }

        Object containing node IDs and attribute names to retrieve

        • ids: number[]

          Array of node IDs (long numbers) to get attributes for

        • attributeNames: string[]

          Array of attribute names to retrieve

      • options: AccessParams = {}

        Access options including optional access key

      Returns Promise<Record<string, any>>

      Promise resolving to a JSON object where keys are stringified node IDs and values are the selected attributes for that node

      When the network has no attributes on nodes

    • Neighborhood query (migrated from original NDEx.js)

      Performs a neighborhood search within a network, returning nodes and edges within the specified search depth from nodes matching the search terms. Can return either raw CX1 or CX2 format based on outputCX2 parameter.

      Parameters

      • networkUUID: string

        The UUID of the network to search

      • searchTerms: string

        Search string to find starting nodes

      • OptionalsaveResult: boolean

        Whether to save the query result as a new network

      • Optionalparameters: {
            searchDepth?: number;
            edgeLimit?: number;
            errorWhenLimitIsOver?: boolean;
            directOnly?: boolean;
            nodeIds?: number[];
        }

        Additional query parameters

        • OptionalsearchDepth?: number

          How many hops to search (default: 1)

        • OptionaledgeLimit?: number

          Maximum number of edges to return

        • OptionalerrorWhenLimitIsOver?: boolean

          Throw error if edge limit exceeded

        • OptionaldirectOnly?: boolean

          Only include direct connections

        • OptionalnodeIds?: number[]

          Specific node IDs to start search from

      • outputCX2: boolean = false

        If true, return CX2 format via V3 API; if false, return CX1 format via V2 API

      Returns Promise<any[] | CX2Network>

      Promise resolving to raw CX1 or CX2 network data

    • Interconnect query (migrated from original NDEx.js)

      Finds connections between nodes matching the search terms within a network. Returns the interconnected subnetwork as either raw CX1 or CX2 format. Can return either raw CX1 or CX2 format based on outputCX2 parameter.

      Parameters

      • networkUUID: string

        The UUID of the network to search

      • searchTerms: string

        Search string to find nodes to interconnect

      • OptionalsaveResult: boolean

        Whether to save the query result as a new network

      • Optionalparameters: { edgeLimit?: number; errorWhenLimitIsOver?: boolean; nodeIds?: number[] }

        Additional query parameters

        • OptionaledgeLimit?: number

          Maximum number of edges to return

        • OptionalerrorWhenLimitIsOver?: boolean

          Throw error if edge limit exceeded

        • OptionalnodeIds?: number[]

          Specific node IDs to find connections between

      • outputCX2: boolean = false

        If true, return CX2 format via V3 API; if false, return CX1 format via V2 API

      Returns Promise<any[] | CX2Network>

      Promise resolving to raw CX1 or CX2 network data

    • Get network permissions by UUIDs (migrated from original NDEx.js)

      Retrieves network permissions for multiple networks in a single batch request. Uses the V2 API batch endpoint to efficiently get permission information.

      Parameters

      • uuidList: string[]

        Array of network UUIDs to retrieve permissions for

      Returns Promise<any[]>

      Promise resolving to permission information for the specified networks

    • Export networks (migrated from original NDEx.js)

      Creates an export job for networks using the V2 batch export endpoint. This allows exporting multiple networks in various formats.

      Parameters

      • exportJob: any

        Export job configuration specifying networks and format

      Returns Promise<any>

      Promise resolving to export job result

    • Move networks to folder (migrated from original NDEx.js)

      Moves multiple networks to a specified folder using the V3 API. This is a V3-specific feature for organizing networks in folders.

      Parameters

      • networkIds: string[]

        Array of network IDs to move

      • OptionalfolderId: string

        Target folder ID to move networks to

      Returns Promise<any>

      Promise resolving when networks are moved

    • Set visibility for multiple files (networks, folders, shortcuts)

      Changes visibility settings for multiple NDEx objects using the V3 API. This function can update visibility for any combination of networks, folders, and shortcuts. Files are validated to ensure proper UUID format and valid file types.

      Parameters

      • files: { files: Record<string, NDExFileType> }

        Object containing a 'files' property with UUID-to-filetype mappings

        • files: Record<string, NDExFileType>

          Record where keys are UUIDs and values are NDExFileType ('NETWORK', 'FOLDER', or 'SHORTCUT')

      • visibility: Visibility

        Visibility setting: 'PUBLIC', 'PRIVATE', or 'UNLISTED'

      Returns Promise<any>

      Promise resolving when visibility is successfully updated

      Error if files validation fails or API request fails

      // Set multiple files to public visibility
      await client.networks.setNetworksVisibility({
      files: {
      '12345678-1234-1234-1234-123456789abc': 'NETWORK',
      '87654321-4321-4321-4321-876543210fed': 'FOLDER',
      '11111111-2222-3333-4444-555555555555': 'SHORTCUT'
      }
      }, 'PUBLIC');

      // Set networks to private visibility
      await client.networks.setNetworksVisibility({
      files: {
      'network-uuid-1': 'NETWORK',
      'network-uuid-2': 'NETWORK'
      }
      }, 'PRIVATE');
    • Get network access key

      Retrieves the access key for a network if it has been enabled for public access. When a network has an access key enabled, it can be accessed by others without explicit permissions using this key.

      Parameters

      • networkUUID: string

        The UUID of the network to get the access key for

      Returns Promise<null | { accessKey: string }>

      Promise resolving to an object with accessKey property when enabled, or null when access key is not enabled on this network

      // Check if network has an access key
      const result = await client.networks.getNetworkAccessKey('12345678-1234-1234-1234-123456789abc');

      if (result) {
      console.log('Access key:', result.accessKey); // "sdfdfdfsdfdsfs"
      // Use the access key to access the network
      const networkData = await client.networks.getRawCX2Network(networkUUID, { accessKey: result.accessKey });
      } else {
      console.log('No access key enabled for this network');
      }
    • Get random edges from network (migrated from original NDEx.js)

      Retrieves a random sample of edges from a network using the V3 API. This is useful for previewing large networks or sampling edge data.

      Parameters

      • networkUUID: string

        The UUID of the network to get edges from

      • limit: number

        Number of random edges to retrieve (must be greater than 0)

      • OptionalaccessKey: string

        Optional access key for private networks

      Returns Promise<CX2Edge[]>

      Promise resolving to array of CX2Edge objects

      Error if limit is less than or equal to 0

    • Get aspect elements (migrated from original NDEx.js)

      Retrieves elements from a specific aspect of a network using the V3 API. This function can be used to get nodes, edges, or other aspect data with optional size limiting and access key support for private networks.

      Parameters

      • networkUUID: string

        The UUID of the network to get aspect elements from

      • aspectName: string

        Name of the aspect to retrieve (e.g., 'nodes', 'edges', 'networkAttributes')

      • Optionallimit: number

        Optional maximum number of elements to return

      • OptionalaccessKey: string

        Optional access key for private networks

      Returns Promise<any[]>

      Promise resolving to array of aspect elements

      // Get first 100 nodes from a network
      const nodes = await client.networks.getAspectElements('network-uuid', 'nodes', 100);

      // Get all edges from a network
      const edges = await client.networks.getAspectElements('network-uuid', 'edges');
    • Get filtered edges (migrated from original NDEx.js)

      Retrieves edges from a network that match specific filtering criteria on a column value. The function supports both CX1 and CX2 formats based on the format parameter, with CX2 being the default format used by the server.

      Parameters

      • networkUUID: string

        The UUID of the network to get filtered edges from

      • columnName: string

        Name of the edge attribute column to filter on

      • valueString: string

        Value to filter by (converted to string for comparison)

      • operator: ">" | "<" | "=" | "!="

        Filtering operation: '>' | '<' | '=' | '!='

      • Optionallimit: number

        Optional maximum number of edges to return (default: -1 = all matching edges)

      • Optionalorder: "asc" | "desc"

        Optional sort order for edges before applying limit: 'asc' | 'desc' (default: 'desc')

      • Optionalformat: "cx2" | "cx"

        Optional output format: 'cx' | 'cx2' (default: 'cx2')

      • OptionalaccessKey: string

        Optional access key for private networks

      Returns Promise<CX2Edge[] | CX1Edge[]>

      Promise resolving to array of edges in the specified format

      // Get edges with weight > 0.5 in CX2 format (default)
      const cx2Edges = await client.networks.getFilteredEdges(
      'network-uuid', 'weight', '0.5', '>'
      );

      // Get top 10 edges with highest score in CX1 format
      const cx1Edges = await client.networks.getFilteredEdges(
      'network-uuid', 'score', '0', '>', 10, 'desc', 'cx'
      );

      // Get edges where interaction equals 'pp'
      const ppEdges = await client.networks.getFilteredEdges(
      'network-uuid', 'interaction', 'pp', '=', undefined, undefined, 'cx2'
      );
    • Get CX2 metadata (migrated from original NDEx.js)

      Retrieves metadata information for all aspects in a CX2 network format. This function provides aspect metadata including element counts for each aspect in the network using the V3 API.

      Parameters

      • networkUUID: string

        The UUID of the network to get CX2 metadata for

      • OptionalaccessKey: string

        Optional access key for private networks

      Returns Promise<CX2MetaData[]>

      Promise resolving to array of CX2MetaData objects

      // Get CX2 metadata for a network
      const metaData = await client.networks.getCX2MetaData('network-uuid');
      console.log(metaData); // [{ name: 'nodes', elementCount: 100 }, { name: 'edges', elementCount: 150 }]

      // Get CX2 metadata for a private network
      const privateMetaData = await client.networks.getCX2MetaData('private-network-uuid', 'access-key');
    • Create network from raw CX2 data (migrated from original NDEx.js)

      Creates a new network on NDEx from raw CX2 data using the V3 API. This function delegates to the NetworkServiceV3 implementation.

      Parameters

      • cx2Data: CX2Network | CX2Network

        Raw CX2 network data as an object or CX2Network instance

      • options: { visibility?: Visibility; folderId?: string } = {}

        Creation options including visibility and folderId

        • Optionalvisibility?: Visibility

          Network visibility: 'PUBLIC', 'PRIVATE', or 'UNLISTED' (default: 'PRIVATE')

        • OptionalfolderId?: string

          UUID of the folder to create the network in. If omitted, network is created in user's home directory

      Returns Promise<NDExObjectUpdateStatus>

      Promise resolving to NDExObjectUpdateStatus with uuid and modificationTime

      // Create private network from raw CX2 data in user's home directory
      const result = await client.networks.createNetworkFromRawCX2(cx2Data);
      console.log(result.uuid); // "12345678-1234-1234-1234-123456789abc"

      // Create public network from raw CX2 data in a specific folder
      const publicResult = await client.networks.createNetworkFromRawCX2(cx2Data, {
      visibility: 'PUBLIC' as Visibility,
      folderId: '87654321-4321-4321-4321-876543210fed'
      });
      console.log(publicResult.uuid);
    • Update network from raw CX2 data (migrated from original NDEx.js)

      Updates an existing network with new raw CX2 data using the V3 API. This function replaces the entire network content with the provided CX2 data.

      Parameters

      • networkUUID: string

        The UUID of the network to update

      • rawCX2: any

        Raw CX2 network data as an object or CX2Network instance

      Returns Promise<void>

      Promise resolving when the network update is complete

      // Update existing network with new CX2 data
      await client.networks.updateNetworkFromRawCX2('network-uuid', updatedCx2Data);
    • Set read-only flag on a network

      Sets or unsets the read-only flag for a network using the V2 API. When a network is marked as read-only, it cannot be modified.

      Parameters

      • networkId: string

        The UUID of the network to modify

      • readOnly: boolean

        true to set the network as read-only, false to allow modifications

      Returns Promise<void>

      Promise resolving when the read-only status is updated

      // Set network as read-only
      await client.networks.setReadOnly('network-uuid', true);

      // Allow network modifications
      await client.networks.setReadOnly('network-uuid', false);