Daily Reddit API
@raymondcamden
code:
data:privatelast updated:4 years ago
today
Build integrations remarkably fast!
You're viewing a public workflow template.
Sign up to customize, add steps, modify code and more.
Join 1,000,000+ developers using the Pipedream platform
steps.
trigger
HTTP API
Deploy to generate unique URL
This workflow runs on Pipedream's servers and is triggered by HTTP / Webhook requests.
steps.
get_new
This endpoint is a listing.
auth
(auths.reddit)
params
Subreddit
 
string ·params.subreddit
Optional
code
async (params, auths) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
}
19
const config = {
  url: `https://oauth.reddit.com/r/${params.subreddit}/new`,
  params: {
    after: params.after,
    before: params.before,
    count: params.count,
    include_categories: params.include_categories,
    limit: params.limit,
    show: params.show,
    sr_detail: params.sr_detail,
  },
  headers: {
    Authorization: `Bearer ${auths.reddit.oauth_access_token}`,
    "User-Agent": "pipedream:v0.0.1 (by /r/pipedream)",
  },
}
return await require("@pipedreamhq/platform").axios(this, config)
steps.
filter_to_today
auth
to use OAuth tokens and API keys in code via theauths object
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
}
20
/*
Date.now is ms, for reddit posts, created_utc is seconds, so convert our value to seconds
*/
const now = Date.now()/1000;
// and 24 hours in seconds then is 24 * 60 * 60
const maxtime = 24 * 60 * 60;
let result = steps.get_new.$return_value.data.children.filter(p => {
  let diff = now - p.data.created_utc;
  return diff < maxtime;
}).map(p => {
  return p.data;
});

$respond({
  status: 200,
  body: { result }, // This can be any string, object, or Buffer
});