-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Add Screenshotbase app and Take actions (GET /v1/take) #18663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import screenshotbase from "../../screenshotbase.app.mjs"; | ||
import { axios } from "@pipedream/platform"; | ||
|
||
export default { | ||
key: "screenshotbase-take", | ||
name: "Take Screenshot", | ||
description: "Render a website screenshot or PDF via Screenshotbase.", | ||
version: "0.1.1", | ||
type: "action", | ||
props: { | ||
screenshotbase, | ||
url: { | ||
label: "URL", | ||
type: "string", | ||
description: "Website to render", | ||
optional: false, | ||
}, | ||
width: { | ||
type: "integer", | ||
label: "Width", | ||
optional: true, | ||
default: 1280, | ||
}, | ||
height: { | ||
type: "integer", | ||
label: "Height", | ||
optional: true, | ||
default: 800, | ||
}, | ||
format: { | ||
type: "string", | ||
label: "Format", | ||
description: "png | jpeg | pdf", | ||
optional: true, | ||
options: ["png", "jpeg", "pdf"], | ||
}, | ||
fullPage: { | ||
type: "boolean", | ||
label: "Full Page", | ||
optional: true, | ||
}, | ||
waitForSelector: { | ||
type: "string", | ||
label: "Wait for CSS Selector", | ||
optional: true, | ||
}, | ||
omitBackground: { | ||
type: "boolean", | ||
label: "Transparent Background", | ||
optional: true, | ||
}, | ||
}, | ||
async run({ steps, $ }) { | ||
const base = this.screenshotbase.baseUrl(); | ||
const params = { | ||
url: this.url, | ||
viewport_width: this.width, | ||
viewport_height: this.height, | ||
format: this.format, | ||
full_page: this.fullPage ? 1 : undefined, | ||
}; | ||
const res = await axios($, { | ||
method: "GET", | ||
url: `${base}/v1/take`, | ||
headers: { apikey: this.screenshotbase.$auth.api_key }, | ||
params, | ||
}); | ||
$.export("result", res); | ||
return res; | ||
}, | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import screenshotbase from "../../screenshotbase.app.mjs"; | ||
import { axios } from "@pipedream/platform"; | ||
|
||
export default { | ||
key: "screenshotbase-take-advanced", | ||
name: "Take Screenshot (Advanced)", | ||
description: "Render a website with full set of parameters (format, quality, full_page, viewport)", | ||
version: "0.1.0", | ||
type: "action", | ||
props: { | ||
screenshotbase, | ||
url: { label: "URL", type: "string", optional: false }, | ||
format: { label: "Format", type: "string", optional: true, options: ["jpg", "jpeg", "png", "gif"] }, | ||
quality: { label: "Quality (jpg/jpeg only)", type: "integer", optional: true }, | ||
full_page: { label: "Full Page", type: "boolean", optional: true }, | ||
viewport_width: { label: "Viewport Width", type: "integer", optional: true, default: 1280 }, | ||
viewport_height: { label: "Viewport Height", type: "integer", optional: true, default: 800 }, | ||
}, | ||
async run({ $ }) { | ||
const base = this.screenshotbase.baseUrl(); | ||
const params = { | ||
url: this.url, | ||
format: this.format, | ||
quality: this.quality, | ||
full_page: this.full_page ? 1 : undefined, | ||
viewport_width: this.viewport_width, | ||
viewport_height: this.viewport_height, | ||
}; | ||
const res = await axios($, { | ||
method: "GET", | ||
url: `${base}/v1/take`, | ||
headers: { apikey: this.screenshotbase.$auth.api_key }, | ||
params, | ||
}); | ||
$.export("result", res); | ||
return res; | ||
}, | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import screenshotbase from "../../screenshotbase.app.mjs"; | ||
import { axios } from "@pipedream/platform"; | ||
|
||
export default { | ||
key: "screenshotbase-take-html", | ||
name: "Take from HTML", | ||
description: "Render a screenshot from raw HTML (served by Screenshotbase)", | ||
version: "0.1.0", | ||
type: "action", | ||
props: { | ||
screenshotbase, | ||
html: { label: "HTML", type: "string", optional: false }, | ||
viewport_width: { label: "Viewport Width", type: "integer", optional: true, default: 800 }, | ||
viewport_height: { label: "Viewport Height", type: "integer", optional: true, default: 400 }, | ||
format: { label: "Format", type: "string", optional: true, options: ["jpg", "jpeg", "png", "gif"] }, | ||
}, | ||
async run({ $ }) { | ||
const base = this.screenshotbase.baseUrl(); | ||
const params = { | ||
html: this.html, | ||
format: this.format, | ||
viewport_width: this.viewport_width, | ||
viewport_height: this.viewport_height, | ||
}; | ||
const res = await axios($, { | ||
method: "GET", | ||
url: `${base}/v1/take`, | ||
headers: { apikey: this.screenshotbase.$auth.api_key }, | ||
params, | ||
}); | ||
$.export("result", res); | ||
return res; | ||
}, | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import screenshotbase from "../../screenshotbase.app.mjs"; | ||
import { axios } from "@pipedream/platform"; | ||
|
||
export default { | ||
key: "screenshotbase-take-pdf", | ||
name: "Take PDF", | ||
description: "Render a PDF from a website URL", | ||
version: "0.1.0", | ||
type: "action", | ||
props: { | ||
screenshotbase, | ||
url: { label: "URL", type: "string", optional: false }, | ||
viewport_width: { label: "Viewport Width", type: "integer", optional: true, default: 1280 }, | ||
viewport_height: { label: "Viewport Height", type: "integer", optional: true, default: 800 }, | ||
}, | ||
async run({ $ }) { | ||
const base = this.screenshotbase.baseUrl(); | ||
const params = { | ||
url: this.url, | ||
format: "pdf", | ||
viewport_width: this.viewport_width, | ||
viewport_height: this.viewport_height, | ||
}; | ||
const res = await axios($, { | ||
method: "GET", | ||
url: `${base}/v1/take`, | ||
headers: { apikey: this.screenshotbase.$auth.api_key }, | ||
params, | ||
}); | ||
$.export("result", res); | ||
return res; | ||
}, | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,38 @@ | ||||||||||||||||||||||||||||||||||
export default { | ||||||||||||||||||||||||||||||||||
type: "app", | ||||||||||||||||||||||||||||||||||
app: "screenshotbase", | ||||||||||||||||||||||||||||||||||
name: "Screenshotbase", | ||||||||||||||||||||||||||||||||||
propDefinitions: {}, | ||||||||||||||||||||||||||||||||||
auth: { | ||||||||||||||||||||||||||||||||||
type: "custom", | ||||||||||||||||||||||||||||||||||
fields: { | ||||||||||||||||||||||||||||||||||
api_key: { | ||||||||||||||||||||||||||||||||||
label: "API Key", | ||||||||||||||||||||||||||||||||||
description: "Get your key from the Screenshotbase dashboard.", | ||||||||||||||||||||||||||||||||||
type: "string", | ||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||
base_url: { | ||||||||||||||||||||||||||||||||||
label: "Base URL (optional)", | ||||||||||||||||||||||||||||||||||
type: "string", | ||||||||||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||||||||||
description: "Override API base, defaults to https://api.screenshotbase.com", | ||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||
test: { | ||||||||||||||||||||||||||||||||||
request: { | ||||||||||||||||||||||||||||||||||
url: "https://api.screenshotbase.com/status", | ||||||||||||||||||||||||||||||||||
headers: { | ||||||||||||||||||||||||||||||||||
apikey: "{{auth.api_key}}", | ||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||
Comment on lines
+21
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test ignores custom base_url. The test block hardcodes Apply this diff to respect the user's base_url configuration: test: {
request: {
- url: "https://api.screenshotbase.com/status",
+ url: "{{auth.base_url || 'https://api.screenshotbase.com'}}/status",
headers: {
apikey: "{{auth.api_key}}",
},
},
}, Note: If the test endpoint path differs between environments, you may need to adjust the template accordingly. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||
connectionLabel: "Screenshotbase", | ||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||
methods: { | ||||||||||||||||||||||||||||||||||
baseUrl() { | ||||||||||||||||||||||||||||||||||
return this.$auth.base_url?.trim() || "https://api.screenshotbase.com"; | ||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Declared props are not sent to the API.
The
waitForSelector
andomitBackground
props are declared but never included in theparams
object (lines 55-61), meaning users who configure these options will expect them to work but they won't be sent to the Screenshotbase API.Apply this diff to include the missing parameters:
Verify the correct parameter names with the Screenshotbase API documentation, as I've assumed snake_case naming convention based on other parameters.
🏁 Script executed:
Length of output: 550
Pass declared props to the API
Add the missing
wait_for_selector
andomit_background
parameters so user‐configured options are sent:Verify the exact parameter names against the Screenshotbase API docs.
📝 Committable suggestion
🤖 Prompt for AI Agents