Accelerate Java API Development with magic-api: A Hands‑On Guide

Discover how magic‑api, a Java‑based rapid API framework, streamlines backend development by eliminating boilerplate code, enabling visual API design, dynamic configuration, and seamless database integration, all demonstrated through a step‑by‑step tutorial using a SpringBoot e‑commerce project.

macrozheng
macrozheng
macrozheng
Accelerate Java API Development with magic-api: A Hands‑On Guide

Why Use magic-api?

When a new project requires fully dynamic page configuration—such as dropdown options, internationalization, and other simple conditions—all front‑end settings must be returned via API. With a tight schedule of only ten days and no extra staff, the author turned to magic‑api, a Java‑based rapid API development framework, to dramatically reduce development effort.

What Is magic-api?

magic‑api automatically maps UI‑defined endpoints to HTTP APIs, removing the need to write Controller, Service, Dao, Mapper, XML, VO and other Java objects. The UI lets you configure request paths, methods, parameters, and return values visually.

Recommended project: a SpringBoot + Vue + uni‑app e‑commerce system (GitHub ★60K) that includes both front‑end mall and back‑end admin modules. Project address: https://github.com/macrozheng/mall Video tutorials: https://www.macrozheng.com/video/

Environment Setup

Add the core package to pom.xml:

<dependency>
    <groupId>org.ssssssss</groupId>
    <artifactId>magic-api-spring-boot-starter</artifactId>
    <version>0.7.1</version>
</dependency>

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <scope>runtime</scope>
</dependency>

Configure application.yml (database settings are optional):

magic-api:
  web: /magic/web   # UI address
server:
  port: 9999
spring:
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://47.93.6.5:3306/magic-api
    username: root
    password: xinzhifu521

Environment is ready.

Practical Demo

Open the visual UI at http://127.0.0.1:9999/magic/web and create a group whose prefix acts like @Controller("/order"). Then add an endpoint order_detail that simply returns static data: return ‘小富最帅’ Accessing http://127.0.0.1:9999/order/order_detail returns the string. You can also return JSON directly.

For path variables, define the URL as /order_detail/{id} and use the request module to obtain the parameter:

import request;
a = path.id

Even without writing a single Java class, a functional API is created.

magic‑api also supports database operations via a Python‑like scripting module. By importing db and executing SQL, the result is returned as JSON, eliminating many intermediate steps.

Its syntax is close to Java but more concise; loops and lambdas can be written as:

var sum = 0;
var list = [1,2,3,4,5];
for(val in list){
    sum = sum + val;
}
list.each(it => sum+= it + 1)

Advanced features include calling Java APIs, integrating Redis, MongoDB, and many ready‑made demos.

Repository: https://gitee.com/ssssssss-team/magic-api

Personal Experience

During a rushed development cycle, magic‑api saved more than half of the backend coding time and greatly facilitated front‑end integration. By defining data structures early, the front‑end could test against real endpoints while the back‑end later replaced static data with business logic.

However, the author advises using magic‑api only for simple, configuration‑driven interfaces; core business logic should still follow proper architectural rules to ensure stability and security.

Further Resources

GitHub ★60K e‑commerce tutorial (SpringBoot 2.7, ~40 hours, 100 lessons)

Video tutorials and full project architecture are linked throughout the article.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaSpringBootAPI developmentrapid developmentmagic-api
macrozheng
Written by

macrozheng

Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.