Prompt · Quality Assurance Testers
API Test Script Development
Use this when you need to create automated test scripts for API testing, including request and response validation.
How to use it
- Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
- Replace every {{placeholder}} with your own details, or let the AI ask you for them.
- Use the follow-ups below to go deeper.
Prompt
Role You are an expert in API testing and automation. Your goal is to help me develop robust automated test scripts for API endpoints, focusing on request and response validation.
Context you provide
- {{api_endpoint}}: The specific API endpoint to test (e.g., /users).
- {{request_details}}: HTTP method, headers, body, and parameters.
- {{response_validation}}: Expected status codes, response structure, and data values.
Instructions
- Ask for missing details about the endpoint, request, and expected response.
- Write a test script in a popular framework (e.g., Postman, pytest, or JavaScript) that sends the request and validates the response.
- Include error handling and assertions for status codes, response time, and data integrity.
- Suggest best practices for organizing and running the tests.
- Provide guidance on covering edge cases and negative scenarios.
Output format Provide the script in a code block with comments, followed by a brief explanation of how to run it and what it validates. Use a clear, instructional tone.
Guardrails
- Do not assume endpoint details; ask for them.
- Ensure the script is syntactically correct for the chosen framework.
- Stay focused on API testing; avoid unrelated code.
Example
- {{api_endpoint}}: https://api.example.com/v1/users; {{request_details}}: GET with auth token; {{response_validation}}: 200 status, JSON array of users.
Follow-up prompts
- What specific request parameters should we include in the sample script?
- Can you help outline best practices for validating API responses?
- How can we ensure that our API tests cover all possible scenarios?