Skip to main content
The k6/http module contains functionality for performing HTTP transactions. This is the primary module for load testing HTTP services.

Import

HTTP Methods

get()

Issues an HTTP GET request.
string | HTTP URL
required
Request URL (e.g. http://example.com).
object
Params object containing additional request parameters like headers, tags, etc.
Response
HTTP Response object.

post()

Issues an HTTP POST request.
string | HTTP URL
required
Request URL (e.g. http://example.com).
string | object | ArrayBuffer
Request body. Objects will be automatically x-www-form-urlencoded.
object
Params object containing additional request parameters.
Response
HTTP Response object.

put()

Issues an HTTP PUT request.
string | HTTP URL
required
Request URL (e.g. http://example.com).
string | object | ArrayBuffer
Request body. Objects will be x-www-form-urlencoded.
object
Params object containing additional request parameters.
Response
HTTP Response object.

del()

Issues an HTTP DELETE request.
string | HTTP URL
required
Request URL (e.g. http://example.com).
string | object | ArrayBuffer
Request body (optional, discouraged). Sending a DELETE request with a body has no defined semantics and may cause some servers to reject it.
object
Params object containing additional request parameters.
Response
HTTP Response object.

request()

Issues any type of HTTP request with a custom method.
string
required
Request method (e.g. 'POST'). Must be uppercase.
string | HTTP URL
required
Request URL (e.g. 'http://example.com').
string | object | ArrayBuffer
Request body. Objects will be x-www-form-urlencoded encoded.
object
Params object containing additional request parameters.
Response
HTTP Response object.

batch()

Issues multiple HTTP requests in parallel (like browsers do).
array | object
required
An array or object containing requests, in string or object form.
object | array
Returns Response objects. It’s an array when you pass an array as requests, and an object with string keys when you use named requests.
To set batch size, use the batchPerHost option in your test configuration.
When using arrays to define requests, use the specific order: [method, url, body, params].