APIJSON-Demo Documentation

repository·master·Indexed 19 days ago

https://github.com/apijson/apijson-demo

A collection of example projects and documentation for implementing Tencent's APIJSON across multiple platforms. Includes quickstart guides for Android (Android Studio), iOS (Swift/Xcode), and Java server integration via APIJSONBoot. Features documentation on using the /delegate interface for proxying and traffic recording, automated regression testing with Before/After comparison, machine learning-based interface testing, and the APIAuto SPA tool for test case management and headless CI/CD execution.

Tokens
40.2K
Snippets
105
Records
184
Agent score
66%

What's inside APIJSON-Demo

  1. Overview of CVAuto

    master

    CVAuto is a zero-code, zero-annotation automated testing platform for Computer Vision (CV) AI models. It allows users to test the functionality, effect, and performance of AI image recognition algorithms without manual bounding box or label annotation.

    Key Workflow:

    1. Upload Test Images: Upload images to be tested.
    2. API Call: The platform calls the algorithm model via HTTP API to get a JSON response.
    3. Automatic Rendering: It automatically draws labels, bounding boxes, lines, points, or polygons on the image based on the JSON response.
    4. Automated Assertion & Correction: Users can verify if boxes are correct. If a false positive occurs, users can click near the border to change a checkmark (✓) to an 'X'.
    5. Metric Calculation: The platform automatically calculates metrics such as Correct count, False Positives, False Negatives, Recall, Precision, and F1 Score, and allows for comparison between different versions.
  2. Overview of AutoUI

    master

    AutoUI is a zero-code, zero-annotation Computer Vision (CV) AI automated testing tool. It is designed for algorithm engineers, researchers, and testers to quickly validate the functionality, effectiveness, and performance of AI models (such as YOLO detection, pose estimation, and segmentation) without manual ground truth labeling.

    Key Capabilities:

    • Automated Inference Visualization: Upload images or videos, call HTTP APIs to get JSON responses, and AutoUI automatically draws labels, bounding boxes, lines, points, and polygons on the media.
    • Automated Assertion & Correction: Automatically checks if bounding boxes are correct. Users can manually correct errors (marking a box as ✓ or X) by clicking near the border, which instantly updates performance metrics.
    • Metric Statistics: Automatically calculates accuracy, false positives, false negatives, recall, precision, and F1 Score.
    • Data Export: One-click download of test reports (including summary metrics and per-image details) and export of training/testing datasets to accelerate model iteration.
  3. Overview of SQLAuto

    master
    SQLAuto is an intelligent zero-code tool designed for testing SQL statements, performing arbitrary CRUD operations, and managing SQL template variables. It enables users to quickly generate large volumes of test data and batch parameter combinations. It is particularly useful for generating 1000+ test records for INSERT statements using custom rules and random parameter injection.
  4. Choose an APIJSON Server-side Demo

    master

    The APIJSON-Java-Server directory contains several demo projects tailored to different database and connection pool requirements:

    JDBC Demos

    • APIJSONDemo: Simple testing with SpringBoot + MySQL/PostgreSQL. Configure via DemoSQLConfig.
    • APIJSONBoot: Complex production-ready demo with SpringBoot + MySQL + PostgreSQL + SQLServer + TDengine. Configure via DemoSQLConfig.
    • APIJSONFinal: Complex production-ready demo with SpringBoot + MySQL + PostgreSQL. Configure via DemoSQLConfig.

    Connection Pool Demos

    • APIJSONDemo-Druid: Testing with SpringBoot + Druid + MySQL/PostgreSQL. Configure via application.yml.
    • APIJSONDemo-HikariCP: Testing with SpringBoot + HikariCP + MySQL/PostgreSQL. Configure via application.yml.
    • APIJSONBoot-MultiDataSource: Complex production-ready demo with SpringBoot + Druid + HikariCP + PostgreSQL + SQLServer + TDengine + Dameng. Configure via application.yml.

    Sharding & BigData Demos

    • APIJSONDemo-ShardingSphere: Testing with SpringBoot + ShardingSphere + MySQL/PostgreSQL. Configure via application.yml and application-sharding-databases.properties.
    • APIJSONBoot-BigData: Complex production-ready demo with SpringBoot + Presto + Trino + Elasticsearch.
  5. Key features of APIJSONSimpleDemo-SpringBoot3

    master

    The APIJSONSimpleDemo-SpringBoot3 project serves as a middle-ground complexity example between APIJSONBoot and APIJSONDemo. It includes several common production-ready configurations:

    • Simple Authentication: Basic security implementation.
    • SameSite Policy: Configured cookie/session security.
    • HikariCP Multi-DataSource: Configuration for managing multiple data sources using HikariCP.
    • Precision Handling: Solutions to prevent precision loss of numeric values when returning data to the frontend.
  6. Get started with APIJSON-Demo

    master

    APIJSON-Demo provides example projects, documentation, and SQL files for Tencent APIJSON across various programming languages (Java, Swift, JavaScript, Python), frameworks (SpringBoot, JFinal), and clients (Web, Android, iOS).

    To quickly test APIJSON without setting up your own environment, you can use the official APIJSON server at apijson.cn:8080.

  7. Handle Script Thread Safety

    master

    Scripts may encounter thread safety issues depending on the engine. Specifically, Lua Bindings are currently not guaranteed to be thread-safe.

    To prevent concurrency issues, you must implement external locking. It is recommended to use a lock granularity based on the script name (e.g., if the script is named length, use length as the lock key).

    Supported locking mechanisms include:

    • lock / synchronized (Java-level)
    • Redis distributed locks
  8. Access APIJSON Metadata and Parameters in Scripts

    master

    When executing scripts, you can access APIJSON metadata and custom extended parameters.

    Metadata (_meta)

    The _meta object provides access to:

    • version: The current version.
    • tag: The current tag.
    • args: An array of arguments passed to the function.

    Extended Parameters (extParam)

    You can pass custom business parameters via extParam, which are accessible directly within the script context.

  9. How multiple datasources are resolved

    master

    APIJSON supports multiple datasources by allowing you to specify a @datasource key at different levels of the JSON request. The resolution follows this precedence order (from highest to lowest):

    1. Object level: Specified directly within a specific object (e.g., "User:aa": { "@datasource": "db2" }).
    2. Global level: Specified at the root of the JSON request (e.g., { "@datasource": "db2", ... }).
    3. Application default: The default datasource configured in the application settings.

    This allows you to mix data from different sources (like a relational database and Elasticsearch) in a single request, using cross-datasource references via the @ syntax (e.g., "user_id@": "User:aa/id").

    {
      // Global datasource
      "@datasource": "db2",
      "@post": {
        "User:aa": {
           "@datasource": "db2" // Object level datasource
        },
        "ES_blog:a": {
           "@datasource": "elasticSearch" // Overriding to use Elasticsearch
        }
      }
    }