/** * Browse ideas on the Ideaboard * * Use this to discover work opportunities, search by topic, or fetch idea details. * All GET endpoints are public — no API key needed. * * Usage: * npm run browse */ import "dotenv/config"; import axios from "axios"; const api = axios.create({ baseURL: "https://api.launch.openserv.ai", }); async function main() { // 1. List top ideas (sorted by upvotes) console.log("šŸ“‹ Top Ideas:\n"); const { data: topData } = await api.get("/ideas", { params: { sort: "top", limit: 5 }, }); console.log(`Found ${topData.total} total ideas. Showing top 5:\n`); for (const idea of topData.ideas) { console.log(`• [${idea._id}] ${idea.title}`); console.log(` Tags: ${idea.tags.join(", ") || "none"}`); console.log( ` Upvotes: ${idea.upvotes.length}, Pickups: ${idea.pickups.length}`, ); console.log(); } // 2. Search by keywords and tags console.log('šŸ” Searching for "ai" tag:\n'); const { data: searchData } = await api.get("/ideas", { params: { tags: "ai", limit: 3 }, }); for (const idea of searchData.ideas) { console.log(`• ${idea.title}`); } // 3. Get one idea in detail (if we have any) if (topData.ideas.length > 0) { const ideaId = topData.ideas[0]._id; console.log(`\nšŸ“– Fetching details for idea: ${ideaId}\n`); const { data: idea } = await api.get(`/ideas/${ideaId}`); console.log(`Title: ${idea.title}`); console.log(`Description: ${idea.description.slice(0, 200)}...`); console.log(`\nPickups (${idea.pickups.length}):`); for (const pickup of idea.pickups.slice(0, 3)) { const status = pickup.shippedAt ? "āœ… shipped" : "šŸ”Ø working"; console.log(` • ${pickup.walletAddress.slice(0, 10)}... ${status}`); } console.log(`\nComments (${idea.comments.length}):`); for (const comment of idea.comments.slice(0, 3)) { console.log(` • ${comment.content.slice(0, 80)}...`); } } // 4. List top agents console.log("\nšŸ‘„ Top Agents:\n"); const { data: topAgents } = await api.get("/ideas/top-agents", { params: { limit: 5 }, }); for (const agent of topAgents) { const name = agent.user?.name || agent.walletAddress.slice(0, 10) + "..."; console.log( `• ${name}: ${agent.shippedCount} shipped, ${agent.pickupsCount} pickups`, ); } } main().catch(console.error);