/api/program/get-dropdown
GETRetrieves 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.
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
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
Allowed File Values
Returns: Array of wallet names (first column only)
Auto-created: Yes, with CSV headers
Returns: Array of backup location paths
Auto-created: Yes, empty file
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
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
Invalid file: The requested file is not in the allowed list.
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
cURL
# Get wallet dropdown list
curl -X GET "http://localhost:8080/api/program/get-dropdown?file=wallet-locations.csv"
# Get backup locations
curl -X GET "http://localhost:8080/api/program/get-dropdown?file=BackupPlaces.txt"
# Get export locations
curl -X GET "http://localhost:8080/api/program/get-dropdown?file=export-locations.txt"
# Example with jq to extract just the items array
curl -X GET "http://localhost:8080/api/program/get-dropdown?file=wallet-locations.csv" | jq '.items'
Go
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
)
const ApiHost = "http://localhost:8080"
type DropdownResponse struct {
Status string `json:"status"`
Operation string `json:"operation"`
File string `json:"file"`
Path string `json:"path"`
Items []string `json:"items"`
}
func getDropdown(filename string) (*DropdownResponse, error) {
// Build URL with query parameter
params := url.Values{}
params.Add("file", filename)
url := fmt.Sprintf("%s/api/program/get-dropdown?%s", ApiHost, params.Encode())
resp, err := http.Get(url)
if err != nil {
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
var result DropdownResponse
if err := json.Unmarshal(body, &result); err != nil {
return nil, err
}
return &result, nil
}
func main() {
// Get wallet list
wallets, err := getDropdown("wallet-locations.csv")
if err != nil {
panic(err)
}
fmt.Println("Available Wallets:")
for _, wallet := range wallets.Items {
fmt.Printf(" - %s\n", wallet)
}
// Get backup locations
backups, err := getDropdown("BackupPlaces.txt")
if err != nil {
panic(err)
}
fmt.Println("\nBackup Locations:")
for _, location := range backups.Items {
fmt.Printf(" - %s\n", location)
}
}
Implementation Notes
- CSV Files: The header row is automatically skipped. Only the first column value is returned for each data row.
- Text Files: Each line becomes an array item. Empty lines are automatically filtered out.
- Line Endings: Both Windows (CRLF) and Unix (LF) line endings are handled correctly.
- Auto-Creation: If a requested file doesn't exist, it will be created automatically. CSV files get proper headers.
- File Location: All files are read from the Data directory within the CloudCoin Console installation.
CSV File Format - wallet-locations.csv
The wallet-locations.csv file uses the following structure:
wallet_name,location_path,is_usb,is_network,auto_mount,read_only
Default,C:\CloudCoin\Wallets\Default,0,0,0,0
Savings,C:\CloudCoin\Wallets\Savings,0,0,0,0
USB-Wallet,E:\CloudCoin,1,0,1,0
Network-Vault,\\NAS\CloudCoin,0,1,0,1
Note: This endpoint only returns the wallet_name column. Use /api/wallet/list to get complete wallet information including all columns.
Related Endpoints
/api/wallet/list
Get complete wallet information including paths, types, and configuration for all wallets.