Injective Python SDK
raw JSON → 1.14.1 verified Fri May 01 auth: no python
Official Python SDK for interacting with the Injective blockchain. Provides exchange API client, protobuf definitions, and utilities for trading, governance, staking, and more. Current version: 1.14.1. Release cadence: irregular, roughly monthly.
pip install injective-py Common errors
error ModuleNotFoundError: No module named 'injective' ↓
cause Installed package with wrong name or not installed at all.
fix
Run 'pip install injective-py' and verify with 'pip list | grep injective'.
error AttributeError: module 'injective' has no attribute 'client' ↓
cause Outdated version or wrong import path.
fix
Ensure you have version 1.14.1: 'pip install --upgrade injective-py'. Use correct import: 'from injective.client import InjectiveClient'.
error RuntimeError: insecure connection rejected. Use secure connection for this network. ↓
cause Set 'insecure=True' on mainnet, which requires TLS.
fix
Change to 'insecure=False' and provide valid certificates or use a testnet network.
error GrpcServiceError: status = StatusCode.UNAUTHENTICATED debug_error_string = ... ↓
cause Private key not set or invalid for the called method.
fix
Call 'client.set_private_key(private_key_hex)' or set mnemonic via 'client.set_from_mnemonic(mnemonic)' before authenticated requests.
Warnings
gotcha The default 'insecure=True' connects via gRPC without TLS. Use only on testnet; for mainnet set 'insecure=False'. ↓
fix Use 'insecure=False' for mainnet and provide proper credentials.
breaking Version 1.14.0 bumped protobuf dependency to match Injective Core v1.19.0. Older transaction messages may be incompatible. ↓
fix Ensure your generated transaction types match the new proto definitions or pin to 'injective-py<1.14.0' if upgrading breaks.
gotcha Python version constraint is <3.15 >=3.10. Installing on Python 3.9 or 3.15+ will fail unless using a compatible version (e.g., 1.13.1). ↓
fix Use Python 3.10-3.14 for v1.14+. For Python 3.9, stay on v1.13.1 (pip install injective-py==1.13.1).
deprecated The 'LocalTerra' utility is intended for testing and may not be maintained in future releases. ↓
fix Consider using a testnet mnemonic and Network.testnet() instead.
Imports
- InjectiveClient wrong
from injective_py.client import InjectiveClientcorrectfrom injective.client import InjectiveClient - Network wrong
from injective.common import Networkcorrectfrom injective.constant import Network - ChainGrpcAuthApi wrong
from injective.grpc import ChainGrpcAuthApicorrectfrom injective.grpc.chain_api import ChainGrpcAuthApi
Quickstart
import os
from injective.client import InjectiveClient
from injective.constant import Network
from injective.utils.localTerra import LocalTerra
# Using LocalTerra for testing, no real funds needed
client = InjectiveClient(
network=Network.testnet(),
insecure=True,
)
print("Connected to Injective testnet")
# Example: get account info (requires a private key or mnemonic for authenticated actions)
# private_key = os.environ.get('INJECTIVE_PRIVATE_KEY', '')
# client.set_private_key(private_key)
# acc = client.get_account()
# print(acc)