Practical Guide to API Debugging and Automated Testing Platforms: Postman, Hoppscotch, Swagger Full Workflow
1. Why Use API Debugging Tools?
When working with JD Open Platform APIs (or third-party integrations like LuckData’s JD API wrapper), the following issues are common:
Tedious parameter concatenation and signature calculation;
Difficult to quickly identify errors;
Hard to reuse parameters or switch between environments;
No easy way to build test cases or share interface documentation with the team.
In such cases, using API debugging and testing platforms can significantly improve efficiency and maintainability.
2. Overview and Comparison of Mainstream Tools
Tool | Features | Ideal Use Case |
---|---|---|
Postman | Supports collections, environment variables, pre-request scripts, tests | Widely used by enterprise teams |
Hoppscotch | Open source, lightweight, no login required, supports WebSocket | Quick testing or lightweight usage |
Swagger UI | Auto-generates API docs, supports interactive online debugging | API documentation and maintenance |
Swagger + Newman (Postman CLI tool) | Supports CI/CD integration for automated regression testing | Automation workflows |
3. Debugging JD API (Official or via LuckData) Using Postman
1. Constructing a Basic Request
Using the JD Union API for product search jingdong.union.search.goods.query
as an example:
Request URL:
POST https://api.jd.com/routerjson
Optional Headers:
Content-Type: application/x-www-form-urlencoded
Request Body (x-www-form-urlencoded):
{"app_key": "your_app_key",
"method": "jingdong.union.search.goods.query",
"access_token": "your_access_token",
"timestamp": "2025-05-15 10:30:00",
"format": "json",
"v": "1.0",
"sign": "calculated_signature",
"360buy_param_json": "{\"goodsReqDTO\":{\"keyword\":\"iPhone\"}}"
}
✅ If you’re using LuckData’s JD API, the signature process is already handled. You only need to pass standard parameters, simplifying the process greatly.
2. Auto-Generating Signatures with Pre-request Script (for JD Official API)
In Postman’s Pre-request Script, add the following JavaScript to calculate the signature:
const appSecret = "your_app_secret";const params = {
method: "jingdong.union.search.goods.query",
app_key: "your_app_key",
access_token: "your_access_token",
timestamp: pm.variables.replaceIn("{{timestamp}}"),
v: "1.0",
format: "json",
"360buy_param_json": JSON.stringify({
goodsReqDTO: {
keyword: "iPhone"
}
})
};
let signStr = appSecret;
Object.keys(params).sort().forEach(k => {
signStr += k + params[k];
});
signStr += appSecret;
const md5 = CryptoJS.MD5(signStr).toString().toUpperCase();
params["sign"] = md5;
pm.environment.set("signed_params", JSON.stringify(params));
In the Body section, reference the signed parameters using {{signed_params}}
.
4. Hoppscotch: Lightweight Open Source Alternative
If you want to quickly test an API without full test automation, Hoppscotch is a great choice:
No installation or login needed;
Supports various authentication methods;
Generates code snippets (e.g., Python, JavaScript);
Steps to use:
Visit hoppscotch.io;
Enter the JD API URL;
Select POST and
x-www-form-urlencoded
mode;Input all required parameters;
View the response.
✅ When using LuckData, simply provide the required parameters and the experience is smooth and straightforward.
5. Swagger UI: Interactive API Docs and Quick Testing
Ideal Use Cases:
When exposing your own API gateway (e.g., via Kong, Tyk);
Wrapping third-party APIs (like LuckData) for internal testing;
Providing public interactive API documentation for external developers.
Sample OpenAPI 3.0 YAML:
paths:/jingdong/goods-search:
post:
summary: JD product search API (Hosted by LuckData)
requestBody:
content:
application/json:
schema:
type: object
properties:
keyword:
type: string
example: "iPhone"
responses:
200:
description: Returns list of products
Deploy the above structure on:
Swagger UI;
ReDoc;
Stoplight.io;
These tools help provide clear and interactive API docs for both developers and stakeholders.
6. Automated Testing: Postman Collections + Newman
Define Tests in Postman:
pm.test("Response is successful", function () {pm.response.to.have.status(200);
});
pm.test("Response contains product data", function () {
const json = pm.response.json();
pm.expect(json.data).to.be.an("array");
});
Export the test collection and run it using the Newman CLI:
newman run jd_goods_collection.json
Integrate with GitHub Actions, Jenkins, or other CI/CD tools to enable automated regression testing.
7. LuckData API Advantages: No Signature, Easy Testing, Multi-Platform Support
Working with JD’s native API can be complex due to its signature logic, token refresh mechanics, and inconsistent request formatting. LuckData simplifies this with a unified, standardized API layer:
Use standard JSON format instead of
x-www-form-urlencoded
;No need to calculate signatures manually, just use a bearer token;
Supports unified request formats across JD, Taobao, Pinduoduo, Amazon, and more;
SDKs with built-in debugging tools for Python, Java, Shell, Node.js, and others.
Example JD Search Request via LuckData:
curl -X POST https://luckdata.cn/api/jingdong-api/goods-search \-H "Authorization: Bearer your_token" \
-d '{"keyword": "iPhone"}'
Much simpler than the original API integration process.
8. Summary
Tool | Key Features | Best Suited For |
---|---|---|
Postman | Signature scripting, test cases, variable management | Backend developers, QA engineers |
Hoppscotch | Instant online testing, no install or login required | DevOps, lightweight testing users |
Swagger UI | Auto-generated docs, interactive API testing | Teams with frontend or doc needs |
LuckData SDK | Signature-free, cross-platform API integration | Developers integrating multiple APIs |
Articles related to APIs :
JD API Third-Party SDKs and Community Libraries: Selection Strategies and Best Practices
In-depth Guide to JD.com APIs: After-Sales Services and Consumer Rights Protection
In-Depth Exploration of JD.com API: Order and Transaction Interfaces
JD Open Platform Practical Guide ③: Full Analysis of Product Query and Detail APIs
JD API Authentication and Signature Mechanism: A Complete Guide for Secure Integration
For seamless and efficient access to the Jingdong API, please contact our team : support@luckdata.com