Skip to main content
Fetch a list of publicly available agents from the Swarms Marketplace.
  • Endpoint: POST /v1/marketplace/agents
  • Auth: x-api-key header
  • Request body: {"number_of_items": <int>} (optional, default: 10, max: 100)
import json
import os

from dotenv import load_dotenv
from requests import post

load_dotenv()

API_KEY = os.getenv("SWARMS_API_KEY")

BASE_URL = "https://api.swarms.world"

headers = {
    "x-api-key": API_KEY,
    "Content-Type": "application/json"
}

# Get 10 agents (default)
response = post(
    f"{BASE_URL}/v1/marketplace/agents",
    headers=headers,
    json={}
)

print(f"Status Code: {response.status_code}")
out = response.json()
print(json.dumps(out, indent=4))

# Get 25 agents
response = post(
    f"{BASE_URL}/v1/marketplace/agents",
    headers=headers,
    json={"number_of_items": 25}
)

print(f"Status Code: {response.status_code}")
out = response.json()
print(json.dumps(out, indent=4))
The number_of_items parameter is passed in the JSON request body. If omitted or an empty object is sent, the endpoint returns 10 items by default.