Help us improve
Share bugs, ideas, or general feedback.
Builds flexible API filtering and sorting systems with query parameter parsing, operators like gte/lte/in, validation, and security whitelists. For search endpoints, data grids, dynamic query APIs.
npx claudepluginhub secondsky/claude-skills --plugin api-filtering-sortingHow this skill is triggered — by the user, by Claude, or both
Slash command
/api-filtering-sorting:api-filtering-sortingThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Build flexible filtering and sorting systems that handle complex queries efficiently.
Guides designing filter and sort query parameters for list endpoints, covering operator syntax, injection prevention, and sort conventions.
Provides REST API design patterns for resource naming, URL structure, HTTP methods, status codes, pagination, filtering, error responses, versioning, and rate limiting. Use when designing endpoints or reviewing contracts.
Share bugs, ideas, or general feedback.
Build flexible filtering and sorting systems that handle complex queries efficiently.
GET /products?category=electronics&price[gte]=100&price[lte]=500&sort=-price,name
const allowedFilters = ['category', 'status', 'price', 'createdAt'];
const allowedSorts = ['name', 'price', 'createdAt'];
app.get('/products', async (req, res) => {
const filter = {};
const sort = {};
// Parse filters
for (const [key, value] of Object.entries(req.query)) {
if (key === 'sort') continue;
const match = key.match(/^(\w+)\[(\w+)\]$/);
if (match) {
const [, field, operator] = match;
if (!allowedFilters.includes(field)) continue;
filter[field] = { [`$${operator}`]: parseValue(value) };
} else if (allowedFilters.includes(key)) {
filter[key] = value;
}
}
// Parse sort
if (req.query.sort) {
for (const field of req.query.sort.split(',')) {
const direction = field.startsWith('-') ? -1 : 1;
const name = field.replace(/^-/, '');
if (allowedSorts.includes(name)) sort[name] = direction;
}
}
const products = await Product.find(filter).sort(sort);
res.json({ data: products });
});
function parseValue(value) {
if (value === 'true') return true;
if (value === 'false') return false;
if (!isNaN(value)) return Number(value);
return value;
}
| Operator | Meaning | Example |
|---|---|---|
| eq | Equals | ?status=active |
| ne | Not equals | ?status[ne]=deleted |
| gt/gte | Greater than | ?price[gte]=100 |
| lt/lte | Less than | ?price[lte]=500 |
| in | In array | ?status[in]=active,pending |
| like | Contains | ?name[like]=phone |