/settings

GET POST SYNC

Retrieve and update application settings.

GET /api/v1/settings
Alias: /get-application-settings
POST /api/v1/settings
Alias: /update-application-settings

Description

This endpoint allows you to read the current application configuration (GET) or overwrite it with new values (POST). Settings control various aspects of the application's behavior, such as network timeouts and default file paths. Both calls are synchronous and return a result immediately.


GET /settings

Retrieves a JSON object containing the current application settings.

Response

Returns a `200 OK` response with a JSON object representing the current settings.

Example Response

{
    "RAIDATimeout": 10,
    "DefaultExportFolder": "/Users/user/Documents/CloudCoin",
    "LogLevel": "info",
    "UseLocalRaidas": false
}

POST /settings

Updates the application settings by accepting a new settings object. The provided object will replace the existing configuration.

Request Body

The request body should be a JSON object with the same structure as the one returned by the GET endpoint.

Settings Properties

Property Type Description
RAIDATimeoutintegerTimeout in seconds for requests to RAIDA servers.
DefaultExportFolderstringThe default file path for exporting coins.
LogLevelstringThe logging level (e.g., "debug", "info", "error").
UseLocalRaidasbooleanIf true, use a local list of RAIDA servers instead of querying guardians.

Response

Returns a `200 OK` with no content if the settings were saved successfully.


Examples

JavaScript: GET Settings

const apiHost = 'http://localhost:8006';

async function getSettings() {
    const response = await fetch(`${apiHost}/api/v1/settings`);
    const settings = await response.json();
    console.log('Current Settings:', settings);
}

getSettings();

JavaScript: POST Settings

async function updateSettings() {
    const newSettings = {
        "RAIDATimeout": 15,
        "DefaultExportFolder": "/Users/user/Desktop/Exports",
        "LogLevel": "debug",
        "UseLocalRaidas": false
    };

    const response = await fetch(`${apiHost}/api/v1/settings`, {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify(newSettings)
    });

    if (response.ok) {
        console.log('Settings updated successfully!');
    } else {
        console.error('Failed to update settings.');
    }
}

updateSettings();

cURL: GET Settings

# Get current settings
curl -X GET "http://localhost:8006/api/v1/settings"

cURL: POST Settings

# Update settings
curl -X POST "http://localhost:8006/api/v1/settings" \
-H "Content-Type: application/json" \
-d '{
    "RAIDATimeout": 15,
    "DefaultExportFolder": "/Users/user/Desktop/Exports",
    "LogLevel": "debug",
    "UseLocalRaidas": false
}'

Go: GET Settings

package main

import (
    "encoding/json"
    "fmt"
    "log"
    "net/http"
)

const apiHost = "http://localhost:8006/api/v1"

type Settings struct {
    RAIDATimeout        int    `json:"RAIDATimeout"`
    DefaultExportFolder string `json:"DefaultExportFolder"`
    LogLevel            string `json:"LogLevel"`
    UseLocalRaidas      bool   `json:"UseLocalRaidas"`
}

func getSettings() {
    resp, err := http.Get(fmt.Sprintf("%s/settings", apiHost))
    if err != nil {
        log.Fatalf("Request failed: %v", err)
    }
    defer resp.Body.Close()

    var settings Settings
    if err := json.NewDecoder(resp.Body).Decode(&settings); err != nil {
        log.Fatalf("Failed to decode response: %v", err)
    }
    fmt.Printf("Current settings: %+v\n", settings)
}

Go: POST Settings

package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "log"
    "net/http"
)

func updateSettings() {
    newSettings := Settings{
        RAIDATimeout:        15,
        DefaultExportFolder: "/Users/user/Desktop/Exports",
        LogLevel:            "debug",
        UseLocalRaidas:      false,
    }
    payload, err := json.Marshal(newSettings)
    if err != nil {
        log.Fatalf("Failed to marshal JSON: %v", err)
    }

    resp, err := http.Post(fmt.Sprintf("%s/settings", apiHost), "application/json", bytes.NewBuffer(payload))
    if err != nil {
        log.Fatalf("Request failed: %v", err)
    }
    defer resp.Body.Close()

    if resp.StatusCode == http.StatusOK {
        fmt.Println("Settings updated successfully.")
    } else {
        log.Fatalf("Failed to update settings, status: %s", resp.Status)
    }
}