{
  "openapi": "3.0.3",
  "info": {
    "title": "SmartProxyCN OpenAPI",
    "description": "SmartProxyCN OpenAPI",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.smartproxycn.com",
      "description": "生产环境接口地址"
    }
  ],
  "tags": [
    {
      "name": "代理账户管理"
    }
  ],
  "paths": {
    "/openapi/whitelist-account/list": {
      "get": {
        "tags": [
          "代理账户管理"
        ],
        "description": "代理账户列表",
        "parameters": [
          {
            "name": "app_key",
            "in": "query",
            "description": "认证密钥",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer",
                      "description": "状态码,200 成功、3 app_key 无效、156 账户未实名认证",
                      "example": 200
                    },
                    "msg": {
                      "type": "string",
                      "description": "状态消息"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "list": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "integer",
                                "description": "账户编号"
                              },
                              "username": {
                                "type": "string",
                                "description": "代理账户名"
                              },
                              "password": {
                                "type": "string",
                                "description": "代理账户密码"
                              },
                              "created_at": {
                                "type": "string",
                                "description": "添加时间"
                              },
                              "remark": {
                                "type": "string",
                                "description": "备注"
                              },
                              "product_type": {
                                "type": "integer",
                                "description": "对应套餐类型，9 动态住宅，16 静态住宅"
                              },
                              "usage_flow": {
                                "type": "integer",
                                "description": "已使用流量，单位：KB"
                              },
                              "limit_flow": {
                                "type": "integer",
                                "description": "自定义流量上限：单位GB，0 不限制"
                              },
                              "status": {
                                "type": "integer",
                                "description": "启用状态：1启用，0停用"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/openapi/whitelist-account/add": {
      "post": {
        "tags": [
          "代理账户管理"
        ],
        "description": "添加代理账户。",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "app_key": {
                    "type": "string",
                    "description": "授权密钥",
                    "required": true,
                    "maxLength": 32,
                    "minLength": 32
                  },
                  "accounts": {
                    "type": "string",
                    "description": "账户密码，请按格式 username:password 填写，账户和密码仅支持数字和字母，禁止输入任何特殊符号或空格,冒号隔开账户和密码。支持批量添加，英文逗号（,）分隔代理账户。",
                    "required": true,
                    "maxLength": 255,
                    "minLength": 3,
                    "default": "user01:pass,user02:pass,user03:pass"
                  },
                  "remark": {
                    "type": "string",
                    "description": "代理账户描述",
                    "default": "",
                    "maxLength": 64
                  },
                  "product_type": {
                    "type": "integer",
                    "description": "套餐类型，9 动态住宅、16静态住宅",
                    "enum": [
                      9,
                      16
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer",
                      "description": "状态码,200 成功、3 app_key 无效、156 账户未实名认证",
                      "example": 200
                    },
                    "msg": {
                      "type": "string",
                      "description": "状态消息"
                    },
                    "data": {
                      "type": "null"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/openapi/whitelist-account/delete": {
      "post": {
        "tags": [
          "代理账户管理"
        ],
        "description": "删除代理账户，请注意删除后无法恢复，已使用流量等无法查询。删除约有5分钟等待时间，在此期间仍可能产生费用。",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "app_key": {
                    "type": "string",
                    "description": "授权密钥",
                    "required": true,
                    "maxLength": 32,
                    "minLength": 32
                  },
                  "accounts": {
                    "type": "string",
                    "description": "代理账户，仅支持数字和字母。支持批量操作，英文逗号（,）分隔代理账户",
                    "required": true,
                    "maxLength": 255,
                    "minLength": 1,
                    "default": "user01,user02"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer",
                      "description": "状态码,200 成功、3 app_key 无效、156 账户未实名认证",
                      "example": 200
                    },
                    "msg": {
                      "type": "string",
                      "description": "状态消息"
                    },
                    "data": {
                      "type": "null"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/openapi/whitelist-account/disable": {
      "post": {
        "tags": [
          "代理账户管理"
        ],
        "description": "禁用代理账户，禁用约有5分钟等待时间，在此期间仍可能产生费用。",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "app_key": {
                    "type": "string",
                    "description": "授权密钥",
                    "required": true,
                    "maxLength": 32,
                    "minLength": 32
                  },
                  "accounts": {
                    "type": "string",
                    "description": "代理账户，仅支持数字和字母。支持批量操作，英文逗号（,）分隔代理账户",
                    "required": true,
                    "maxLength": 255,
                    "minLength": 1,
                    "default": "user01,user02"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer",
                      "description": "状态码,200 成功、3 app_key 无效、156 账户未实名认证",
                      "example": 200
                    },
                    "msg": {
                      "type": "string",
                      "description": "状态消息"
                    },
                    "data": {
                      "type": "null"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/openapi/whitelist-account/enable": {
      "post": {
        "tags": [
          "代理账户管理"
        ],
        "description": "启用代理账户",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "app_key": {
                    "type": "string",
                    "description": "授权密钥",
                    "required": true,
                    "maxLength": 32,
                    "minLength": 32
                  },
                  "accounts": {
                    "type": "string",
                    "description": "代理账户，仅支持数字和字母。支持批量操作，英文逗号（,）分隔代理账户",
                    "required": true,
                    "maxLength": 255,
                    "minLength": 1,
                    "default": "user01,user02"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer",
                      "description": "状态码,200 成功、3 app_key 无效、156 账户未实名认证",
                      "example": 200
                    },
                    "msg": {
                      "type": "string",
                      "description": "状态消息"
                    },
                    "data": {
                      "type": "null"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/openapi/whitelist-account/change-password": {
      "post": {
        "tags": [
          "代理账户管理"
        ],
        "description": "修改代理账户密码，请注意修改后有5分钟等待时间，在此期间旧密码仍可能正常使用。",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "app_key": {
                    "type": "string",
                    "description": "授权密钥",
                    "required": true,
                    "maxLength": 32,
                    "minLength": 32
                  },
                  "account": {
                    "type": "string",
                    "description": "代理账户，仅支持数字和字母。",
                    "required": true,
                    "maxLength": 16,
                    "minLength": 1,
                    "default": "user"
                  },
                  "password": {
                    "type": "string",
                    "description": "代理账户新密码，仅支持数字和字母。",
                    "required": true,
                    "maxLength": 16,
                    "default": "pass"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer",
                      "description": "状态码,200 成功、3 app_key 无效、156 账户未实名认证",
                      "example": 200
                    },
                    "msg": {
                      "type": "string",
                      "description": "状态消息"
                    },
                    "data": {
                      "type": "null"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/openapi/whitelist-account/change-remark": {
      "post": {
        "tags": [
          "代理账户管理"
        ],
        "description": "修改代理账户备注",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "app_key": {
                    "type": "string",
                    "description": "授权密钥",
                    "required": true,
                    "maxLength": 32,
                    "minLength": 32
                  },
                  "account": {
                    "type": "string",
                    "description": "代理账户，仅支持数字和字母。",
                    "required": true,
                    "maxLength": 16,
                    "minLength": 1,
                    "default": "user"
                  },
                  "remark": {
                    "type": "string",
                    "description": "代理账户新备注，32个中文或64个英文以内。",
                    "required": true,
                    "default": "",
                    "maxLength": 64
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer",
                      "description": "状态码,200 成功、3 app_key 无效、156 账户未实名认证",
                      "example": 200
                    },
                    "msg": {
                      "type": "string",
                      "description": "状态消息"
                    },
                    "data": {
                      "type": "null"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/openapi/whitelist-account/change-limit": {
      "post": {
        "tags": [
          "代理账户管理"
        ],
        "description": "修改代理账户流量上限，请注意流量统计可能有5分钟以内延迟，即实际消耗流量可能超过此限制。",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "app_key": {
                    "type": "string",
                    "description": "授权密钥",
                    "required": true,
                    "maxLength": 32,
                    "minLength": 32
                  },
                  "account": {
                    "type": "string",
                    "description": "代理账户，仅支持数字和字母。",
                    "required": true,
                    "maxLength": 16,
                    "minLength": 1,
                    "default": "user"
                  },
                  "limit": {
                    "type": "integer",
                    "description": "流量限制，单位：GB，0为不设上限",
                    "required": false,
                    "default": 0,
                    "maximum": 102400
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer",
                      "description": "状态码,200 成功、3 app_key 无效、156 账户未实名认证",
                      "example": 200
                    },
                    "msg": {
                      "type": "string",
                      "description": "状态消息"
                    },
                    "data": {
                      "type": "null"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/openapi/user-usage-flow/total": {
      "get": {
        "tags": [
          "流量日志查询"
        ],
        "description": "使用流量按天汇总",
        "parameters": [
          {
            "name": "app_key",
            "in": "query",
            "description": "认证密钥",
            "required": true
          },
          {
            "name": "start_time",
            "in": "query",
            "description": "起始时间，可精确到秒。请注意，日志记录有5分钟以内延迟。默认7天以内。",
            "example": "2022-08-01 00:00:00",
            "required": false
          },
          {
            "name": "end_time",
            "in": "query",
            "description": "截止时间，可精确到秒。请注意，日志记录有5分钟以内延迟。默认当前时间。",
            "example": "2022-08-01 23:59:59"
          },
          {
            "name": "username",
            "in": "query",
            "description": "子账户名称,默认查询所有账户，可指定子账户。请注意如果您添加了相同名称的子账户，此查询将返回同名代理账户的所有使用记录。",
            "required": false
          },
          {
            "name": "product_type",
            "in": "query",
            "description": "套餐类型,9 动态住宅，16 静态住宅，默认查询所有套餐类型。",
            "required": false
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer",
                      "description": "状态码,200 成功、3 app_key 无效、156 账户未实名认证",
                      "example": 200,
                      "required": true
                    },
                    "msg": {
                      "type": "string",
                      "description": "状态消息",
                      "required": true
                    },
                    "data": {
                      "type": "object",
                      "required": true,
                      "properties": {
                        "list": {
                          "type": "array",
                          "required": true,
                          "items": {
                            "type": "object",
                            "properties": {
                              "day": {
                                "type": "string",
                                "description": "日期",
                                "example": "2022-08-01"
                              },
                              "flow": {
                                "type": "integer",
                                "description": "消耗流量,单位KB",
                                "example": 0
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/openapi/user-product/list": {
      "get": {
        "tags": [
          "套餐查询"
        ],
        "description": "套餐列表",
        "parameters": [
          {
            "name": "app_key",
            "in": "query",
            "description": "认证密钥",
            "required": true
          },
          {
            "name": "trade_no",
            "in": "query",
            "description": "订单号，请输入完整订单号。不支持模糊搜索。",
            "example": "",
            "required": false
          },
          {
            "name": "page",
            "in": "query",
            "description": "分页，默认：1",
            "example": 1
          },
          {
            "name": "size",
            "in": "query",
            "description": "分页显示数量,默认：20",
            "required": false,
            "example": 20
          },
          {
            "name": "product_type",
            "in": "query",
            "description": "套餐类型,9 动态住宅，16 静态住宅，默认查询所有套餐类型。",
            "required": false
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer",
                      "description": "状态码,200 成功、3 app_key 无效、156 账户未实名认证",
                      "example": 200,
                      "required": true
                    },
                    "msg": {
                      "type": "string",
                      "description": "状态消息",
                      "required": true
                    },
                    "data": {
                      "type": "object",
                      "required": true,
                      "properties": {
                        "list": {
                          "type": "array",
                          "required": true,
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "integer",
                                "description": "套餐编号"
                              },
                              "created_at": {
                                "type": "string",
                                "description": "套餐生效时间",
                                "example": "2022-05-13 12:14:15"
                              },
                              "expired_at": {
                                "type": "string",
                                "description": "套餐过期时间,过期后流量无法使用。",
                                "example": "2022-05-13 12:14:15"
                              },
                              "product_type": {
                                "type": "integer",
                                "description": "套餐类型，9 动态住宅、16静态住宅"
                              },
                              "trade_no": {
                                "type": "string",
                                "description": "订单交易号",
                                "example": "2022051312134339861461465434"
                              },
                              "order": {
                                "type": "object",
                                "properties": {
                                  "created_at": {
                                    "type": "string",
                                    "description": "订单创建时间",
                                    "example": "2022-05-13 12:13:43"
                                  },
                                  "pay_at": {
                                    "type": "string",
                                    "description": "订单支付时间",
                                    "example": "2022-05-13 12:13:43"
                                  },
                                  "title": {
                                    "type": "string",
                                    "description": "订单描述",
                                    "example": "入门级"
                                  }
                                }
                              }
                            }
                          }
                        },
                        "page": {
                          "type": "integer",
                          "description": "当前分页",
                          "required": true,
                          "default": 1
                        },
                        "page_size": {
                          "type": "integer",
                          "description": "分页大小",
                          "default": 20
                        },
                        "total_count": {
                          "type": "integer",
                          "description": "总记录数量"
                        },
                        "total_page": {
                          "type": "integer",
                          "description": "总分页数量"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
