---
title: "How to Perform API Load Testing from Command Line Using k6 CLI?"  
description: "How to Perform API Load Testing from Command Line Using k6 CLI?"  
author: "Ravi Vishwakarma"  
published: 2026-08-19  
updated: 2026-08-18  
canonical: https://answers.mindstick.com/qa/117082/how-to-perform-api-load-testing-from-command-line-using-k6-cli  
category: "API Testing"  
tags: ["k6", "Load Testing", "CLI", "API Performance", "DevOps"]  
reading_time: 1 minute  

---

# How to Perform API Load Testing from Command Line Using k6 CLI?

k6 is an open-source load testing tool designed for developer happiness and performance testing in CLI environments. It uses JavaScript to define test scenarios.

## How to write and run an API load test using k6 CLI?

Follow these steps to execute a performance test from the terminal:

### 1. Create a Test Script (script.js)

```
import http from 'k6/http';
import { check, sleep } from 'k6';

export const options = {
    vus: 10,
    duration: '30s',
};

export default function () {
    const res = http.get('https://api.example.com/v1/health');
    check(res, {
        'status is 200': (r) => r.status === 200,
    });
    sleep(1);
}
```

### 2. Execute via Command Prompt

```
k6 run script.js
```

The CLI output displays real-time metrics including HTTP request duration, failure rate, and request volume per second.


---

Original Source: https://answers.mindstick.com/qa/117082/how-to-perform-api-load-testing-from-command-line-using-k6-cli

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
