Get available coupon list interface

Get the list of coupons that the current user can use under the current situation, supporting filtering by order amount and product ID.

Points to note

  • This interface is used to get the list of coupons available to the current user
  • Coupons applicable to orders of specified amount can be filtered by the amount parameter
  • The discount for the specified product can be filtered through the archive_id parameter
  • You need to log in to get the coupon list
  • Ensure that the domain address is correctly configured
  • Returns the current time valid and unused coupons
  • The validity of the voucher includes time range, usage conditions, and other restrictions

Request address

{域名地址}/api/coupon/valid

Description:{域名地址}Replace it with your domain name, such ashttps://en.anqicms.com/api/coupon/valid

Request Syntax

GET /api/coupon/valid

Request Headers

This interface involves only public request headers. For more information, please refer toCommon Request Headers (Common Request Headers).

Request parameters

Field name Type Required Description
amount int No Order amount, used to filter vouchers that meet the amount conditions
archive_id int No Product ID, used to filter vouchers that can be used for specified products

Response header

This interface only involves common response headers. For more information, please refer toCommon Request Headers (Common Request Headers).

Return parameters

Field name Type Description
code int Error code
msg string Error description
data object[] result content
Total int Total

data result item parameter

Field name Type Description
id int Coupon code ID
Title string Coupon name
coupon_id int Coupon ID
start_time int start time
End Time int end time
user_id int User ID
money Float Discount Amount
max money Float Highest Discount Amount
get_time int Claim Time
use_time int Usage Time
order_id int Order ID
money_type int Discount amount type 0 = Fixed amount, 1 = Random amount, 2 = Percentage discount
description string description

Usage Example

Request example

GET /api/coupon/valid?amount=100&archive_id=5 HTTP/1.1
Host: www.anqicms.com

Response Example

{
  "code": 0,
  "data": [
    {
      "id": 1,
      "title": "满减优惠券",
      "coupon_id": 1,
      "start_time": 1624494644,
      "end_time": 1627173044,
      "user_id": 1,
      "money": 10.00,
      "max_money": 0.00,
      "get_time": 1624494644,
      "use_time": 0,
      "order_id": 0,
      "money_type": 0,
      "description": "满100可用"
    },
    {
      "id": 2,
      "title": "新用户优惠券",
      "coupon_id": 2,
      "start_time": 1624494644,
      "end_time": 1627173044,
      "user_id": 1,
      "money": 20.00,
      "max_money": 0.00,
      "get_time": 1624494650,
      "use_time": 0,
      "order_id": 0,
      "money_type": 0,
      "description": "新用户专享优惠券"
    }
  ],
  "msg": "",
  "total": 2
}

Error code

Error code Description
0 OK
-1 Error, the reason is indicated in msg
1001 Not logged in
1002 Not authorized
200 API request OK