Skip to main content

Request Examples

This page provides practical examples of how to use the ReviewData Lite API endpoints in different programming languages. These examples use the same default values as the interactive playground for consistency.

Base URL

All API requests are made to: https://data.reviewdata.ai

Request Reviews Examples

const axios = require('axios');

const requestReviews = async () => {
try {
const response = await axios.post('https://data.reviewdata.ai/submit/request-reviews/', {
job: 'App\\Jobs\\RequestReviews',
data: {
lazy: true,
api_key: 'YOUR_API_KEY_HERE', // Replace with your API key
business: {
id: 'restaurant_001',
name: 'McDonald\'s',
tags: [
'restaurant',
'pizza',
'italian',
'casual'
],
phone: '+12123852066',
address: {
zip: '10038',
city: 'New York',
state: 'NY',
street: '160 Broadway',
country: 'USA'
},
description: 'Classic, long-running fast-food chain known for its burgers & fries.'
},
publishers: {
'maps.google.com': {
profile_key: 'https://www.google.com/maps/place/McDonald\'s/@40.7094789,-74.0126167,886m/data=!3m2!1e3!5s0x89c2592f4977ef97:0xf78d57398ac93494!4m7!3m6!1s0x89c25a177d4bf5db:0x84e51f23e8c0a75c!8m2!3d40.7094789!4d-74.0100364!10e1!16s%2Fg%2F1thtf190!5m1!1e1?entry=ttu&g_ep=EgoyMDI1MDYyMi4wIKXMDSoASAFQAw%3D%3D',
first_page_only: false,
last_review_hashes: []
}
},
foreign_key: `TEST_${Date.now()}_${Math.random().toString(36).substring(2, 8)}` // Generate unique key
}
}, {
headers: {
'Content-Type': 'application/json'
}
});

console.log('Request submitted successfully:');
console.log('Status:', response.data.status);
console.log('Task ID:', response.data.task_id || response.data.tasks_id);
console.log('Request ID:', response.data.request_id);
console.log('Foreign Key:', response.data.foreign_key);
console.log('Publisher:', response.data.publisher_key);

return response.data;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
throw error;
}
};

// Usage
requestReviews();

Retrieve Task Examples

const axios = require('axios');

const retrieveTask = async (taskId, foreignKey, publisherKey, apiKey, page = 1, pageSize = 10) => {
try {
const response = await axios.post('https://data.reviewdata.ai/retrieve-task/', {
api_key: apiKey,
task_id: taskId,
foreign_key: foreignKey,
publisher_key: publisherKey,
page: page,
page_size: pageSize
}, {
headers: {
'Content-Type': 'application/json'
}
});

console.log('Task retrieved successfully:');
console.log('Task Status:', response.data.task_status);
console.log('Foreign Key:', response.data.foreign_key);
console.log('Publisher:', response.data.business?.publisher);

if (response.data.reviews) {
console.log('Reviews Count:', response.data.reviews.length);
console.log('Pagination:', response.data.pagination);
}

return response.data;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
throw error;
}
};

// Usage with sample data from playground
retrieveTask(
'900e2ff4-2d25-4576-ab18-b9b8e73c0bd6',
'TEST_1751004113518_i6yxcl',
'maps.google.com',
'YOUR_API_KEY_HERE'
);

Configure Webhook Examples

const axios = require('axios');

const configureWebhook = async (apiKey, webhookUrl) => {
try {
const response = await axios.post('https://data.reviewdata.ai/webhooks/create-webhook/', {
api_key: apiKey,
webhook: webhookUrl
}, {
headers: {
'Content-Type': 'application/json'
}
});

console.log('Webhook configured successfully:');
console.log('Status:', response.data.status);
console.log('Webhook URL:', response.data.webhook);

return response.data;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
throw error;
}
};

// Usage
configureWebhook('YOUR_API_KEY_HERE', 'https://example.com/webhook');

Alternative Publisher Examples

TripAdvisor Sample Request

const axios = require('axios');

