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))
require('dotenv').config();
const API_KEY = process.env.SWARMS_API_KEY;
const BASE_URL = "https://api.swarms.world";
async function listMarketplaceAgents() {
// Get 10 agents (default)
const resp = await fetch(`${BASE_URL}/v1/marketplace/agents`, {
method: 'POST',
headers: {
'x-api-key': API_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify({})
});
console.log('Status:', resp.status);
const data = await resp.json();
console.log(JSON.stringify(data, null, 2));
// Get 30 agents
const resp2 = await fetch(`${BASE_URL}/v1/marketplace/agents`, {
method: 'POST',
headers: {
'x-api-key': API_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify({ number_of_items: 30 })
});
console.log('Status:', resp2.status);
const data2 = await resp2.json();
console.log(JSON.stringify(data2, null, 2));
}
listMarketplaceAgents().catch(console.error);
# Basic request (default 10 items)
curl -X POST "https://api.swarms.world/v1/marketplace/agents" \
-H "x-api-key: $SWARMS_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'
# Get 25 agents
curl -X POST "https://api.swarms.world/v1/marketplace/agents" \
-H "x-api-key: $SWARMS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"number_of_items": 25}'
# Get 100 agents (maximum)
curl -X POST "https://api.swarms.world/v1/marketplace/agents" \
-H "x-api-key: $SWARMS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"number_of_items": 100}'
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.