Manage and view profiles
mainThe CLI supports multiple user profiles.
- List profiles: Use
show-profilesto see the names of all configured profiles. - Select profile: Use the
-pflag followed by the profile name to use a specific account.
repository·main·Indexed 42 days ago
https://github.com/roeniss/dhlottery-apiAn unofficial API and CLI wrapper for the Donghaeng Lottery (동행복권) website. It allows users to purchase Lotto 6/45 tickets in automatic, manual, and semi-automatic modes, check account balances, view purchase history, and manage deposit virtual accounts directly from the terminal.
The CLI supports multiple user profiles.
show-profiles to see the names of all configured profiles.-p flag followed by the profile name to use a specific account.To use the dhapi CLI, you need Python 3.9 or higher. You can install it using pip or uv.
pip install dhapi --upgradeuv pip install dhapi --upgradepip install dhapi --upgradeIf you do not want to install the package permanently, you can run commands directly using uvx.
uvx dhapi --help
uvx dhapi buy-lotto645 --help
uvx dhapi buy-lotto645 -yProfile information is stored in a TOML file located at ~/.dhapi/credentials. You can manually edit this file to add or modify multiple accounts. Each section represents a profile name.
To use a specific profile, pass it via the -p flag in your commands.
[default]
username = "dhlotter_id"
password = "****"
[another_profile]
username = "dhlotter_second_id"
password = "****"The dhapi command-line interface allows you to manage your Donghaeng Lottery account, check balances, and purchase Lotto 6/45 tickets.
Common global options available for most commands:
-p, --profile: Specify which profile to use (defaults to default).-d, --debug: Enable debug logging and detailed exception reporting.# Example of general usage pattern
dhapi buy-lotto645 --profile my-profile --debugIf main.py fails to execute, you may need to explicitly set the PYTHONPATH to ensure the module structure is correctly recognized. Run the command from the parent directory of src.
cd ..
PYTHONPATH=./src/ python3 src/dhapi/main.py buy_lotto645 -qA successful Lottery645 purchase returns a JSON object containing login status and a result object. The arrGameChoiceNum array contains strings representing the game choices, where the suffix indicates the selection type: 1 for Manual, 2 for Combine, and 3 for Automatic.
{
"loginYn": "Y",
"result": {
"oltInetUserId": "00NNNNNNN",
"issueTime": "hh:mm:ss",
"issueDay": "yyyy/MM/dd",
"resultCode": "100",
"barCode4": "nnnnn",
"barCode5": "nnnnn",
"barCode6": "nnnnn",
"barCode1": "nnnnn",
"barCode2": "nnnnn",
"barCode3": "nnnnn",
"resultMsg": "SUCCESS",
"buyRound": "950",
"arrGameChoiceNum": [
"A|nn|nn|nn|nn|nn|nn3", # Manual: 1, Combine: 2, Automatic: 3
"B|nn|nn|nn|nn|nn|nn3",
"C|nn|nn|nn|nn|nn|nn3"
],
"weekDay": "월",
"payLimitDate": None,
"drawDate": None,
"nBuyAmount": 3000
}
}When interacting with the Lottery645 purchase functionality, the request body requires specific fields. Note that direct is not strictly required for operation, and ROUND_DRAW_DATE or WAMT_PAY_TLMT_END_DT can be omitted.
data = {
"round": 777,
"direct": "172.17.20.52", # Not strictly required
"nBuyAmount": str(1000 * 3),
"param": '[{"genType":"0","arrGameChoiceNum":null,"alpabet":"A"},{"genType":"0","arrGameChoiceNum":null,"alpabet":"B"},{"genType":"0","arrGameChoiceNum":null,"alpabet":"C"}]',
# "ROUND_DRAW_DATE": "2021/06/12", # Can be omitted
# "WAMT_PAY_TLMT_END_DT": "2022/06/13", # Can be omitted
"gameCnt": 3,
}Automates the process of selecting a deposit amount for your assigned personal virtual account.
Note: This command only prepares the setting on the website; you must still perform the actual bank transfer manually. The 'Quick Recharge' (간편 충전) feature is not implemented.
Purchase Lotto 6/45 tickets. Supports automatic, manual, and semi-automatic modes. You can purchase up to 5 tickets at a time. Note that the Donghaeng Lottery policy limits purchases to a maximum of 5 tickets per week.
Use the -y flag to enable automatic mode (purchasing 5 tickets) and skip the confirmation step.
dhapi buy-lotto645 -yUse assign_virtual_account to set up a virtual account for depositing funds. The CLI will output the account details, and you must manually deposit the specified amount into that account.
Arguments:
amount: The amount to deposit. Supported values: 5000, 10000, 20000, 30000, 50000, 100000, 200000, 300000, 500000, 700000, 1000000 (Note: The help text suggests these specific increments).dhapi assign-virtual-account 50000