You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

关于GetCandy API搜索端点多sort参数请求的技术咨询

GetCandy API Multi-Sorting: Answers to Your Questions

Hey there! Let's break down your questions about implementing multi-sorting for your search page using the GetCandy API:

1. Does the API support multi-sorting based on the returned array?

The single-item array [{ name: 'desc' }] you're seeing doesn't mean multi-sorting is off the table. That's probably just the default or available sorting option for your current context, not a hard limit on the API's capabilities. Most e-commerce APIs (including GetCandy) are built to support multi-level sorting, so we can move forward with standard pattern tests.

2. How to format multi-sort parameters in your request?

Since single sorting uses the format { sort: 'name-desc' } (field name + hyphen + direction), multi-sort is typically handled by comma-separating multiple sort rules in the same sort string. Here's how to structure it:

// Example: Sort by name descending first, then price ascending for ties
{ sort: 'name-desc,price-asc' }

Each segment follows the same [field]-[direction] pattern, and the order matters—results will sort by the first rule first, then fall back to the second rule for items that match on the first field.

3. Can you send multiple parameters under the sort key?

It depends on the API's expected format, but given your single-sort example uses a string value for sort, the comma-separated string is the safest first approach. Some APIs do accept an array of sort strings, like:

{ sort: ['name-desc', 'price-asc'] }

But since GetCandy uses a string for single sorting, start with the comma-separated format. If that doesn't behave as expected, you can test the array format or check the official GetCandy docs to confirm support.

Pro tip: Test with a small dataset first to verify the sorting works as intended—this will help you confirm the API is parsing your multi-sort parameter correctly.

内容的提问来源于stack exchange,提问作者Jamie Warburton

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 09:10:46