Skip to main content
Glama
test-direct-unblended.cjs4.07 kB
const axios = require('axios'); async function testDirectUnblended() { const BASE_URL = 'https://api.dev.umbrellacost.dev/api'; const USERNAME = 'elisha+testmcpdev@anodot.com'; const PASSWORD = 'Test123!'; const ACCOUNT_KEY = '111111639'; const DIVISION_ID = '0'; try { console.log('🔐 Authenticating...\n'); const authResponse = await axios.post(`${BASE_URL}/v1/users/signin`, { username: USERNAME, password: PASSWORD }); const token = authResponse.data.jwtToken; const tokenPayload = JSON.parse(Buffer.from(token.split('.')[1], 'base64').toString()); const userKey = tokenPayload.sub; console.log('✅ Authenticated'); console.log(`User Key: ${userKey}\n`); const startDate = '2025-01-01'; const endDate = '2025-10-08'; const apiKey = `${userKey}:${ACCOUNT_KEY}:${DIVISION_ID}`; // Test with isUnblended=true console.log('═'.repeat(80)); console.log('TEST: Direct API call with isUnblended=true'); console.log('═'.repeat(80)); const params = { startDate, endDate, isUnblended: true, costType: ['cost', 'discount'], periodGranLevel: 'month', groupBy: 'none' }; console.log('Request params:', JSON.stringify(params, null, 2)); console.log('API Key:', apiKey); console.log(''); try { const response = await axios.get(`${BASE_URL}/v2/invoices/cost-and-usage`, { params: params, headers: { 'Authorization': token, 'apikey': apiKey } }); console.log('✅ Response received'); console.log('Status:', response.status); console.log(''); if (response.data.data) { console.log(`Number of records: ${response.data.data.length}`); if (response.data.data.length > 0) { const totalCost = response.data.data.reduce((sum, item) => sum + (item.total_cost || 0), 0); console.log(`Total Cost: $${totalCost.toFixed(2)}`); console.log(''); console.log('Breakdown by month:'); response.data.data.forEach(item => { console.log(` ${item.usage_date}: $${item.total_cost.toFixed(2)}`); }); } else { console.log('⚠️ WARNING: Data array is EMPTY!'); } } else { console.log('⚠️ WARNING: No data.data in response'); console.log('Response structure:', JSON.stringify(response.data, null, 2).substring(0, 500)); } } catch (error) { console.log('❌ Error calling API:', error.message); if (error.response) { console.log('Status:', error.response.status); console.log('Error data:', JSON.stringify(error.response.data, null, 2)); } } // Now test without isUnblended to see default behavior console.log('\n' + '═'.repeat(80)); console.log('TEST: Direct API call WITHOUT isUnblended (default behavior)'); console.log('═'.repeat(80)); const params2 = { startDate, endDate, costType: ['cost', 'discount'], periodGranLevel: 'month', groupBy: 'none' }; console.log('Request params:', JSON.stringify(params2, null, 2)); console.log(''); try { const response = await axios.get(`${BASE_URL}/v2/invoices/cost-and-usage`, { params: params2, headers: { 'Authorization': token, 'apikey': apiKey } }); if (response.data.data && response.data.data.length > 0) { const totalCost = response.data.data.reduce((sum, item) => sum + (item.total_cost || 0), 0); console.log(`Total Cost: $${totalCost.toFixed(2)}`); console.log(`Number of records: ${response.data.data.length}`); } } catch (error) { console.log('❌ Error:', error.message); } } catch (error) { console.error('❌ Error:', error.message); if (error.response) { console.error('Status:', error.response.status); console.error('Data:', JSON.stringify(error.response.data, null, 2)); } } } testDirectUnblended();

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/daviddraiumbrella/invoice-monitoring'

If you have feedback or need assistance with the MCP directory API, please join our Discord server