Naver Cloud Platform Python SDK
Official Python SDK for Naver Cloud Platform (NCP) — South Korea's primary cloud provider, equivalent to AWS in the Korean market. Provides programmatic access to NCP infrastructure services: servers, VPC, CDN, DNS, Object Storage, and more. The SDK is split into service-specific packages (ncloud-server, ncloud-vserver, ncloud-vpc, ncloud-cdn, etc.) — install only the services you need. IMPORTANT: NCP has two distinct environments — Classic and VPC — with separate SDK modules, different API endpoints, and incompatible APIs. ncloud-server targets Classic, ncloud-vserver targets VPC. New accounts should use VPC.
Warnings
- breaking Classic and VPC environments are completely separate API surfaces with different modules, endpoints, and product codes. ncloud-server (Classic) and ncloud-vserver (VPC) are NOT interchangeable. Classic uses 'https://ncloud.apigw.ntruss.com/server/v2', VPC uses 'https://ncloud.apigw.ntruss.com/vserver/v2'. Calling Classic APIs on a VPC account or vice versa returns auth or resource-not-found errors.
- gotcha Server image product codes and server product codes are not human-readable strings — they are opaque codes like 'SW.VSVR.OS.LNX64.CNTOS.0703.B050'. These codes differ between Classic and VPC environments and can change over time as Naver deprecates older images. Hardcoding them will break when Naver retires the image.
- gotcha The README installation instruction says 'pip install Setuptools' which is misleading — this is a general Python build tool, not the NCP SDK. Each NCP service is a separate PyPI package (ncloud-server, ncloud-vserver, ncloud-vpc, ncloud-cdn, etc.). There is no single 'pip install ncloud-sdk' that installs everything.
- gotcha Credential loading order via ncloud_apikey.NcloudKey() is: (1) environment variables NCLOUD_ACCESS_KEY_ID / NCLOUD_SECRET_KEY, (2) config file at ~/.ncloud/configure, (3) Server Role metadata (VPC only). If none are present, the SDK raises a generic exception with no clear message about missing credentials.
- gotcha NCP console, documentation, and support are primarily in Korean. English documentation at api.ncloud-docs.com exists but is less comprehensive and may lag behind Korean docs for newer services.
- gotcha NCP regions are Korea-centric. Primary region is KR (Korea). Additional regions include SGN (Singapore), JPN (Japan), USWN (US West), and DE (Germany). Not all services are available in all regions. Region availability must be checked per service.
Install
-
pip install ncloud -
pip install ncloud-vserver ncloud-vpc ncloud-apikey -
pip install ncloud-server ncloud-apikey -
pip install ncloud-cdn ncloud-apikey
Imports
- ncloud_vserver (VPC servers)
import ncloud_vserver from ncloud_vserver.api.v2_api import V2Api
Quickstart
# Step 1: Set up credentials
# Option A: Config file at ~/.ncloud/configure
# [DEFAULT]
# ncloud_access_key_id = YOUR_ACCESS_KEY
# ncloud_secret_access_key = YOUR_SECRET_KEY
# Option B: Environment variables
# export NCLOUD_ACCESS_KEY_ID=YOUR_ACCESS_KEY
# export NCLOUD_SECRET_KEY=YOUR_SECRET_KEY
# Step 2: VPC Server operations (recommended for new accounts)
import ncloud_vserver
from ncloud_vserver.api.v2_api import V2Api
from ncloud_vserver.rest import ApiException
import ncloud_apikey
# Load credentials from config file or env vars
apikeys = ncloud_apikey.ncloud_key.NcloudKey().keys()
configuration = ncloud_vserver.Configuration()
configuration.access_key = apikeys['access_key']
configuration.secret_key = apikeys['secret_key']
api = V2Api(ncloud_vserver.ApiClient(configuration))
# List server instances
try:
response = api.get_server_instance_list(
ncloud_vserver.GetServerInstanceListRequest()
)
for server in response.get_server_instance_list_response.server_instance_list:
print(server.server_name, server.server_instance_status.code_name)
except ApiException as e:
print(f'API error: {e}')
# Create a server instance (VPC)
try:
request = ncloud_vserver.CreateServerInstancesRequest(
vpc_no='YOUR_VPC_NO',
subnet_no='YOUR_SUBNET_NO',
server_image_product_code='SW.VSVR.OS.LNX64.CNTOS.0703.B050', # CentOS 7
server_product_code='SVR.VSVR.STAND.C002.M008.NET.SSD050.B050.G002',
)
response = api.create_server_instances(request)
print(response)
except ApiException as e:
print(f'Create error: {e}')
# Classic environment (legacy — use only if on Classic account)
import ncloud_server
from ncloud_server.api.v2_api import V2Api as ClassicV2Api
classic_config = ncloud_server.Configuration()
classic_config.access_key = apikeys['access_key']
classic_config.secret_key = apikeys['secret_key']
classic_api = ClassicV2Api(ncloud_server.ApiClient(classic_config))
try:
response = classic_api.get_server_instance_list(
ncloud_server.GetServerInstanceListRequest()
)
except ApiException as e:
print(f'Classic API error: {e}')
# CDN (works for both Classic and VPC)
import ncloud_cdn
from ncloud_cdn.api.v2_api import V2Api as CdnV2Api
cdn_config = ncloud_cdn.Configuration()
cdn_config.access_key = apikeys['access_key']
cdn_config.secret_key = apikeys['secret_key']
cdn_api = CdnV2Api(ncloud_cdn.ApiClient(cdn_config))
try:
response = cdn_api.get_cdn_plus_instance_list(
ncloud_cdn.GetCdnPlusInstanceListRequest()
)
print(response)
except ApiException as e:
print(f'CDN error: {e}')