Access and retrieve extracted data using the Kadoa SDK
const result = await client.extraction.run({ urls: ['https://sandbox.kadoa.com/ecommerce'], name: 'Product Extraction' }); // Get the extracted data const response = await result.fetchData({}); console.log(response.data); // Array of extracted items
// Fetch specific page const pageResponse = await result.fetchData({ page: 1, limit: 50 }); console.log(`Total items: ${pageResponse.pagination.total}`); console.log(`Page ${pageResponse.pagination.page} of ${pageResponse.pagination.totalPages}`);
// Option 1: Iterate page by page for await (const page of result.fetchDataPages()) { console.log('Page data:', page.data); console.log('Page number:', page.pagination.page); } // Option 2: Get everything at once const allData = await result.fetchAllData(); console.log('All data:', allData);
const client = new KadoaClient({ apiKey: 'your-api-key', enableRealtime: true }); // Listen to all events client.realtime?.onEvent((event) => { console.log('Event:', event); // Handle: EXTRACTION_STARTED, EXTRACTION_COMPLETED, DATA_CHANGED, etc. }); // Check connection if (client.isRealtimeConnected()) { console.log('Connected to real-time updates'); }
{ data: [ { // Your extracted fields title: "Product Name", price: "$99.99", inStock: true } ], pagination: { page: 1, limit: 50, total: 150, totalPages: 3 } }