🌐 AppML API & References
Estimated reading: 4 minutes 91 views

🌐 AppML – API Overview: Power Your AppML Apps with Dynamic Data

🧲 Introduction – What Is the AppML API?

AppML is not just a model-view binding frameworkβ€”it also supports API-driven development. You can connect your AppML views to RESTful APIs, server scripts (PHP/ASP), or even JSON and XML endpoints using simple HTML attributes. This makes it easy to build dynamic, data-driven web appsβ€”without needing JavaScript libraries.

🎯 In this guide, you’ll learn:

  • How AppML uses APIs to fetch and update data
  • Supported request types: GET, POST, PUT, DELETE
  • API structure for client-server communication
  • Real-world use cases and code examples

πŸ”Œ What Is the AppML API?

The AppML API is not a standalone framework or serviceβ€”rather, it’s how AppML communicates with backend servers. You define your model and link it to an API endpoint via the appml-data attribute. This endpoint can return data, handle form submissions, and perform CRUD operations.


πŸ—‚οΈ Basic API Workflow in AppML

🎯 StepπŸ”„ Description
appml-dataSpecifies the API URL or server endpoint
appml-modelDefines how to structure, validate, and bind the data
Controller logicAdds filters, sort options, or validation
ViewAutomatically updates with API response

πŸ§ͺ Example: Loading Data from an API

βœ… HTML

<div appml-model="models/user-model.json" appml-data="api/get-users.php">
  <p>{{name}} – {{email}}</p>
</div>

βœ… get-users.php

<?php
$users = [
  ["name" => "Alice", "email" => "alice@example.com"],
  ["name" => "Bob", "email" => "bob@example.com"]
];
echo json_encode($users);
?>

βœ… AppML fetches and renders this data using the model definition.


πŸ” Supported API Operations in AppML

HTTP MethodAppML OperationExample Use Case
GETReadLoad users, products, etc.
POSTCreateAdd a new record from a form
PUTUpdateEdit existing record
DELETEDeleteRemove an item (manually coded)

Example: Form Submission via POST

<div appml-model="models/product-model.json" appml-data="api/save-product.php">
  <input name="name">
  <input name="price" type="number">
  <button appml-submit>Save</button>
</div>

AppML sends the form as JSON to save-product.php.


🧠 Controller Logic to Enhance API Calls

You can dynamically control how data is sent to or retrieved from your API:

myAppML.onshow = function() {
  myAppML.sqlfilter = "price > 100";
};

myAppML.onsubmit = function() {
  myAppML.message = "Product saved successfully!";
  return true;
};

πŸ”’ Securing AppML API Endpoints

While AppML handles client-side rendering, make sure your server-side API:

  • Validates and sanitizes all inputs
  • Restricts access via authentication/authorization
  • Escapes SQL queries to prevent injection
  • Sends proper HTTP status codes

πŸ“¦ Use Cases for API in AppML

πŸ’Ό ScenarioπŸ’¬ API Integration Example
Admin dashboardLoad users, stats, and analytics
Product managementCreate/edit/delete products
Customer data formsSubmit feedback or registration
Reporting systemLoad report data via JSON API
Remote filtering/searchApply filters on server response

πŸ“Œ Summary – Recap & Key Takeaways

AppML uses API endpoints to fetch, filter, and save data with no JavaScript coding required. This allows you to connect your frontend to any modern backend using REST-style services or custom PHP scripts.

πŸ” Key Takeaways:

  • Use appml-data to define your API endpoint
  • Combine with appml-model for structured input and validation
  • Supports full CRUD with GET/POST/PUT/DELETE
  • Use controllers to apply filters, sorting, and form handling
  • API responses must return JSON or XML for compatibility

βš™οΈ With AppML APIs, you can build lightweight, dynamic apps that talk to real serversβ€”all from HTML.


❓ FAQs – AppML API Usage


❓ Can I use third-party REST APIs with AppML?
βœ… Yes, as long as they return data in JSON or XML and CORS is enabled.


❓ What format should my server return?
βœ… AppML supports both JSON arrays and XML records. JSON is preferred.


❓ Does AppML handle HTTP errors?
⚠️ No automatic error alerts. Use myAppML.message to show error responses.


❓ Can I send authentication tokens with requests?
βœ… Yes, by customizing your controller to include headers or query params (with backend support).


❓ Is AppML compatible with Node.js or Python backends?
βœ… Yes. Any backend that sends/receives JSON can work with AppML seamlessly.


Share Now :
Share

AppML – API Overview

Or Copy Link

CONTENTS
Scroll to Top