Skip to main content
https://app.travis-ci.com/ndexbio/ndex2-client.svg?branch=master https://img.shields.io/pypi/v/ndex2.svg https://coveralls.io/repos/github/ndexbio/ndex2-client/badge.svg?branch=master Documentation Status

Overview

The NDEx2 Python Client provides methods to access NDEx via the NDEx REST Server API. As well as methods for common operations on networks via the NiceCXNetwork class.

Dependencies

Compatibility

Python 3.5+

Installation

The NDEx2 Python Client module can be installed from the Python Package Index (PyPI) repository using PIP:

pip install ndex2

If you already have an older version of the ndex2 module installed, you can use this command instead:

pip install --upgrade ndex2

Resources

  • The NDEx2 Python Client documentation is available on Read the Docs.

  • Please refer to our Jupyter Notebook Tutorials GitHub repository for code examples to work with networks using the NDEx2 Python Client and NiceCX object class.

License

See LICENSE.txt

History

3.12.0 (2025-08-12)

  • Enhancements
    • Added namespace attributes to ndex2.client.Ndex2 exposing the NDEx v3 API, so a single client covers both API versions: client.files (folders, shortcuts, trash, sharing, file search), client.networks (summaries, aspects, queries, export, ownership), client.users and client.admin.

    • Added ndex2.transport.HttpTransport, shared by every namespace. It is built on the session Ndex2 already creates, so credentials are held in one place and changing them applies to all calls.

    • Added FileType, Visibility and Permissions to ndex2.constants.

    • Added folder_id to Ndex2.save_new_cx2_network() and Ndex2.save_cx2_stream_as_new_network(), creating the network directly inside a folder. Omitting it leaves the request unchanged.

    • Added ndex2.exceptions.raise_from_requests_http_error() and raise_from_exception(), the shared mapping from HTTP status code to exception type.

  • Deprecations
    • Network set and group methods now emit a DeprecationWarning pointing at the namespace equivalent: create_networkset, get_networkset, get_network_set, get_networksets_for_user_id, delete_networkset, add_networks_to_networkset, delete_networks_from_networkset, update_network_group_permission, grant_networks_to_group, and the include_groups argument of search_networks.

    • These methods remain fully supported and there is no planned removal. On the server a network set is stored as a folder, and a group as a folder several users hold permissions on, so the v2 endpoints continue to work. Because a network set is a folder, client.files.get_folder() accepts a network set UUID and network sets appear in client.files.search().

  • Notes
    • No existing method was removed, renamed, or changed in behaviour. The v3 endpoints are additive.

    • Some namespace methods overlap a flat method where the v3 endpoint offers more, for example client.networks.get_summary() reports folderId and client.networks.delete() moves a network to the trash rather than deleting it outright. Both remain available; see the v3 API namespaces page in the documentation.

3.11.0 (2025-07-22)

  • Enhancements
    • Added CX2Network.rename_attribute method to rename attributes in the network.

3.10.0 (2025-01-14)

  • Enhancements
    • Added store_layout_in_pos argument in get_graph method of CX2NetworkXFactory that saves layout coordinates in G.pos (x and y) and G.zpos (z).

    • Added get_layout_from_pos argument in get_cx2network method of NetworkXToCX2NetworkFactory that determines the source of the layout coordinates. If True, the layout is derived from G.pos (x and y) and G.zpos. If False, the layout uses the (x, y, z) values specified as the node attributes.

    • Added interaction_col argument in get_cx2network of PandasDataFrameToCX2NetworkFactory that allows to specify the name of the column with edge interactions

  • Bug fixes
    • Fix for string IDs in NetworkX networks - cast to integer if possible or add as name attribute.

    • Fix for DataFrames without column names

3.9.0 (2024-06-18)

  • Enhancements
    • Added set_name(), remove_node_attribute(), remove_edge_attribute, get_opaque_aspect(), and set_opaque_aspect() to CX2Network class.

  • Bug fixes
    • Fixed bug in type conversion. Datatypes in shorter form such as ‘str’, ‘int’ etc. are accepted.

3.8.0 (2024-02-07)

  • Enhancements
    • Added add_network_attribute(), add_node_attribute(), add_edge_attribute(), lookup_node_id_by_name() to CX2Network class.

    • Added new parameters to get_cx2network in PandasDataFrameToCX2NetworkFactory to make it easier to convert Pandas Dataframe.

    • Added get_nodelist_table() to CX2NetworkPandasDataFrameFactory class.

3.7.0 (2024-01-03)

  • Enhancements
    • Added CX2NetworkXFactory under cx2.py module to convert CX2Network object to NetworkX Graph

    • Added NetworkXToCX2NetworkFactory under cx2.py module to convert NetworkX Graph to CX2Network object

    • Added PandasDataFrameToCX2NetworkFactory under cx2.py module to convert Pandas DataFrame to CX2Network object

    • Added CX2NetworkPandasDataFrameFactory under cx2.py module to convert CX2Network object to Pandas DataFrame

