skills/api-filtering-sorting/SKILL.md
Implement advanced filtering and sorting capabilities for APIs with query parsing, field validation, and optimization. Use when building search features, complex queries, or flexible data retrieval endpoints.
npx skillsauth add aj-geddes/useful-ai-prompts api-filtering-sortingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Build flexible filtering and sorting systems that handle complex queries efficiently with proper validation, security, and performance optimization.
Minimal working example:
// Node.js filtering implementation
app.get("/api/products", async (req, res) => {
const filters = {};
const sortOptions = {};
// Parse filtering parameters
const allowedFilters = [
"category",
"minPrice",
"maxPrice",
"inStock",
"rating",
];
for (const key of allowedFilters) {
if (req.query[key]) {
filters[key] = req.query[key];
}
}
// Build MongoDB query
const mongoQuery = {};
if (filters.category) {
mongoQuery.category = filters.category;
}
// ... (see reference guides for full implementation)
Detailed implementations in the references/ directory:
| Guide | Contents | |---|---| | Query Parameter Filtering | Query Parameter Filtering | | Advanced Filter Parser | Advanced Filter Parser | | Filter Builder Pattern | Filter Builder Pattern | | Python Filtering (SQLAlchemy) | Python Filtering (SQLAlchemy) | | Elasticsearch Filtering | Elasticsearch Filtering | | Query Validation | Query Validation |
development
Implement Zero Trust security model with identity verification, microsegmentation, least privilege access, and continuous monitoring. Use when building secure cloud-native applications.
development
Prevent Cross-Site Scripting (XSS) attacks through input sanitization, output encoding, and Content Security Policy. Use when handling user-generated content in web applications.
tools
Create wireframes and interactive prototypes to visualize user interfaces and gather feedback early. Use tools and techniques to communicate design ideas before development.
development
Implement real-time bidirectional communication with WebSockets including connection management, message routing, and scaling. Use when building real-time features, chat systems, live notifications, or collaborative applications.