Getting Started
All examples use real endpoints from the k6 demo applications. You can copy and run them directly:Available Examples
HTTP Authentication
Test APIs with Basic Auth, Bearer tokens, NTLM, and AWS Signature v4
API CRUD Operations
Complete REST API testing with Create, Read, Update, and Delete operations
WebSockets
Real-time WebSocket connection testing with bidirectional messaging
Data Uploads
File upload testing with multipart requests and binary data
Correlation & Dynamic Data
Extract and reuse dynamic tokens, CSRF tokens, and session data
Common Patterns
Basic Test Structure
Most k6 tests follow this pattern:Using Environment Variables
Make tests configurable with environment variables:Test Lifecycle
k6 tests have four distinct phases:- Init context - Load files, import modules, define global variables
- Setup stage - Run once to prepare test data (optional)
- VU stage - Main test logic, runs repeatedly for each VU
- Teardown stage - Clean up after test completes (optional)
Next Steps
Test Types
Learn about smoke, load, stress, and spike testing
Metrics & Checks
Validate responses and track performance metrics