/api/program/get-dropdown

GET

Retrieves dropdown menu data from configuration files for populating UI selection components.

Description

The `/api/program/get-dropdown` endpoint reads data from configuration files stored in the CloudCoin Console's Data directory and returns it as a JSON array suitable for populating dropdown menus and selection lists in user interfaces. This endpoint provides a secure, validated way to access configuration data without direct filesystem access.

The endpoint automatically creates empty configuration files if they don't exist, ensuring consistency across installations. For CSV files like `wallet-locations.csv`, it will initialize them with proper headers.

💡 Use Cases

This endpoint is ideal for:

  • Populating wallet selector dropdowns
  • Loading backup location lists
  • Displaying export destination options
  • Building dynamic configuration UIs
  • Quick wallet switching interfaces
⚠️ Security

For security reasons, this endpoint only allows access to a whitelist of specific configuration files. Attempting to access any other file will result in a 400 Bad Request error.

Parameters

file required
string (query)
The configuration file to read. Must be one of the allowed values listed below.

Allowed File Values

wallet-locations.csv
CSV format with headers: wallet_name, location_path, is_usb, is_network, auto_mount, read_only
Returns: Array of wallet names (first column only)
Auto-created: Yes, with CSV headers
BackupPlaces.txt
Plain text format: One backup location path per line
Returns: Array of backup location paths
Auto-created: Yes, empty file
export-locations.txt
Plain text format: One export destination path per line
Returns: Array of export destination paths
Auto-created: Yes, empty file

Response

Returns a JSON object containing the dropdown items as an array.

Response Properties

status string
Always "success" for successful requests.
operation string
Always "get-dropdown".
file string
The requested filename (echoed back from request).
path string
Full filesystem path to the configuration file that was read.
items array
Array of strings containing the dropdown items. For CSV files, only the first column is included. Empty lines are skipped.

Example Response - wallet-locations.csv

{
  "status": "success",
  "operation": "get-dropdown",
  "file": "wallet-locations.csv",
  "path": "D:\\CloudCoin\\Pro\\Data\\wallet-locations.csv",
  "items": [
    "Default",
    "Savings",
    "Business"
  ]
}

Example Response - BackupPlaces.txt

{
  "status": "success",
  "operation": "get-dropdown",
  "file": "BackupPlaces.txt",
  "path": "D:\\CloudCoin\\Pro\\Data\\BackupPlaces.txt",
  "items": [
    "E:\\Backups\\CloudCoin",
    "\\\\NAS\\CloudCoin",
    "C:\\Users\\John\\OneDrive\\CloudCoin"
  ]
}

Error Responses

400 Bad Request
Missing parameter: The 'file' parameter was not provided.
Invalid file: The requested file is not in the allowed list.
500 Internal Server Error
File creation failed: Could not create the configuration file.
Read failed: Could not read the configuration file.

Example Error - Missing Parameter

{
  "status": "error",
  "error": "Missing 'file' parameter"
}

Example Error - Invalid File

{
  "status": "error",
  "error": "Invalid file parameter. Allowed: wallet-locations.csv, BackupPlaces.txt, export-locations.txt"
}

Examples

JavaScript (fetch)

const API_HOST = 'http://localhost:8080';

// Get wallet list for dropdown
async function getWalletDropdown() {
    try {
        const response = await fetch(
            `${API_HOST}/api/program/get-dropdown?file=wallet-locations.csv`
        );
        const result = await response.json();

        if (result.status === 'success') {
            console.log('Available wallets:', result.items);

            // Populate a