### Installation Source: https://context7.com/codef-io/easycodefpy/llms.txt Install the easycodefpy library using pip. ```APIDOC ## Installation ```bash pip install easycodefpy ``` ``` -------------------------------- ### Bank Account Inquiry Workflow Source: https://context7.com/codef-io/easycodefpy/llms.txt Complete example demonstrating initialization, account registration, and retrieving account lists. ```python from easycodefpy import Codef, ServiceType, encrypt_rsa import json # 1. Codef 인스턴스 초기화 codef = Codef() codef.public_key = 'MIIBIjANBgkqh...' codef.set_client_info('your_client_id', 'your_client_secret') # 2. 계정 등록 및 Connected ID 발급 account_list = [{ 'countryCode': 'KR', 'businessType': 'BK', 'clientType': 'P', 'organization': '0004', 'loginType': '1', 'id': 'bank_user_id', 'password': encrypt_rsa('bank_password', codef.public_key) }] response = codef.create_account(ServiceType.SANDBOX, {'accountList': account_list}) result = json.loads(response) if result['result']['code'] == 'CF-00000': connected_id = result['data']['connectedId'] print(f"Connected ID 발급 완료: {connected_id}") # 3. 계좌 목록 조회 parameter = { 'connectedId': connected_id, 'organization': '0004' } response = codef.request_product( '/v1/kr/bank/p/account/account-list', ServiceType.SANDBOX, parameter ) account_result = json.loads(response) if account_result['result']['code'] == 'CF-00000': print("\n=== 예금/적금 계좌 ===") for acc in account_result['data'].get('resDepositTrust', []): print(f" {acc['resAccountName']}: {acc['resAccountBalance']}원") print("\n=== 대출 계좌 ===") for acc in account_result['data'].get('resLoan', []): print(f" {acc['resAccountName']}: {acc['resAccountBalance']}원") else: print(f"계정 등록 실패: {result['result']['message']}") ``` -------------------------------- ### Install easycodefpy Source: https://github.com/codef-io/easycodefpy/blob/master/README.md Install the easycodefpy library using pip. This is the first step to using the library for CODEF API integration. ```bash python -m pip install easycodefpy ``` -------------------------------- ### Create Account (Connected ID) Source: https://github.com/codef-io/easycodefpy/blob/master/README.md This example shows how to create an account by registering user credentials to obtain a Connected ID. The password must be encrypted using RSA with the provided public key. This Connected ID is then used for subsequent API requests that require user authentication. ```python # 요청 파라미터 설정 # - 계정관리 파라미터를 설정(https://developer.codef.io/cert/account/cid-overview) account_list = [] account = { 'countryCode': 'KR', 'businessType': 'BK', 'clientType': 'P', 'organization': '0004', 'loginType': '1', 'id': "user_id", } # 비밀번호 설정 pwd = encrypt_rsa("password", codef.public_key) account['password'] = pwd account_list.append(account) parameter = { 'accountList': account_list, } # 요청 res = codef.create_account(ServiceType.SANDBOX, parameter) print(res) ``` -------------------------------- ### Request Access Token Source: https://github.com/codef-io/easycodefpy/blob/master/README.md This example demonstrates how to initialize the Codef instance and request an access token for sandbox services. Client information must be set before requesting a token. The library automatically handles token renewal. ```python from easycodefpy import Codef, ServiceType demo_client_id = '' demo_client_secret = '' client_id = '' client_secret = '' public_key = '' # 코드에프 인스턴스 생성 codef = Codef() codef.public_key = public_key # 데모 클라이언트 정보 설정 # - 데모 서비스 가입 후 코드에프 홈페이지에 확인 가능(https://codef.io/#/account/keys) # - 데모 서비스로 상품 조회 요청시 필수 입력 항목 codef.set_demo_client_info(demo_client_id, demo_client_secret) # 정식 클라이언트 정보 설정 # - 정식 서비스 가입 후 코드에프 홈페이지에 확인 가능(https://codef.io/#/account/keys) # - 정식 서비스로 상품 조회 요청시 필수 입력 항목 codef.set_client_info(client_id, client_secret) # 토큰 발급 요청 token = codef.request_token(ServiceType.SANDBOX) # 결과 출력 print(token) ``` -------------------------------- ### Example API Response Source: https://github.com/codef-io/easycodefpy/blob/master/README.md A sample JSON response structure returned by the Codef API. ```json { "result" : { "code" : "CF-00000", "extraMessage" : "", "message" : "성공", "transactionId" : "786e01e459af491888e1f782d1902e40" }, "data" : [ { "resBusinessStatus" : "사업을하지않고있습니다.", "resCompanyIdentityNo" : "3333344444", "code" : "CF-00000", "resTaxationTypeCode" : "98", "extraMessage" : null, "resClosingDate" : "", "resTransferTaxTypeDate" : "", "message" : "성공" }, { "resBusinessStatus" : "부가가치세일반과세자입니다.\n*과세유형전환된날짜는2011년07월01일입니다.", "resCompanyIdentityNo" : "1234567890", "code" : "CF-00000", "resTaxationTypeCode" : "1", "extraMessage" : null, "resClosingDate" : "", "resTransferTaxTypeDate" : "20110701", "message" : "성공" } ] } ``` -------------------------------- ### Account Creation Response Example Source: https://github.com/codef-io/easycodefpy/blob/master/README.md This JSON object represents the response from the create_account API call. It indicates the success or failure of account registration for different organizations and provides the generated Connected ID upon successful registration. ```json { "result" : { "code" : "CF-00000", "extraMessage" : "", "message" : "정상", "transactionId":"786e01e459af491888e1f782d1902e40" }, "data" : { "successList" : [ { "code" : "CF-00000", "message" : "정상", "extraMessage" : "", "countryCode" : "KR", "businessType" : "BK", "clientType" : "P", "loginType" : "1", "organization" : "0004" }], "errorList" : [ ], "connectedId" : "byi1wYwD40k8hEIiXl6bRF" } } ``` -------------------------------- ### Get List of Connected IDs Source: https://context7.com/codef-io/easycodefpy/llms.txt Fetch a list of all Connected IDs associated with your client credentials. This helps in managing multiple client connections. ```python from easycodefpy import Codef, ServiceType import json codef = Codef() codef.public_key = 'MIIBIjANBgkqh...' codef.set_client_info('your_client_id', 'your_client_secret') parameter = {} # Connected ID 목록 조회 response = codef.get_connected_id_list(ServiceType.SANDBOX, parameter) result = json.loads(response) for item in result['data']: print(f"Connected ID: {item['connectedId']}") ``` -------------------------------- ### Get List of Registered Accounts Source: https://context7.com/codef-io/easycodefpy/llms.txt Retrieve a list of all bank accounts currently registered under a specific Connected ID. This is useful for verifying account linkages. ```python from easycodefpy import Codef, ServiceType import json codef = Codef() codef.public_key = 'MIIBIjANBgkqh...' codef.set_client_info('your_client_id', 'your_client_secret') parameter = { 'connectedId': 'byi1wYwD40k8hEIiXl6bRF' } # 계정 목록 조회 response = codef.get_account_list(ServiceType.SANDBOX, parameter) result = json.loads(response) for account in result['data']['accountList']: print(f"기관: {account['organization']}, 타입: {account['businessType']}") ``` -------------------------------- ### Initialize Codef Client Source: https://context7.com/codef-io/easycodefpy/llms.txt Create and configure the main Codef client instance with credentials. ```python from easycodefpy import Codef, ServiceType # 코드에프 인스턴스 생성 codef = Codef() # 퍼블릭 키 설정 (CODEF 홈페이지에서 발급) codef.public_key = 'MIIBIjANBgkqh...' # 데모 클라이언트 정보 설정 (데모 서비스용) codef.set_demo_client_info( client_id='demo_client_id', client_secret='demo_client_secret' ) # 정식 클라이언트 정보 설정 (정식 서비스용) codef.set_client_info( client_id='your_client_id', client_secret='your_client_secret' ) # 클라이언트 정보 확인 client_id, client_secret = codef.get_client_info(ServiceType.PRODUCT) print(f"Client ID: {client_id}") ``` -------------------------------- ### Codef Class - Main Client Instance Source: https://context7.com/codef-io/easycodefpy/llms.txt Instantiate the Codef class to interact with the CODEF API. This includes setting up public keys, client information for different service environments, and managing tokens. ```APIDOC ## Codef 클래스 - 메인 클라이언트 인스턴스 생성 CODEF API를 사용하기 위한 메인 클라이언트 클래스입니다. 클라이언트 인증 정보 설정, 토큰 관리, 계정 관리, 상품 요청 등 모든 API 기능을 이 클래스를 통해 사용할 수 있습니다. ```python from easycodefpy import Codef, ServiceType # 코드에프 인스턴스 생성 codef = Codef() # 퍼블릭 키 설정 (CODEF 홈페이지에서 발급) codef.public_key = 'MIIBIjANBgkqh...' # 데모 클라이언트 정보 설정 (데모 서비스용) codef.set_demo_client_info( client_id='demo_client_id', client_secret='demo_client_secret' ) # 정식 클라이언트 정보 설정 (정식 서비스용) codef.set_client_info( client_id='your_client_id', client_secret='your_client_secret' ) # 클라이언트 정보 확인 client_id, client_secret = codef.get_client_info(ServiceType.PRODUCT) print(f"Client ID: {client_id}") ``` ``` -------------------------------- ### Request a Codef Product Source: https://github.com/codef-io/easycodefpy/blob/master/README.md Use the request_product method to call a specific API endpoint. Ensure the correct ServiceType is provided. ```python # - 서비스타입(0:정식, 1:데모, 2:샌드박스) product_url = '/v1/kr/public/nt/business/status' res = codef.request_product(product_url, ServiceType.SANDBOX, parameter) print(res) ``` -------------------------------- ### POST /request_product Source: https://context7.com/codef-io/easycodefpy/llms.txt Requests financial product data such as account lists or business status. ```APIDOC ## POST /request_product ### Description Requests various financial product APIs. ### Method POST ### Endpoint [product_url] ### Parameters #### Request Body - **connectedId** (string) - Optional - Connected ID if required by the product - **organization** (string) - Required - Organization code ``` -------------------------------- ### Select Service Environment Source: https://context7.com/codef-io/easycodefpy/llms.txt Define the target environment using the ServiceType enum. ```python from easycodefpy import ServiceType # 서비스 타입 종류 ServiceType.PRODUCT # 0: 정식 서비스 (실제 운영 환경) ServiceType.DEMO # 1: 데모 서비스 (테스트 환경, 실제 데이터) ServiceType.SANDBOX # 2: 샌드박스 (개발 연습용, 고정 응답) # 서비스 타입별 도메인 # PRODUCT -> https://api.codef.io # DEMO -> https://development.codef.io # SANDBOX -> https://sandbox.codef.io ``` -------------------------------- ### Request Product with Additional Authentication Source: https://context7.com/codef-io/easycodefpy/llms.txt Initiate requests for financial products that require two-way authentication, such as SMS verification or CAPTCHA input. The `twoWayInfo` from the first response must be included in subsequent requests. ```python from easycodefpy import Codef, ServiceType import json codef = Codef() codef.public_key = 'MIIBIjANBgkqh...' codef.set_client_info('your_client_id', 'your_client_secret') # 1차 요청: 기본 파라미터로 요청 parameter = { 'connectedId': 'byi1wYwD40k8hEIiXl6bRF', 'organization': '0004' } product_url = '/v1/kr/bank/p/account/transaction-list' response = codef.request_product(product_url, ServiceType.PRODUCT, parameter) result = json.loads(response) ``` -------------------------------- ### Define Service Types Source: https://github.com/codef-io/easycodefpy/blob/master/README.md Enumeration of available service environments for API requests. ```python class ServiceType(Enum): PRODUCT = 0 # 정식 DEMO = 1 # 데모 SANDBOX = 2 # 샌드박스 ``` -------------------------------- ### create_account() - Register Connected ID Account Source: https://context7.com/codef-io/easycodefpy/llms.txt Register an end-user's account information to issue a Connected ID, which allows data access without direct credential transmission for subsequent product requests. ```APIDOC ## create_account() - Connected ID 계정 등록 엔드 유저의 계정 정보를 등록하고 Connected ID를 발급받습니다. Connected ID는 이후 상품 요청 시 직접적인 계정 정보 전송 없이 데이터를 조회할 수 있게 해줍니다. ```python from easycodefpy import Codef, ServiceType, encrypt_rsa import json codef = Codef() codef.public_key = 'MIIBIjANBgkqh...' codef.set_client_info('your_client_id', 'your_client_secret') # 계정 정보 설정 account_list = [{ 'countryCode': 'KR', # 국가코드 'businessType': 'BK', # 업무구분 (BK:은행, CD:카드, IS:보험 등) 'clientType': 'P', # 고객구분 (P:개인, B:기업) 'organization': '0004', # 기관코드 (0004:국민은행) 'loginType': '1', # 로그인타입 (0:인증서, 1:ID/PW) 'id': 'user_id', 'password': encrypt_rsa('user_password', codef.public_key) }] parameter = {'accountList': account_list} # 계정 등록 요청 response = codef.create_account(ServiceType.SANDBOX, parameter) result = json.loads(response) print(f"결과 코드: {result['result']['code']}") print(f"Connected ID: {result['data']['connectedId']}") # 출력 예시: # 결과 코드: CF-00000 # Connected ID: byi1wYwD40k8hEIiXl6bRF ``` ``` -------------------------------- ### Manage OAuth Tokens Source: https://context7.com/codef-io/easycodefpy/llms.txt Request, refresh, or manually set access tokens for API authentication. ```python from easycodefpy import Codef, ServiceType codef = Codef() codef.public_key = 'MIIBIjANBgkqh...' codef.set_client_info('your_client_id', 'your_client_secret') # 토큰 요청 (유효한 토큰이 있으면 재사용, 없으면 신규 발급) token = codef.request_token(ServiceType.SANDBOX) print(f"Access Token: {token}") # 강제로 새 토큰 발급 new_token = codef.request_new_token(ServiceType.SANDBOX) print(f"New Access Token: {new_token}") # 현재 저장된 토큰 조회 current_token = codef.get_access_token(ServiceType.SANDBOX) # 토큰 수동 설정 codef.set_access_token('your_token', ServiceType.SANDBOX) ``` -------------------------------- ### Encode Files to Base64 Source: https://context7.com/codef-io/easycodefpy/llms.txt Convert certificate or key files into Base64 strings for API transmission. ```python from easycodefpy import encode_to_file_string # 인증서 파일을 Base64 문자열로 인코딩 cert_string = encode_to_file_string('/path/to/cert.pfx') print(f"인코딩된 인증서: {cert_string[:50]}...") # 인증서 계정 등록 예시 account = { 'countryCode': 'KR', 'businessType': 'BK', 'clientType': 'P', 'organization': '0004', 'loginType': '0', # 인증서 로그인 'certFile': encode_to_file_string('/path/to/signCert.der'), 'keyFile': encode_to_file_string('/path/to/signPri.key'), 'certPassword': encrypt_rsa('cert_password', public_key) } ``` -------------------------------- ### POST /add_account Source: https://context7.com/codef-io/easycodefpy/llms.txt Adds a new account to an existing Connected ID. ```APIDOC ## POST /add_account ### Description Adds a new account to an existing Connected ID. ### Method POST ### Endpoint /add_account ### Parameters #### Request Body - **connectedId** (string) - Required - Existing Connected ID - **accountList** (array) - Required - List of account objects containing countryCode, businessType, clientType, organization, loginType, id, and encrypted password. ### Response #### Success Response (200) - **successList** (array) - List of successfully added accounts - **errorList** (array) - List of failed account additions ``` -------------------------------- ### Response for Personal Account List Request Source: https://github.com/codef-io/easycodefpy/blob/master/README.md This is a sample JSON response for a successful personal account list request. It includes transaction details and a list of accounts with their balances and other relevant information. ```json { "result":{ "code":"CF-00000", "extraMessage":"", "message":"성공", "transactionId":"5069429e367745baba92f5c12c4343de" }, "data":{ "resDepositTrust":[ { "resAccount":"06170204000000", "resAccountBalance":"874890", "resAccountCurrency":"KRW", "resAccountDeposit":"11", "resAccountDisplay":"061702-04-000000", "resAccountEndDate":"", "resAccountLifetime":"", "resAccountName":"저축예금", "resAccountNickName":"", "resAccountStartDate":"20120907", "resLastTranDate":"" }, { "resAccount":"23850204000000", "resAccountBalance":"0", "resAccountCurrency":"KRW", "resAccountDeposit":"11", "resAccountDisplay":"238502-04-000000", "resAccountEndDate":"", "resAccountLifetime":"", "resAccountName":"직장인우대통장-저축예금", "resAccountNickName":"급여통장", "resAccountStartDate":"20060413", "resLastTranDate":"" }, { "resAccount":"54780300000000", "resAccountBalance":"13110000", "resAccountCurrency":"KRW", "resAccountDeposit":"12", "resAccountDisplay":"547803-00-000000", "resAccountEndDate":"", "resAccountLifetime":"", "resAccountName":"OO국민재형저축", "resAccountNickName":"", "resAccountStartDate":"20151228", "resLastTranDate":"" } ], "resForeignCurrency":[], "resFund":[], "resInsurance":[], "resLoan":[ { "resAccount":"75260904000000", "resAccountBalance":"120000000", "resAccountCurrency":"KRW", "resAccountDeposit":"40", "resAccountDisplay":"752609-04-000000", "resAccountEndDate":"20210628", "resAccountLoanExecNo":"", "resAccountName":"서울특별시신혼부부임차보증금대출", "resAccountNickName":"", "resAccountStartDate":"20190628" } ] } } ``` -------------------------------- ### Request Personal Account List with Connected ID Source: https://github.com/codef-io/easycodefpy/blob/master/README.md Use this snippet to request a list of personal accounts associated with a Connected ID. Ensure client information and public key are correctly set. The `request_product` method handles the API call with specified parameters and service type. ```python from easycodefpy import Codef, ServiceType demo_client_id = '' demo_client_secret = '' client_id = '' client_secret = '' public_key = '' # 코드에프 인스턴스 생성 codef = Codef() codf.public_key = public_key # 데모 클라이언트 정보 설정 # - 데모 서비스 가입 후 코드에프 홈페이지에 확인 가능(https://codef.io/#/account/keys) # - 데모 서비스로 상품 조회 요청시 필수 입력 항목 codf.set_demo_client_info(demo_client_id, demo_client_secret) # 정식 클라이언트 정보 설정 # - 정식 서비스 가입 후 코드에프 홈페이지에 확인 가능(https://codef.io/#/account/keys) # - 정식 서비스로 상품 조회 요청시 필수 입력 항목 codf.set_client_info(client_id, client_secret) # 요청 파라미터 설정 # - 각 상품별 파라미터를 설정(https://developer.codef.io/products) parameter = { 'connectedId': '8PQI4dQ......hKLhTnZ', 'organization': '0004', } # 코드에프 정보 조회 요청 # - 서비스타입(0:정식, 1:데모, 2:샌드박스) # 개인 보유계좌 조회 (https://developer.codef.io/products/bank/common/p/account) product_url = "/v1/kr/bank/p/account/account-list" res = codef.request_product(product_url, ServiceType.SANDBOX, parameter) print(res) ``` -------------------------------- ### Encrypt Data with RSA Source: https://context7.com/codef-io/easycodefpy/llms.txt Encrypt sensitive information like passwords using the provided public key. ```python from easycodefpy import encrypt_rsa public_key = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQE...' # 비밀번호 암호화 encrypted_password = encrypt_rsa("my_password", public_key) print(f"암호화된 비밀번호: {encrypted_password}") # 계정 정보에 암호화된 비밀번호 적용 account = { 'countryCode': 'KR', 'businessType': 'BK', 'clientType': 'P', 'organization': '0004', 'loginType': '1', 'id': 'user_id', 'password': encrypt_rsa('user_password', public_key) } ``` -------------------------------- ### encode_to_file_string() - File Base64 Encoding Source: https://context7.com/codef-io/easycodefpy/llms.txt Encode certificate files (e.g., .pfx, .der, .key) into Base64 strings for API transmission. ```APIDOC ## encode_to_file_string() - 파일 Base64 인코딩 인증서 파일 등을 Base64 문자열로 인코딩합니다. cert/key 파일이나 pfx 파일을 API에 전송할 때 사용합니다. ```python from easycodefpy import encode_to_file_string # 인증서 파일을 Base64 문자열로 인코딩 cert_string = encode_to_file_string('/path/to/cert.pfx') print(f"인코딩된 인증서: {cert_string[:50]}...") # 인증서 계정 등록 예시 account = { 'countryCode': 'KR', 'businessType': 'BK', 'clientType': 'P', 'organization': '0004', 'loginType': '0', # 인증서 로그인 'certFile': encode_to_file_string('/path/to/signCert.der'), 'keyFile': encode_to_file_string('/path/to/signPri.key'), 'certPassword': encrypt_rsa('cert_password', public_key) } ``` ``` -------------------------------- ### Request Financial Product Data Source: https://context7.com/codef-io/easycodefpy/llms.txt Make general requests for financial product data, such as bank account details or transaction history. Can be used with or without a Connected ID. ```python from easycodefpy import Codef, ServiceType import json codef = Codef() codef.public_key = 'MIIBIjANBgkqh...' codef.set_client_info('your_client_id', 'your_client_secret') # 예시 1: 개인 보유계좌 조회 (Connected ID 사용) parameter = { 'connectedId': 'byi1wYwD40k8hEIiXl6bRF', 'organization': '0004' # 국민은행 } product_url = '/v1/kr/bank/p/account/account-list' response = codef.request_product(product_url, ServiceType.SANDBOX, parameter) result = json.loads(response) print("=== 보유 계좌 목록 ===") for account in result['data']['resDepositTrust']: print(f"계좌: {account['resAccountDisplay']}") print(f"계좌명: {account['resAccountName']}") print(f"잔액: {account['resAccountBalance']}원") print("---") # 예시 2: 사업자등록상태 조회 (Connected ID 미사용) parameter = { 'organization': '0004', 'req_identity_list': [ {'reqIdentity': '1234567890'}, {'reqIdentity': '0987654321'} ] } product_url = '/v1/kr/public/nt/business/status' response = codef.request_product(product_url, ServiceType.SANDBOX, parameter) result = json.loads(response) print("=== 사업자 상태 조회 ===") for biz in result['data']: print(f"사업자번호: {biz['resCompanyIdentityNo']}") print(f"상태: {biz['resBusinessStatus']}") print("---") ``` -------------------------------- ### POST /get_account_list Source: https://context7.com/codef-io/easycodefpy/llms.txt Retrieves all accounts registered under a specific Connected ID. ```APIDOC ## POST /get_account_list ### Description Retrieves all accounts registered under a specific Connected ID. ### Method POST ### Endpoint /get_account_list ### Parameters #### Request Body - **connectedId** (string) - Required - Existing Connected ID ``` -------------------------------- ### request_token() - Request OAuth Access Token Source: https://context7.com/codef-io/easycodefpy/llms.txt Obtain an access token for CODEF API services. Tokens are valid for one week and are automatically managed by the library. ```APIDOC ## request_token() - OAuth 액세스 토큰 요청 CODEF API 서비스 이용을 위한 액세스 토큰을 발급받습니다. 토큰은 일주일간 재사용 가능하며, 라이브러리가 자동으로 유효성을 검사하고 만료 시 재발급합니다. ```python from easycodefpy import Codef, ServiceType codef = Codef() codef.public_key = 'MIIBIjANBgkqh...' codef.set_client_info('your_client_id', 'your_client_secret') # 토큰 요청 (유효한 토큰이 있으면 재사용, 없으면 신규 발급) token = codef.request_token(ServiceType.SANDBOX) print(f"Access Token: {token}") # 강제로 새 토큰 발급 new_token = codef.request_new_token(ServiceType.SANDBOX) print(f"New Access Token: {new_token}") # 현재 저장된 토큰 조회 current_token = codef.get_access_token(ServiceType.SANDBOX) # 토큰 수동 설정 codef.set_access_token('your_token', ServiceType.SANDBOX) ``` ``` -------------------------------- ### Request Business Registration Status Without Connected ID Source: https://github.com/codef-io/easycodefpy/blob/master/README.md This snippet shows how to request business registration status (suspension/resumption) without using a Connected ID. It requires setting up client information and then defining parameters including a list of business identities to query. ```python # 사업자등록상태(휴폐업조회)(Connected ID 미사용) from easycodefpy import Codef, ServiceType demo_client_id = '' demo_client_secret = '' client_id = '' client_secret = '' public_key = '' # 코드에프 인스턴스 생성 codef = Codef() codf.public_key = public_key # 데모 클라이언트 정보 설정 # - 데모 서비스 가입 후 코드에프 홈페이지에 확인 가능(https://codef.io/#/account/keys) # - 데모 서비스로 상품 조회 요청시 필수 입력 항목 codf.set_demo_client_info(demo_client_id, demo_client_secret) # 정식 클라이언트 정보 설정 # - 정식 서비스 가입 후 코드에프 홈페이지에 확인 가능(https://codef.io/#/account/keys) # - 정식 서비스로 상품 조회 요청시 필수 입력 항목 codf.set_client_info(client_id, client_secret) # 요청 파라미터 설정 # - 각 상품별 파라미터를 설정(https://developer.codef.io/products) parameter = { 'organization': "0004", } req_identity_list = [{ 'reqIdentity': '3333344444', }, { 'reqIdentity': '1234567890', }] parameter['req_identity_list'] = req_identity_list # 코드에프 정보 조회 요청 ``` -------------------------------- ### ServiceType - Service Environment Selection Source: https://context7.com/codef-io/easycodefpy/llms.txt Use the ServiceType enum to specify the CODEF API service environment (PRODUCT, DEMO, SANDBOX). ```APIDOC ## ServiceType - 서비스 환경 선택 CODEF API 요청 시 사용할 서비스 환경을 지정하는 열거형입니다. 정식(PRODUCT), 데모(DEMO), 샌드박스(SANDBOX) 세 가지 환경을 지원합니다. ```python from easycodefpy import ServiceType # 서비스 타입 종류 ServiceType.PRODUCT # 0: 정식 서비스 (실제 운영 환경) ServiceType.DEMO # 1: 데모 서비스 (테스트 환경, 실제 데이터) ServiceType.SANDBOX # 2: 샌드박스 (개발 연습용, 고정 응답) # 서비스 타입별 도메인 # PRODUCT -> https://api.codef.io # DEMO -> https://development.codef.io # SANDBOX -> https://sandbox.codef.io ``` ``` -------------------------------- ### encrypt_rsa() - RSA Encryption Utility Source: https://context7.com/codef-io/easycodefpy/llms.txt Encrypt sensitive information like passwords using RSA encryption with CODEF's public key before transmission. ```APIDOC ## encrypt_rsa() - RSA 암호화 유틸리티 비밀번호 등 민감한 정보를 RSA 암호화하여 안전하게 전송합니다. CODEF에서 제공하는 퍼블릭 키를 사용하여 데이터를 암호화합니다. ```python from easycodefpy import encrypt_rsa public_key = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQE...' # 비밀번호 암호화 encrypted_password = encrypt_rsa("my_password", public_key) print(f"암호화된 비밀번호: {encrypted_password}") # 계정 정보에 암호화된 비밀번호 적용 account = { 'countryCode': 'KR', 'businessType': 'BK', 'clientType': 'P', 'organization': '0004', 'loginType': '1', 'id': 'user_id', 'password': encrypt_rsa('user_password', public_key) } ``` ``` -------------------------------- ### POST /update_account Source: https://context7.com/codef-io/easycodefpy/llms.txt Updates information such as passwords for registered accounts. ```APIDOC ## POST /update_account ### Description Updates registered account information. ### Method POST ### Endpoint /update_account ### Parameters #### Request Body - **connectedId** (string) - Required - Existing Connected ID - **accountList** (array) - Required - List of account objects to update. ``` -------------------------------- ### add_account() - Add Account to Existing Connected ID Source: https://context7.com/codef-io/easycodefpy/llms.txt Add accounts from different organizations to an already issued Connected ID. ```APIDOC ## add_account() - 기존 Connected ID에 계정 추가 이미 발급받은 Connected ID에 다른 기관의 계정을 추가합니다. ```python from easycodefpy import Codef, ServiceType, encrypt_rsa import json codef = Codef() codef.public_key = 'MIIBIjANBgkqh...' codef.set_client_info('your_client_id', 'your_client_secret') ``` -------------------------------- ### Add Account to Connected ID Source: https://context7.com/codef-io/easycodefpy/llms.txt Add a new institution account to an existing Connected ID. ```python from easycodefpy import Codef, ServiceType, encrypt_rsa import json codef = Codef() codef.public_key = 'MIIBIjANBgkqh...' codef.set_client_info('your_client_id', 'your_client_secret') ``` -------------------------------- ### POST /request_certification Source: https://context7.com/codef-io/easycodefpy/llms.txt Handles 2Way authentication requests like security codes or SMS verification. ```APIDOC ## POST /request_certification ### Description Requests products requiring additional authentication (2Way). ### Method POST ### Endpoint /request_certification ### Parameters #### Request Body - **twoWayInfo** (object) - Required - Information received from the initial request to continue authentication. ``` -------------------------------- ### API Response and Error Codes Source: https://context7.com/codef-io/easycodefpy/llms.txt Structure of successful API responses and a reference list of common error codes. ```python # 성공 응답 { "result": { "code": "CF-00000", "message": "성공", "extraMessage": "" }, "data": { ... } } # 주요 에러 코드 # CF-00000: 성공 # CF-00002: json형식이 올바르지 않습니다 # CF-00007: 요청 파라미터가 올바르지 않습니다 # CF-00014: 클라이언트 정보가 필요합니다 # CF-00015: 퍼블릭키가 필요합니다 # CF-03003: 2WAY 요청 처리 정보가 올바르지 않습니다 # CF-03004: 추가 인증은 requestCertification 메서드를 사용해야 합니다 # CF-00400: 클라이언트 요청 오류 # CF-00401: 요청 권한이 없습니다 # CF-00403: 잘못된 요청입니다 # CF-00404: 요청하신 페이지를 찾을 수 없습니다 # CF-09999: 서버 처리중 에러가 발생했습니다 ``` -------------------------------- ### Register Connected ID Account Source: https://context7.com/codef-io/easycodefpy/llms.txt Register user account information to receive a Connected ID for future requests. ```python from easycodefpy import Codef, ServiceType, encrypt_rsa import json codef = Codef() codef.public_key = 'MIIBIjANBgkqh...' codef.set_client_info('your_client_id', 'your_client_secret') # 계정 정보 설정 account_list = [{ 'countryCode': 'KR', # 국가코드 'businessType': 'BK', # 업무구분 (BK:은행, CD:카드, IS:보험 등) 'clientType': 'P', # 고객구분 (P:개인, B:기업) 'organization': '0004', # 기관코드 (0004:국민은행) 'loginType': '1', # 로그인타입 (0:인증서, 1:ID/PW) 'id': 'user_id', 'password': encrypt_rsa('user_password', codef.public_key) }] parameter = {'accountList': account_list} # 계정 등록 요청 response = codef.create_account(ServiceType.SANDBOX, parameter) result = json.loads(response) print(f"결과 코드: {result['result']['code']}") print(f"Connected ID: {result['data']['connectedId']}") # 출력 예시: # 결과 코드: CF-00000 # Connected ID: byi1wYwD40k8hEIiXl6bRF ``` -------------------------------- ### Handle 2WAY Authentication Source: https://context7.com/codef-io/easycodefpy/llms.txt Logic for processing additional authentication requests when 'twoWayInfo' is present in the API response. ```python if 'twoWayInfo' in result['data']: two_way_info = result['data']['twoWayInfo'] # 사용자에게 보안문자 이미지 표시 후 입력값 수집 captcha_input = input("보안문자를 입력하세요: ") # 2차 요청: 추가 인증 정보 포함 parameter = { 'connectedId': 'byi1wYwD40k8hEIiXl6bRF', 'organization': '0004', 'secureNo': captcha_input, # 사용자 입력 보안문자 'is2Way': True, 'twoWayInfo': { 'jobIndex': two_way_info['jobIndex'], 'threadIndex': two_way_info['threadIndex'], 'jti': two_way_info['jti'], 'twoWayTimestamp': two_way_info['twoWayTimestamp'] } } # 추가 인증 요청 response = codef.request_certification(product_url, ServiceType.PRODUCT, parameter) result = json.loads(response) print(f"최종 결과: {result['result']['message']}") ``` -------------------------------- ### Add Account to Connected ID Source: https://context7.com/codef-io/easycodefpy/llms.txt Use this function to add a new bank account to an existing Connected ID. Ensure the account details and encryption are correct. ```python from easycodefpy import Codef, ServiceType import json codef = Codef() codef.public_key = 'MIIBIjANBgkqh...' codef.set_client_info('your_client_id', 'your_client_secret') # 추가할 계정 정보 account_list = [{ 'countryCode': 'KR', 'businessType': 'BK', 'clientType': 'P', 'organization': '0003', # 기업은행 'loginType': '1', 'id': 'ibk_user_id', 'password': encrypt_rsa('ibk_password', codef.public_key) }] parameter = { 'connectedId': 'byi1wYwD40k8hEIiXl6bRF', # 기존 Connected ID 'accountList': account_list } # 계정 추가 요청 response = codef.add_account(ServiceType.SANDBOX, parameter) result = json.loads(response) print(f"성공 목록: {result['data']['successList']}") print(f"실패 목록: {result['data']['errorList']}") ``` -------------------------------- ### POST /get_connected_id_list Source: https://context7.com/codef-io/easycodefpy/llms.txt Retrieves all Connected IDs registered to the client. ```APIDOC ## POST /get_connected_id_list ### Description Retrieves all Connected IDs registered to the client. ### Method POST ### Endpoint /get_connected_id_list ``` -------------------------------- ### Update Account Information Source: https://context7.com/codef-io/easycodefpy/llms.txt Modify existing account details, such as the password, for an account linked to a Connected ID. The new password must be encrypted. ```python from easycodefpy import Codef, ServiceType, encrypt_rsa import json codef = Codef() codef.public_key = 'MIIBIjANBgkqh...' codef.set_client_info('your_client_id', 'your_client_secret') # 수정할 계정 정보 account_list = [{ 'countryCode': 'KR', 'businessType': 'BK', 'clientType': 'P', 'organization': '0004', 'loginType': '1', 'id': 'user_id', 'password': encrypt_rsa('new_password', codef.public_key) # 새 비밀번호 }] parameter = { 'connectedId': 'byi1wYwD40k8hEIiXl6bRF', 'accountList': account_list } # 계정 수정 요청 response = codef.update_account(ServiceType.SANDBOX, parameter) result = json.loads(response) print(f"결과: {result['result']['message']}") ``` -------------------------------- ### POST /delete_account Source: https://context7.com/codef-io/easycodefpy/llms.txt Deletes a specific account from a Connected ID. ```APIDOC ## POST /delete_account ### Description Removes a specific institution's account from a Connected ID. ### Method POST ### Endpoint /delete_account ### Parameters #### Request Body - **connectedId** (string) - Required - Existing Connected ID - **accountList** (array) - Required - List of account objects to delete. ``` -------------------------------- ### Delete Account from Connected ID Source: https://context7.com/codef-io/easycodefpy/llms.txt Remove a specific bank account from a Connected ID. This action severs the link to that account within the specified Connected ID. ```python from easycodefpy import Codef, ServiceType import json codef = Codef() codef.public_key = 'MIIBIjANBgkqh...' codef.set_client_info('your_client_id', 'your_client_secret') # 삭제할 계정 정보 account_list = [{ 'countryCode': 'KR', 'businessType': 'BK', 'clientType': 'P', 'organization': '0004', 'loginType': '1' }] parameter = { 'connectedId': 'byi1wYwD40k8hEIiXl6bRF', 'accountList': account_list } # 계정 삭제 요청 response = codef.delete_account(ServiceType.SANDBOX, parameter) result = json.loads(response) print(f"결과: {result['result']['message']}") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.