Overview
Getting a KIS API key requires a Korea Investment & Securities account. This guide walks you through the entire process.
Requirements
- Valid ID (passport for foreigners)
- Korean phone number OR Korea-based identity verification
- Bank account for funding
Step 1: Create KIS Account
Visit the Korea Investment & Securities website and select non-face-to-face account opening.
For foreigners:
- Prepare your passport
- You may need to visit a branch in person depending on your nationality
- Some nationalities can complete the process online
Step 2: Enable API Trading
- Log into HTS or the mobile app
- Go to the API application menu
- Agree to terms and conditions
- Select API type: Real trading or Paper trading (모의투자)
Tip: Start with Paper trading to test your code before using real money.
Step 3: Generate App Key
- After approval, visit the KIS Developers portal
- Log in with your KIS credentials
- Click Generate App Key
- Copy and securely store your App Key and App Secret
Step 4: Set Up Environment Variables
Never hardcode your API keys. Use environment variables:
export KIS_APP_KEY="your_app_key_here"
export KIS_APP_SECRET="your_app_secret_here"
export KIS_ACCOUNT="your_account_number"
Or use a .env file with python-dotenv:
from dotenv import load_dotenv
import os
load_dotenv()
APP_KEY = os.getenv("KIS_APP_KEY")
APP_SECRET = os.getenv("KIS_APP_SECRET")
Paper Trading vs Real Trading
| Paper Trading | Real Trading | |
|---|---|---|
| API endpoint | openapivts.koreainvestment.com | openapi.koreainvestment.com |
| Real money | No | Yes |
| Good for | Testing | Live trading |
Security Best Practices
- Store API keys in environment variables
- Never commit keys to GitHub
- Add
.envto your.gitignore - Rotate keys regularly