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

  1. Log into HTS or the mobile app
  2. Go to the API application menu
  3. Agree to terms and conditions
  4. 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

  1. After approval, visit the KIS Developers portal
  2. Log in with your KIS credentials
  3. Click Generate App Key
  4. 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 .env to your .gitignore
  • Rotate keys regularly