3.6.0 (2023-11-14)

  • Enhancements
    • Added CX2Network class under cx2.py module to represent networks CX2 format

    • Added RawCX2NetworkFactory class under cx2.py to create CX2Network objects

    • Added NoStyleCXToCX2NetworkFactory class under cx2.py to convert NiceCXNetwork to CX2Network

  • Bug fixes

3.5.1 (2023-04-11)

  • Bug fixes
    • Fixed bug where ndex2.create_nice_cx_from_networkx() fails with numpy version 1.24 Issue #96

    • Updated post and put calls in client.py to only pass credentials if they are set. This change is to accommodate changes in upcoming version 3 of requests library

3.5.0 (2022-06-28)

  • Enhancements
    • Added skip_version_check parameter to Ndex2() constructor to let caller optionally bypass NDEx server call to see if v2 endpoint is supported

    • Added the following CX2 methods to Ndex2() client: get_network_as_cx2_stream(), get_network_aspect_as_cx2_stream(), save_cx2_stream_as_new_network(), save_new_cx2_network(), and update_cx2_network() Issue #87

    • In Ndex2() client, methods that raise NDExError exceptions from calls to NDEx server will now raise the more specific NDExUnauthorizedError subclass when the response from NDEx server is a 401 aka unauthorized.

    • Added new parameters dataconverter and include_attributes to NiceCXNetwork.to_pandas_dataframe(). dataconverter parameter specifies data type conversion and include_attributes parameter lets caller specify whether all node/edge attributes are added to the resulting DataFrame

    • Added new parameter to ndex2.create_nice_cx_from_server() named ndex_client that lets caller specify NDex2() client object to use.

    • Passing None for the server positional parameter into ndex2.create_nice_cx_from_server(None, uuid='XXXX') will default to the production NDEx server

  • Bug fixes
    • Fixed bug where creation of NiceCXNetwork from networkx via ndex2.create_nice_cx_from_networkx() incorrectly set the data type for boolean values to integer. Issue #83

    • Fixed bug where converting NiceCXNetwork to networkx and back does not handle name attribute correctly. Issue #84

    • Fixed bug where @context was lost if it was set as aspect in CX format and loaded into NiceCXNetwork object. Issue #88

    • Fixed bug where creation of NiceCXNetwork from networkx via ndex2.create_nice_cx_from_networkx() incorrectly set the data type for empty list to string. Issue #90

    • Fixed bug where Y coordinates of nodes would be inverted when converting to/from networkx from NiceCXNetwork. This was due to differences in coordinate systems between networkx and NiceCXNetwork

    • DefaultNetworkXFactory networkx converter (used by NiceCXNetwork.to_networkx(mode='default')) no longer converts edge attributes that are of type list into strings delimited by commas

    • Fixed bug where ndex2.create_nice_cx_from_server() failed on networks with provenanceHistory aspect

  • Removals
    • Removed unused test methods from internal class NiceCXBuilder: load_aspect(), stream_aspect(), stream_aspect_raw()

    • Removed the following deprecated methods from NiceCXNetwork: add_node(), add_edge(), get_edge_attribute_object(), get_node_attribute_objects(), get_edge_attribute_objects(), add_metadata(), get_provenance(), set_provenance(), __merge_node_attributes(), create_from_pandas(), create_from_networkx(), create_from_server(), upload_new_network_stream(), & create_from_cx()

3.4.0 (2021-05-06)

  • Added offset and limit parameters to Ndex2.get_network_ids_for_user() to enable retrieval of all networks for a user. Issue #78

  • Switched NiceCXNetwork.upload_to() to named arguments and added client parameter. Issue #80

  • Switched NiceCXNetwork.update_to() to named arguments and added client parameter. Issue #81

  • Fixed documentation NiceCXNetwork.update_to() to correctly state method returns empty string upon success. Issue #82

  • Fixed bug in NiceCXNetwork.set_opaque_aspect() where passing None in the aspect_elements parameter raised an error instead of removing the aspect

  • Added Ndex2.get_user_by_id() method to get user information by NDEx user Id.

  • Added Ndex2.get_id_for_user() method to get NDEx user Id by username.

  • Added Ndex2.get_networksets_for_user_id() to get Network Sets for a given user Id. Issue #61

  • Improved documentation by adding intersphinx to provide links to python documentation for python objects.

3.3.3 (2021-04-22)

  • Fixed bug where NiceCXNetwork.to_networkx() fails with ValueError when installed networkx version has X.Y.Z format (example: 2.5.1) Issue #79

