Data & HTTP

Data & HTTP

Connect to the world. Fetch data from APIs, read/write files, and interact with the clipboard.


1. HTTP Requests

Fetch data from REST APIs using GET, POST, PUT, or DELETE methods.

cloud_download

GET

Retrieve data from a server.

cloud_upload

POST

Send data to a server.

App.xml
<!-- Simple GET Request -->
<HttpRequest 
    Method="GET" 
    Url="https://api.github.com/users/modderboyy" 
    ToState="userData"/>

<!-- POST Request with JSON Body -->
<HttpRequest 
    Method="POST" 
    Url="https://api.example.com/login" 
    Body="{ 'username': '{user}', 'password': '{pass}' }" 
    ToState="loginResult"/>
info
Note: HTTP requests are synchronous by default. For long operations, consider using Animate to show a loading spinner before the request.

2. JSON Parsing

Nimbus includes a built-in JsonPlugin to extract values from JSON strings returned by APIs.

<!-- Assume 'userData' contains: {"name": "John", "id": 123} -->

<Plugin Name="JsonPlugin" Method="get" 
        Params="{userData},name" 
        ToState="userName"/>

<Set Target="lblName" Property="Text" Value="{userName}"/>

Functions available:

  • json.get(json, key) - Get value by key.
  • json.count(json) - Count items in array/object.
  • json.has(json, key) - Check if key exists.

3. File System

Read and write files on the user's computer. Useful for saving settings or exporting data.

Save File

Opens a "Save As" dialog and saves content.

<!-- Save content from a TextBox -->
<SaveFile FromControl="txtEditor" Filter="Text Files|*.txt"/>

<!-- Save specific content -->
<SaveFile Content="Hello World" FileName="test.txt"/>

Open File

Opens an "Open File" dialog and reads content.

<!-- Read file into a TextBox -->
<OpenFile ToControl="txtEditor" Filter="Text Files|*.txt"/>

<!-- Read file into a Variable -->
<OpenFile ToState="fileContent"/>

Direct File Operations (Plugin)

For silent file operations without dialogs, use FilePlugin.

<!-- Write directly -->
<Plugin Name="FilePlugin" Method="write" Params="log.txt,System started"/>

<!-- Check existence -->
<Plugin Name="FilePlugin" Method="exists" Params="config.xml" ToState="hasConfig"/>

4. Clipboard

Copy and paste text to/from the system clipboard.

<!-- Copy from Variable -->
<Copy Text="{apiKey}"/>

<!-- Copy from TextBox -->
<Copy FromControl="txtResult"/>

<!-- Paste into TextBox -->
<Paste ToControl="txtInput"/>