
Product
Socket Now Supports pylock.toml Files
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
This is a proof of concept for a TypeScript wrapper for the Reddit API.
Example bootstrap code:
require('dotenv').config()
import { TSRAW } from "./TSRAW.js"
import { SubmitArgs } from "./types.js"
const { REDDIT_USER_AGENT, REDDIT_CLIENT_ID, REDDIT_CLIENT_SECRET, REDDIT_USERNAME, REDDIT_PASSWORD } = process.env
const CREDENTIALS = {
user_agent: REDDIT_USER_AGENT!,
client_id: REDDIT_CLIENT_ID!,
client_secret: REDDIT_CLIENT_SECRET!,
username: REDDIT_USERNAME!,
password: REDDIT_PASSWORD!,
}
export class RedditBot {
private r: TSRAW
constructor(r: TSRAW) {
this.r = r
}
async start() {
const thread = await this.createThread('test', dailyThread())
}
async createThread(subreddit: string, content: ThreadContent) {
const submission: SubmitArgs = {
sr: subreddit,
title: content.title,
text: content.body,
kind: 'self',
sendreplies: false
}
return this.r.submit(submission)
}
}
interface ThreadContent { title: string, body: string }
const dailyThread = (): ThreadContent => {
const title =
`Daily Discussion Thread (${new Date().toISOString().split('T')[0]})`
const body =
`Talk about anything your heart desires. Be polite and upvote everything!\n\n`+
`How has your day been?`
return { title, body }
}
const main = async () => {
try {
const r = await TSRAW.init(CREDENTIALS)
const bot = new RedditBot(r)
await bot.start()
} catch (cause) {
console.error(new Date().toISOString(), cause)
process.exit(1312)
}
}
main()
Interaces, see src/types.d.ts for more details
constructor(token: string)
static init(credentials: TSRAWCredentials): Promise<TSRAW>
private rq<T extends RedditRes>(request: AxiosRequestConfig, raw?: boolean): Promise<T>
submit (submission: SubmitArgs): Promise<SubmitResp>
edit (post: EditArgs): Promise<SubmitResp>
sticky (id: string): Promise<RedditRes> // Returns 500 (https://redd.it/1h41n06)
getSettings (subreddit: string): Promise<SettingsResp>
getMe (): Promise<AboutResp>
updateSidebar (subreddit: string, description: string): Promise<RedditRes>
threads (params: ThreadsReq): Promise<Thread[]>
comments (params: CommentsReq): Promise<Comment[]>
FAQs
TypeScript Reddit API Wrapper
The npm package tsraw receives a total of 227 weekly downloads. As such, tsraw popularity was classified as not popular.
We found that tsraw demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
Security News
Research
Socket uncovered two npm packages that register hidden HTTP endpoints to delete all files on command.
Research
Security News
Malicious Ruby gems typosquat Fastlane plugins to steal Telegram bot tokens, messages, and files, exploiting demand after Vietnam’s Telegram ban.