nhplug

nhplug is a cursor rule for Cursor from PLUG-OpenAPI/nhplug-sdk. It costs 1,736 tokens per session, scanned A, original, MIT.

A set of coding rules for NH Investment & Securities Open API, a service for accessing Korean financial-market data and functions. It tells developers to use the nhplug SDK to handle login tokens, request formatting, and response checks.

In plain words
What is it for?
Use it when building applications that call NH Investment & Securities APIs for Korean or overseas stocks, futures, bonds, gold, quotes, or instrument lists. It also covers safe handling of API keys and practice-versus-live environments.
Why use it?
It avoids writing and maintaining error-prone login and HTTP request code by hand. It also reduces mistakes from guessing API paths, fields, or response types.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc). Also seen: mentions Cursor.

Good fit Use it when building applications that call NH Investment & Securities APIs for Korean or overseas stocks, futures, bonds, gold, quotes, or instrument lists. It also covers safe handling of API keys and practice-versus-live environments.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/plug-openapi/nhplug-sdk/nhplug
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/PLUG-OpenAPI/nhplug-sdk

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for nhplug

README.md
[![agentmods](https://agentmods.dev/badge/rules/plug-openapi/nhplug-sdk/nhplug/github.svg)](https://agentmods.dev/rules/plug-openapi/nhplug-sdk/nhplug)
Your own site
<a href="https://agentmods.dev/rules/plug-openapi/nhplug-sdk/nhplug"><img src="https://agentmods.dev/badge/rules/plug-openapi/nhplug-sdk/nhplug/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for nhplug

Your own site · 80×15
<a href="https://agentmods.dev/rules/plug-openapi/nhplug-sdk/nhplug"><img src="https://agentmods.dev/badge/rules/plug-openapi/nhplug-sdk/nhplug.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 1,736 This file is loaded in full into every session.
When invoked 1,736 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.01736 $0.01736
Opus 5.5 $0.00694 $0.00694
Sonnet 5.5 $0.00347 $0.00347
Haiku 4.5 $0.00174 $0.00174

Measured 1mo ago against content hash ce52f3b43954, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

nhplug scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

templates/cursor/nhplug.mdc · 118 lines

How it starts

The opening of the file, as written. The whole thing — 118 lines — stays where its author put it; the contents beside it link to each section on GitHub.

NH투자증권 Open API 개발 규칙

SDK 를 쓴다 — 직접 HTTP 를 짜지 않는다

pip install nhplug                 # 인증·토큰캐시·에러판정·실시간·종목마스터 포함
pip install "nhplug[instruments]"  # 마스터를 DataFrame 으로 받을 때
from nhplug import call, NhplugError
call("/krstock/quote/v1/currentPrice", {"iem_cd": "005930", "market_cd": "KRX"})

토큰 발급·갱신·캐시, Input_0 봉투, 인증 헤더, 연속조회, 유량 제어를 call() 이 처리한다. 업무 성공/실패는 판정하지 않는다 — 아래 「에러 처리」 참조. requests 로 /oauth2/token 을 직접 부르는 코드를 새로 만들지 말 것.

명세 정본 — 도메인

설정 (.env)

NHPLUG_APP_KEY=...
NHPLUG_APP_SECRET=...
NHPLUG_BASE_URL=https://api.nhplug.com:8443    # 모의투자: moapi.nhplug.com:8443
NHPLUG_AUTH_URL=https://api.nhplug.com:8443    # 토큰은 운영 전용
NHPLUG_INSTRUMENTS_BASE=https://www.nhplug.com/instruments

키는 코드에 하드코딩 금지. .env 는 .gitignore. N2 고객은 위 세 줄을 모두 n2plug 로 — 하나라도 빠지면 그 기능만 조용히 나무로 간다.

호출 규약

  • 요청 {"Input_0": {...}} / 응답 Output_0(+Output_1) + rsp_cd·rsp_msg
  • Output_0 은 객체일 수도 배열일 수도 있다. 타입을 추측하지 말고 openapi.json 확인.
  • 계좌목록 POST /n2/acctinfo → Output_0[].acct_no 를 이후 act_no 로 사용.

⚠️ 성공 판정 — HTTP 200 ≠ 업무 성공

  • 🔴 SDK 는 업무 성공/실패를 판정하지 않는다. 기준은 HTTP 상태코드 하나다. HTTP 200 → 응답 본문 그대로 반환(예외 없음) / 200 아님 → NhplugError(본문은 .raw 에 원문).
  • 🔴 rsp_msg 문장을 읽고 판단한다. 같은 rsp_cd 값이 API 에 따라 정상일 수도 오류일 수도 있어 어떤 코드 목록도 기준이 될 수 없다. status_of(data) 로 (rsp_cd, rsp_msg) 를 꺼낸다(판정 아님).
  • ⚠️ if rsp_cd == "00000" 같은 코드를 절대 쓰지 말 것. 코드값 비교는 API 를 바꾸면 무너진다.
  • 🔴 주문 등 되돌릴 수 없는 처리 전에는 직전 응답의 rsp_msg 를 반드시 확인한다. SDK 가 막아 주지 않는다.
  • ⚠️ is_success()·NHPLUG_SUCCESS_CODES·category="business" 는 0.4.0 에서 삭제됐다. 되살리지 말 것. 원본이 필요하면 call(..., raise_on_error=False).
  • 429(초당 5회 초과)는 자동 재시도하지 않는다. 429 재시도에 토큰을 재발급하지 말 것(재발급은 401 에만).

Read the full file on GitHub · 118 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago Changed · +7 lines · +184 tokens per session ce52f3b43954
  2. 1mo ago Changed · +3 lines · +111 tokens per session 85b1cd78e828
  3. 1mo ago Changed · +4 lines · +113 tokens per session f48d4d6ceefa
  4. 1mo ago First seen · 104 lines · 1,328 tokens per session scan A 7ec197ac9ab1

Subscribe to this mod's changes

nhplug is a cursor rule published in the GitHub repository PLUG-OpenAPI/nhplug-sdk (14 stars, last pushed 19d ago), licensed MIT. It adds 1,736 tokens to every session, about $0.0069 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.