Registry / aws / nacos-sdk-python

nacos-sdk-python

JSON →
library3.2.0pypypi✓ verified 22d ago

Python client for Nacos, a dynamic service discovery, configuration, and service management platform. It currently supports Nacos server versions 3.x and Python 3.10+. The library maintains a regular release cadence, with version 3.0.4 being the latest stable release.

pip install nacos-sdk-python
INSTALL
IMPORT
SIG · NACOS-SDK-PYTHON
N
nacos-sdk-python
awspythonv3.2.0
Install
17.3s avg
Import
Disk
109MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 109.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 17.3s · import 0.000s · 110MB
109MB installed
● package 109MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

NacosClient
from v2 import NacosClient
from v2 import NacosClient

This quickstart demonstrates how to initialize the `NacosClient` and perform basic configuration publishing/retrieval and service registration/discovery. It's recommended to configure Nacos server addresses, namespace, and authentication credentials via environment variables for flexible deployment. For Nacos server 3.x and above, ensure the Nacos server is running and accessible.

import os import nacos # Configure Nacos server address and optional namespace/auth via environment variables SERVER_ADDRESSES = os.environ.get('NACOS_SERVER_ADDR', '127.0.0.1:8848') NAMESPACE_ID = os.environ.get('NACOS_NAMESPACE_ID', '') # e.g., 'public' ACCESS_KEY = os.environ.get('NACOS_ACCESS_KEY', '') SECRET_KEY = os.environ.get('NACOS_SECRET_KEY', '') # Initialize Nacos Client # For production, ensure access_key and secret_key are provided for authentication. client = nacos.NacosClient( SERVER_ADDRESSES, namespace=NAMESPACE_ID, ak=ACCESS_KEY, sk=SECRET_KEY ) # --- Configuration Service Example --- data_id = "example_config" group = "DEFAULT_GROUP" # Publish a configuration success = client.publish_config(data_id, group, "Hello from nacos-sdk-python!") print(f"Published config: {success}") # Get a configuration config_content = client.get_config(data_id, group) print(f"Retrieved config: {config_content}") # --- Naming Service Example --- service_name = "example_service" service_ip = "127.0.0.1" service_port = 8080 # Register an instance registered = client.add_naming_instance(service_name, service_ip, service_port) print(f"Registered service instance: {registered}") # Query instances instances = client.get_naming_instance(service_name, group_name=group) print(f"Discovered instances: {instances}") # Deregister an instance deregistered = client.remove_naming_instance(service_name, service_ip, service_port) print(f"Deregistered service instance: {deregistered}")
Debug
Known issues
breaking`nacos-sdk-python` 3.x clients are designed to be compatible with Nacos server 3.x and later. Older Nacos server versions (e.g., 0.x, 1.x, or 2.x) are generally not compatible with 3.x clients, and the Nacos server 3.2.0 removed legacy v1/v2 HTTP APIs.
fix
Ensure your Nacos server instance is running version 3.x or above when using `nacos-sdk-python` 3.x. Consult the Nacos official documentation for server upgrade guides.
affects: 3.x
breakingThe Nacos Python SDK 3.x introduced 'v2 API support', implying changes from previous API patterns, especially for configuration and service management. Direct imports from `nacos` vs. `v2.nacos` differentiate between simplified usage and explicit V2 API features.
fix
Review the official documentation and migration guides for `nacos-sdk-python` 3.x to understand API changes, particularly when migrating from 2.x. Use `from v2.nacos import ...` for explicit V2 API interactions or advanced configurations like `ClientConfigBuilder`.
affects: 3.x
gotchaFor production deployments, always configure `NacosClient` with `access_key` and `secret_key` (or `username`/`password`) for authentication with the Nacos server. Relying solely on a public namespace without authentication can lead to security vulnerabilities.
fix
Pass `ak` and `sk` parameters during `NacosClient` initialization, ideally sourced from secure environment variables or a secret management system. E.g., `client = nacos.NacosClient(..., ak=os.environ.get('NACOS_ACCESS_KEY'), sk=os.environ.get('NACOS_SECRET_KEY'))`.
affects: All
gotchaWhen configuring the Nacos server, modifying `nacos.server.contextPath` from its default value can sometimes cause service registration failures or other communication issues with the Python client.
fix
If experiencing registration issues, verify that `nacos.server.contextPath` is set correctly on your Nacos server, or revert it to its default if custom paths are not strictly necessary.
affects: All
Upgrade
Version history
3.2.0latest on PyPI · released Apr 27, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
86 hits · last 30 days
node
82
Amazon
1
OpenAI (training)
1
Resources
nacos-sdk-python — pip install nacos-sdk-python · libregistry