import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = { vus: 50, duration: '3m' };
const BASE_URL = 'https://api.example.com';
export default function () {
// GET request
const list = http.get(`${BASE_URL}/items`);
check(list, { 'list ok': (r) => r.status === 200 });
// POST request with JSON body
const created = http.post(`${BASE_URL}/items`,
JSON.stringify({ name: 'Test Item' }),
{ headers: { 'Content-Type': 'application/json' } }
);
check(created, { 'created': (r) => r.status === 201 });
sleep(1);
}All standard methods — GET, POST, PUT, PATCH, DELETE, HEAD, and OPTIONS. You can also send custom HTTP methods via k6's http.request() function.
Yes. Use JSON.stringify() for the body and set Content-Type to application/json. k6 handles serialization and content negotiation transparently.
k6 automatically manages cookies across requests within a VU iteration. You can also set custom cookies via the headers parameter or use k6's cookie jar API for fine-grained control.
Load test your REST and GraphQL APIs with up to 200 virtual users for free. Real-time metrics, JavaScript scripting, and instant results.
Benchmark your REST API performance with precise p50, p95, p99 latency metrics. Compare endpoints and track regressions over time.
Load test your GraphQL API with realistic queries and mutations. Measure resolver performance and find N+1 query bottlenecks.