3.3.2 (2021-04-13)

  • Fixed bug where NiceCXNetwork.create_node() and .create_edge() overwrote existing nodes/edges. Issue #60

  • Fixed bug where enum34 package would be unnecessarily installed on versions of Python 3.4 and newer. Issue #76

  • Improved documentation for Ndex2.set_network_properties() method. Issue #77

3.3.1 (2019-09-23)

  • Added MANIFEST.in file to include README.rst, HISTORY.rst, and LICENSE.txt files as well as documentation and tests so python setup.py install will work properly on distribution of this client on PyPI. Thanks to Ben G. for catching this. Issue #62

  • Minor updates to README.rst

3.3.0 (2019-09-11)

  • Fixed bug where if server version is not 2.0 exactly then Ndex2() object incorrectly falls back to version of 1.3 of REST calls Issue #40

  • Fixed bug in NiceCXNetwork.add_network_attribute() method where type not properly reset when adding duplicate attribute Issue #50

  • Added delete_networksets() method to Ndex2 client to allow deletion of networksets Issue #59

3.2.0 (2019-04-23)

  • Verify consistent conversion of CX for networkx 1.11 and 2.0+ Issue #30

  • NiceCXNetwork.get_nodes(), NiceCXNetwork.get_edges(), NiceCXNetwork.get_metadata() needs to make correct iterator call in Python 2 Issue #44

  • Add NiceCXNetwork.get_network_attribute_names() function enhancement Issue #45

  • NiceCXNetwork.create_edge() fails to correctly create edge when node dict passed in Issue #46

3.1.0a1 (2019-03-20)

  • Add method to ndex2 python client to apply style from one NiceCXNetwork to another NiceCXNetwork Issue #43

3.0.0a1 (2019-02-11)

  • In NiceCXNetwork class ability to add to User-Agent for calls to NDEx service Issue #36

  • Methods in ndex2/client.py should raise an NDExError for invalid credentials Issue #39

  • Add timeout flag to all web request calls Issue #33

  • Update User-Agent to reflect actual version of software Issue #35

  • NiceCXNetwork.set_node_attribute() incorrectly handles duplicate attributes Issue #41

  • NiceCXNetwork.set_node_attribute() fails if node object passed to it Issue #42

  • Passing None to user_agent parameterin Ndex2() constructor raises TypeError Issue #34

  • Ndex2() constructor does not properly handle invalid json from server Issue #28

  • Eliminate circular import between ndex2 and ndex2cx/nice_cx_builder.py Issue #31

  • Replace print statements with logging calls in ndex2/client.py Issue #32

2.0.1 (2019-01-03)

  • Fixed bug where logs directory is created within the package installation directory. Issue #26

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ndex2-3.12.0.tar.gz (251.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ndex2-3.12.0-py2.py3-none-any.whl (102.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file ndex2-3.12.0.tar.gz.

File metadata

  • Download URL: ndex2-3.12.0.tar.gz
  • Upload date:
  • Size: 251.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for ndex2-3.12.0.tar.gz
Algorithm Hash digest
SHA256 0a97df1fb4e70c09e90aaf24a315128bdb576d57abd4d776560b8994fc4a38e9
MD5 74dabcbb6c65bcc7e4aa389e0d4ef4c6
BLAKE2b-256 b8ceddb977ce672688959a76c746fd512520c2b1bbdb19e7cdea43ddb34584d9

See more details on using hashes here.

File details

Details for the file ndex2-3.12.0-py2.py3-none-any.whl.

File metadata

  • Download URL: ndex2-3.12.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 102.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for ndex2-3.12.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 204ed59510e159e2edca99f7181036def3594139969ec33e132c80024b538c8a
MD5 9ac940604b57997e333ba249e5d6aceb
BLAKE2b-256 d37ff2b047d0ae4e5b72a8c6b4373832cf4c3fa43c97a96d94bd8387c2262317

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

3.12.0 This release

2 files

3.11.0

2 files

3.10.0

2 files

3.9.0

2 files

3.8.0

2 files

3.7.0

2 files

3.6.0

2 files

3.5.1

2 files

3.5.0

2 files

3.4.0

2 files

3.3.3

2 files

3.3.2

2 files

3.3.1

2 files

3.3.0

2 files

3.2.0

2 files

2.0.1

2 files

2.0.0.8

2 files

2.0.0.7

3 files

2.0.0.4

1 file

2.0.0.3

2 files

2.0.0.2

2 files

2.0.0.1

2 files

2.0.0

2 files

1.2.0.58

2 files

1.2.0.56

2 files

1.2.0.55

2 files

1.2.0.49

2 files

1.2.0.48

2 files

1.2.0.44

2 files

1.2.0.42

2 files

1.2.0.41

2 files

1.2.0.40

2 files

1.2.0.39

2 files

1.2.0.38

2 files

1.2.0.37

2 files

1.2.0.36

2 files

1.2.0.33

2 files

1.0

2 files

0.2.0.42

2 files

0.2.0.33

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page