Implement API Pagination System
Generate complete API pagination code with offset, cursor, or page-based approaches. Includes error handling and best practices.
Prompt Template
Variables to Customize
[PROGRAMMING_LANGUAGE] The programming language and framework to use
Example: Node.js with Express
[DATABASE_TYPE] The database system being used
Example: PostgreSQL
[RESOURCE_TYPE] The type of data being paginated
Example: user profiles
[PAGINATION_METHOD] The pagination approach to implement
Example: offset-based
[DEFAULT_PAGE_SIZE] Default number of items per page
Example: 20
[MAX_PAGE_SIZE] Maximum allowed items per page
Example: 100
[SORTING_FIELDS] Fields that can be used for sorting
Example: created_at, name, email
Example Output
Pro Tips for Best Results
- Always validate and sanitize pagination parameters to prevent SQL injection and invalid queries
- Include total count in responses but consider caching it for large datasets to improve performance
- Set reasonable default and maximum page sizes to prevent resource exhaustion
- Use database indexes on frequently sorted columns to optimize pagination queries
- Consider cursor-based pagination for real-time data or very large datasets where offset becomes inefficient
Tags
Want 500+ Expert Prompts?
Get the Premium Prompt Pack — organized, tested, and ready to use.
Get it for $29Related Prompts You Might Like
Optimize Database Query Performance
You are a senior database performance engineer with expertise in query optimization. I need you to analyze and optimize ...
Configure Production Load Balancer Architecture
You are a senior DevOps engineer specializing in high-availability infrastructure. I need to set up a production-grade l...
Write Comprehensive Technical Specifications
You are a senior technical architect tasked with creating comprehensive technical specifications. Write a detailed techn...
Create Comprehensive Database Backup Strategy
You are a senior database administrator with expertise in enterprise backup strategies and disaster recovery planning. C...
Implement Data Serialization for APIs
You are an expert backend developer specializing in data serialization for APIs. I need you to implement a complete data...
Implement Search Functionality
I need to implement search functionality for my [APPLICATION_TYPE] application. Here are the key requirements: **Techni...