const requestTripAdvisorReviews = async () => {
try {
const response = await axios.post('https://data.reviewdata.ai/submit/request-reviews/', {
job: 'App\\Jobs\\RequestReviews',
data: {
lazy: true,
api_key: 'YOUR_API_KEY_HERE',
business: {
id: 'restaurant_001',
name: 'McDonald\'s',
tags: ['restaurant', 'fast-food'],
phone: '+12123852066',
address: {
zip: '10038',
city: 'New York',
state: 'NY',
street: '160 Broadway',
country: 'USA'
},
description: 'Fast food restaurant'
},
publishers: {
'tripadvisor.com': {
profile_key: 'https://www.tripadvisor.com/Restaurant_Review-g60763-d123456-Reviews-McDonalds-New_York_City_New_York.html',
first_page_only: false,
last_review_hashes: []
}
},
foreign_key: `TEST_${Date.now()}_${Math.random().toString(36).substring(2, 8)}`
}
}, {
headers: {
'Content-Type': 'application/json'
}
});

console.log('TripAdvisor request submitted:', response.data);
return response.data;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
throw error;
}
};

// Usage
requestTripAdvisorReviews();

Yelp Sample Request

const axios = require('axios');

const requestYelpReviews = async () => {
try {
const response = await axios.post('https://data.reviewdata.ai/submit/request-reviews/', {
job: 'App\\Jobs\\RequestReviews',
data: {
lazy: true,
api_key: 'YOUR_API_KEY_HERE',
business: {
id: 'restaurant_001',
name: 'McDonald\'s',
tags: ['restaurant', 'fast-food'],
phone: '+12123852066',
address: {
zip: '10038',
city: 'New York',
state: 'NY',
street: '160 Broadway',
country: 'USA'
},
description: 'Fast food restaurant'
},
publishers: {
'yelp.com': {
profile_key: 'https://www.yelp.com/biz/mcdonalds-new-york-123',
first_page_only: false,
last_review_hashes: []
}
},
foreign_key: `TEST_${Date.now()}_${Math.random().toString(36).substring(2, 8)}`
}
}, {
headers: {
'Content-Type': 'application/json'
}
});

console.log('Yelp request submitted:', response.data);
return response.data;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
throw error;
}
};

// Usage
requestYelpReviews();

Tips for Using the Examples

1. Replace API Key

Replace the sample API key YOUR_API_KEY_HERE with your actual API key from https://www.shoutaboutus.com/request-api-key.

2. Test with Playground First

Before using these examples in production, test your requests with the interactive playground to ensure they work correctly.

3. Handle Errors Gracefully

All examples include error handling. Make sure to implement proper error handling in your production code.

4. Use Unique Foreign Keys

The examples generate unique foreign keys to avoid conflicts. In production, use your own unique identifier system.

5. Monitor Task Status

After submitting a request, use the retrieve task endpoint to check the status and get the results when complete.

6. Implement Webhooks

For production use, implement webhooks to receive real-time notifications when tasks are completed.

Common Use Cases

1. Submit Request and Wait for Completion

const submitAndWait = async () => {
// Submit request
const submitResponse = await requestReviews();
const taskId = submitResponse.task_id || submitResponse.tasks_id;
const foreignKey = submitResponse.foreign_key;

// Poll for completion
let completed = false;
while (!completed) {
await new Promise(resolve => setTimeout(resolve, 30000)); // Wait 30 seconds

const taskData = await retrieveTask(taskId, foreignKey, 'maps.google.com', 'YOUR_API_KEY_HERE');

if (taskData.task_status === 200) {
completed = true;
console.log('Task completed with', taskData.reviews.length, 'reviews');
} else if (taskData.task_status >= 400) {
throw new Error('Task failed');
}
}
};

2. Bulk Business Processing

const businesses = [
{ name: 'Business 1', profileKey: 'https://...' },
{ name: 'Business 2', profileKey: 'https://...' }
];

const processBulk = async () => {
const tasks = [];

for (const business of businesses) {
const response = await requestReviews(); // Modify with business data
tasks.push(response);
}

// Process all tasks
for (const task of tasks) {
// Retrieve and process each task
}
};

Need Help?

If you need assistance with these examples:

  1. Test in Playground: Use the interactive playground to test requests
  2. Check Documentation: Review the API documentation for details
  3. Contact Support: Email techsupport@shoutaboutus.com for help