Installations
npm install pr0gramm-api
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>=18.15.0
Node Version
20.5.0
NPM Version
9.8.0
Score
66.3
Supply Chain
98.5
Quality
75.9
Maintenance
100
Vulnerability
80.6
License
Releases
Contributors
Languages
TypeScript (100%)
Developer
Download Statistics
Total Downloads
11,589
Last Day
5
Last Week
14
Last Month
138
Last Year
1,348
GitHub Statistics
20 Stars
294 Commits
2 Forks
3 Watching
2 Branches
3 Contributors
Bundle Size
318.60 kB
Minified
169.00 kB
Minified + Gzipped
Package Meta Information
Latest Version
4.2.1
Package Id
pr0gramm-api@4.2.1
Unpacked Size
84.85 kB
Size
23.82 kB
File Count
25
NPM Version
9.8.0
Node Version
20.5.0
Publised On
22 Jul 2023
Total Downloads
Cumulative downloads
Total Downloads
11,589
Last day
150%
5
Compared to previous day
Last week
-69.6%
14
Compared to previous week
Last month
58.6%
138
Compared to previous month
Last year
-39.2%
1,348
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
Dev Dependencies
3
pr0gramm-api
A Node.js API for pr0gramm written in TypeScript.
1npm install -S pr0gramm-api
Usage
Login with username/password:
1import { Pr0grammAPI, NodeRequester, ItemFlags } from "pr0gramm-api"; 2 3main(); 4async function main() { 5 const requester = NodeRequester.create(); 6 // When using this library in the browser, use this requester: 7 // const requester = BrowserRequester.create(); 8 9 const api = Pr0grammAPI.create(requester); 10 11 const mainItems = await api.items.getItems({ 12 promoted: true, 13 flags: ItemFlags.SFW 14 }); 15 16 console.log(mainItems.items); 17 18 const captchaData = await api.user.requestCaptcha(); 19 // captchaData.captcha contains the image as a data URI 20 21 const loginResponse = await api.user.login("cha0s", "stahl0fen80", captchaData.token, "aaaaa"); 22 if(!loginResponse.success) { 23 console.log("Could not log in :("); 24 if(loginResponse.ban !== null) { 25 console.log("You are banned. Reason:"); 26 console.log(loginResponse.ban.reason); 27 return; 28 } 29 } 30}
Login with oAuth:
1import * as readline from "node:readline/promises";
2import { AuthorizationCode } from "simple-oauth2";
3import { Pr0grammAPI, NodeRequester, ItemFlags } from "pr0gramm-api";
4
5const oAuthAccessCodeClient = new AuthorizationCode({
6 client: {
7 // See above
8 id: "<client_id>",
9 secret: "<client_secret>",
10 },
11 auth: {
12 tokenHost: "https://pr0gramm.com/",
13 tokenPath: "/api/oauth/createAccessToken",
14 authorizePath: "/oauth/authorize",
15 }
16});
17
18main();
19async function main() {
20 const authorizationUri = oAuthAccessCodeClient.authorizeURL({
21 redirect_uri: authCallbackUrl,
22 scope: "items.get",
23 state: "<state>",
24 });
25
26 console.log("Go to this URL and enter the auth code from ?code=<auth code> from the callback URL:");
27 console.log(authorizationUri);
28
29 const rl = readline.createInterface({
30 input: process.stdin,
31 output: process.stdin,
32 });
33 const authCode = await rl.question("Auth-Code: ");
34 rl.close();
35
36 const tokenHandler = await oAuthAccessCodeClient.getToken({
37 code: authCode,
38 });
39
40 const requester = NodeRequester.create();
41 requester.setOAuthAccessToken(tokenHandler.token.access_token);
42
43 const api = Pr0grammAPI.create(requester);
44
45 const mainItems = await api.items.getItems({
46 promoted: true,
47 flags: ItemFlags.All
48 });
49
50 console.log(mainItems.items);
51}
Stream Walker
The item stream requires you to call the next page of elements. Because it is a common operation to just walk over all items in the stream, there is a stream walker api for convenience:
1import { Pr0grammAPI, NodeRequester, ItemFlags } from "pr0gramm-api"; 2 3main(); 4async function main() { 5 const api = Pr0grammAPI.create(NodeRequester.create()); 6 7 // Create a walker that iterates through the entire stream of elements 8 // starting at item 0, going upwards 9 const itemStream = api.items.walkStreamNewer({ 10 newer: 0, 11 flags: ItemFlags.SFW, 12 promoted: false, 13 }); 14 15 // Asynchronous iteration over all items on pr0gramm 16 // automatically requests next items 17 for await (const item of itemStream) { 18 console.log(item.id + ": " + item.user); 19 } 20}
Important:
- This approach uses async generators, which are currently hidden behind node's
--harmony
flag. To use this API, you need to start node with--harmony
. - If you are using TypeScript, you need to have
"esnext.asynciterable"
and"es6"
in yourlib
entry intsconfig.json
. - The module is exposed as CommonJS, not (yet) ES modules. If you use plain JavaScript, keep in mind using CommonJS imports instead of ES imports:
const { Pr0grammAPI, ItemFlags } = require("pr0gramm-api");
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: GNU General Public License v3.0: LICENSE:0
Reason
0 existing vulnerabilities detected
Reason
5 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 4
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/CD.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/holzmaster/node-pr0gramm-api/CD.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/CD.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/holzmaster/node-pr0gramm-api/CD.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/CI.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/holzmaster/node-pr0gramm-api/CI.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/CI.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/holzmaster/node-pr0gramm-api/CI.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/Docs.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/holzmaster/node-pr0gramm-api/Docs.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/Docs.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/holzmaster/node-pr0gramm-api/Docs.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/Docs.yml:39: update your workflow using https://app.stepsecurity.io/secureworkflow/holzmaster/node-pr0gramm-api/Docs.yml/master?enable=pin
- Info: 0 out of 7 GitHub-owned GitHubAction dependencies pinned
- Info: 3 out of 3 npmCommand dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Info: jobLevel 'contents' permission set to 'read': .github/workflows/CD.yml:18
- Warn: no topLevel permission defined: .github/workflows/CD.yml:1
- Warn: no topLevel permission defined: .github/workflows/CI.yml:1
- Warn: no topLevel permission defined: .github/workflows/Docs.yml:1
- Info: no jobLevel write permissions found
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 30 are checked with a SAST tool
Score
4.9
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More