Skip to main content
This guide explains how to import, configure, and initialize the Nevermined Payments Python SDK.

Get the NVM API Key

Before using the SDK, you need a Nevermined API Key:
  1. Go to the Nevermined App
  2. Sign in or create an account
  3. Navigate to Settings > API Keys
  4. Generate a new API key
  5. Copy the key (format: nvm:xxxxxxxx...)
Never commit your API key to version control. Use environment variables or a secrets manager.

Import and Initialize

Basic Initialization

The environment option is deprecated. The SDK now derives the environment from the API-key prefix (<prefix>:<jwt>) — a key minted for sandbox starts with sandbox:, for production with live:, and so on. When the prefix is recognized it always wins; passing environment is ignored (with a warning). It is still accepted only as a fallback for local/custom keys whose prefix the SDK doesn’t recognize (see Custom Environment).

Using Environment Variables

Configuration Options

The PaymentOptions class accepts the following parameters:

API Version Pinning

Every request the SDK sends to the Nevermined backend carries a Nevermined-Version header declaring which backend API version (MAJOR.MINOR) the SDK was built and tested against. You normally don’t need to touch this — the SDK pins the right version for you. To target a different backend contract explicitly:
See the API versioning reference for the list of versions and the changes between them.

Environments

The environment is determined by your API key’s prefix — you don’t select it explicitly. The prefix-to-environment mapping is:

Sandbox Environment (Testing)

A key minted for sandbox starts with sandbox::
  • Backend: https://api.sandbox.nevermined.app
  • Proxy: https://proxy.sandbox.nevermined.app
  • Uses test tokens and test networks

Live Environment (Production)

A key minted for production starts with live::
  • Backend: https://api.live.nevermined.app
  • Proxy: https://proxy.live.nevermined.app
  • Uses real tokens and mainnet networks

Custom Environment

For self-hosted or local development setups, the API key’s prefix won’t be one the SDK recognizes, so it falls back to the (still-accepted) environment option. Pass environment="custom" to point the SDK at URLs from environment variables:

Available Environments

Accessing Sub-APIs

The initialized Payments object provides access to specialized APIs:

Error Handling

The SDK raises PaymentsError for API errors:

Next Steps

Now that you have initialized the SDK, proceed to: