Skip to main content

Overview

Load testing a REST API is streamlined and intuitive with LoadForge. The examples below demonstrate testing capabilities using a sample REST API. LoadForge provides the flexibility to define custom headers as required, and the ability to send requests based on the data returned from your API.
Ensure you disable API rate limits associated with your token to prevent an influx of failure responses during testing.
Below are two illustrative examples:
  1. Basic API Example: This showcases a straightforward set of GET requests to an API, accompanied by bearer authentication using a custom header.
  2. Advanced API Example: A more intricate example involving both POST and GET requests and dynamic responses based on returned data.

Basic API Example

The following Python script demonstrates how to conduct simple GET requests to your API with bearer token authentication:

Advanced API Example

This test provides insights into load testing the LoadForge REST API. The script below contains comprehensive comments to elucidate each step: The test script comprises four main segments:
  1. Fetch random hosts and tests.
  2. During initialization, retrieve all results, save the result IDs, and establish the bearer token.
  3. Acquire a random result from the previously fetched list.
  4. Create a new host through the API and subsequently delete it to maintain a clean slate.
This exemplifies the convenience of load testing, be it for a Laravel API or any RESTful API. The capacity to retrieve all results and then fetch random result IDs is particularly beneficial, given the inherent ability to parse responses within the test.
LoadForge is built upon the robust foundation of locust, allowing open-source locust users to readily utilize this script. If you’re already a locust aficionado, think about importing your script to LoadForge and elevate your testing endeavors!