The Collections API allows you to create and manage curated sets of tools for specific use cases.
GET /api/collections
Retrieve a paginated list of public collections with optional filtering.
limit - Number of results (default: 20, max: 50)offset - Pagination offsetq - Search querycurl "https://tpmjs.com/api/collections?limit=10"{
"success": true,
"data": [
{
"id": "clx123abc",
"uid": "web-scraping-toolkit",
"name": "Web Scraping Toolkit",
"description": "Essential tools for web scraping and data extraction",
"isPublic": true,
"toolCount": 5,
"likeCount": 42,
"owner": {
"id": "user123",
"name": "John Doe",
"username": "johndoe"
}
}
],
"pagination": {
"limit": 10,
"offset": 0,
"hasMore": true
}
}GET /api/collections/:uid
Retrieve detailed information about a specific collection, including its tools.
uid - Collection unique identifier or slugcurl "https://tpmjs.com/api/collections/web-scraping-toolkit"{
"success": true,
"data": {
"id": "clx123abc",
"uid": "web-scraping-toolkit",
"name": "Web Scraping Toolkit",
"description": "Essential tools for web scraping and data extraction",
"isPublic": true,
"toolCount": 5,
"likeCount": 42,
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-01-20T14:45:00Z",
"tools": [
{
"id": "tool123",
"name": "webScraperTool",
"description": "Scrape content from web pages"
}
],
"owner": {
"id": "user123",
"name": "John Doe",
"username": "johndoe"
}
}
}POST /api/collections
Create a new collection. Requires authentication.
{
"name": "My Data Tools",
"uid": "my-data-tools",
"description": "A collection of data processing tools",
"isPublic": true
}const response = await fetch('/api/collections', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY'
},
body: JSON.stringify({
name: 'My Data Tools',
uid: 'my-data-tools',
description: 'A collection of data processing tools',
isPublic: true
})
});
const { data: collection } = await response.json();
console.log('Created collection:', collection.id);PATCH /api/collections/:uid
Update an existing collection. Requires authentication and ownership.
{
"name": "Updated Collection Name",
"description": "Updated description",
"isPublic": false
}curl -X PATCH "https://tpmjs.com/api/collections/my-data-tools" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "Updated Collection Name"}'POST /api/collections/:uid/tools
Add a tool to a collection. Requires authentication and ownership.
{
"toolId": "clx456def"
}const response = await fetch('/api/collections/my-data-tools/tools', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY'
},
body: JSON.stringify({
toolId: 'clx456def'
})
});
if (response.ok) {
console.log('Tool added to collection');
}DELETE /api/collections/:uid/tools/:toolId
Remove a tool from a collection. Requires authentication and ownership.
curl -X DELETE "https://tpmjs.com/api/collections/my-data-tools/tools/clx456def" \
-H "Authorization: Bearer YOUR_API_KEY"{
"success": true,
"message": "Tool removed from collection"
}POST /api/collections/:uid/like
Like or unlike a collection. Requires authentication.
// Like a collection
const response = await fetch('/api/collections/web-scraping-toolkit/like', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
});
const { data } = await response.json();
console.log('Liked:', data.liked); // true if now liked, false if unlikedDELETE /api/collections/:uid
Delete a collection. Requires authentication and ownership. This action cannot be undone.
curl -X DELETE "https://tpmjs.com/api/collections/my-data-tools" \
-H "Authorization: Bearer YOUR_API_KEY"{
"success": true,
"message": "Collection deleted successfully"
}