Send Reddit Search Results to Google Sheets
Use a manually run Apps Script to fetch up to five matching public Reddit posts and append rows to Google Sheets. The script makes one price-capped request per run.
Documentation reviewed: 2026-11-14 · By PostToData
Set up a private test spreadsheet
Create a tab named Social evidence. Add headers fetched_at, id, url, text and request_id. Paste the code into the sheet’s bound Apps Script project. Run savePostToDataKey and enter your key in the sheet prompt. It stores your key in User Properties. Keep the sheet and its script private while testing.
Check the price before running the code
The snippet sets max_price_usd to the documented price. Run the free quote below, confirm the current price, then run appendRedditSample manually. The script stops on an HTTP error, keeps identifiers as text and escapes spreadsheet formula prefixes. Each new execution can cost one request.
Keep the query and collection time in your review
Record your search phrase in the workbook or use a separate sheet per query. Repeated runs may return the same post. Use id to group repeated observations while preserving their timestamps, and leave private or removed sources out of shareable reports.
Google Apps Script
function savePostToDataKey() {
const ui = SpreadsheetApp.getUi();
const input = ui.prompt('PostToData API key', 'Set it in this private spreadsheet.', ui.ButtonSet.OK_CANCEL);
if (input.getSelectedButton() !== ui.Button.OK) return;
const key = input.getResponseText().trim();
if (key) PropertiesService.getUserProperties().setProperty('POSTTODATA_API_KEY', key);
}
function appendRedditSample() {
const key = PropertiesService.getUserProperties().getProperty('POSTTODATA_API_KEY');
if (!key) throw new Error('Add your PostToData key to User Properties first.');
const sheet = SpreadsheetApp.getActive().getSheetByName('Social evidence');
if (!sheet) throw new Error('Create the Social evidence sheet first.');
const url = 'https://posttodata.com/v1/reddit/search' +
'?query=' + encodeURIComponent('pour over coffee') +
'&limit=5&format=standard&max_price_usd=0.003';
const response = UrlFetchApp.fetch(url, {
headers: {Authorization: 'Bearer ' + key},
followRedirects: false,
muteHttpExceptions: true,
});
const status = response.getResponseCode();
const body = JSON.parse(response.getContentText());
if (status !== 200) throw new Error('HTTP ' + status + ' · ' + (body.meta?.request_id ?? ''));
const safeCell = value => {
const text = String(value ?? '');
return /^[\s\u0000-\u001f]*[=+@-]/.test(text) ? "'" + text : text;
};
const rows = body.data.items.map(item => [
body.meta.fetched_at, item.id, item.url, item.title || item.text, body.meta.request_id,
].map(safeCell));
if (!rows.length) return;
sheet.getRange(sheet.getLastRow() + 1, 1, rows.length, 5)
.setNumberFormat('@').setValues(rows);
}Example sources and documentation
Current prices & implemented operations
| Operation | Per successful call | 1,000 successful calls |
|---|---|---|
| Reddit · Search posts | $0.003 | $3.00 |
The 1,000-call figure is list price multiplied by calls, not 1,000 records or a top-up package. The example only previews the first operation: no upstream fetch or charge. To retrieve data, remove dry_run=1 and supply Authorization: Bearer API_KEY. Keep max_price_usd to reject a price above the approved amount.
curl --get "https://posttodata.com/v1/reddit/search" \
--data-urlencode 'query=pour over coffee' \
--data-urlencode 'limit=5' \
--data-urlencode 'format=standard' \
--data-urlencode 'max_price_usd=0.003' \
--data-urlencode 'dry_run=1'A per-call ceiling is not a shared budget for the whole task. Bound the number of approved calls and stop on 402, 412 or 429; do not automatically raise limits or rotate accounts.
Frequently asked questions
Does Sheets refresh the results when the spreadsheet opens?
The provided function runs only when you execute it. It creates no triggers or custom spreadsheet formula.
Related guides
- Twitter/X API Alternative for AI Agents & Developers
- Connect Bluesky Search to n8n with One HTTP Request
- Paginate Reddit Keyword Search with a Fixed API Budget
- Find WeChat Official Account Articles by Topic