Skip to content

Commit

Permalink
ading api docs
Browse files Browse the repository at this point in the history
minhlucvan committed Sep 30, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 8d44077 commit c958800
Showing 13 changed files with 1,032 additions and 1 deletion.
73 changes: 73 additions & 0 deletions api/v2/1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
openapi: 3.0.2
info:
title: Content API
version: 2.0.0
servers:
- url: https://production-sfo.browserless.io
paths:
/content:
post:
summary: Fetches the page's content
parameters:
- name: token
in: query
required: true
schema:
type: string
description: API token
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
url:
type: string
description: The URL to navigate to
gotoOptions:
type: object
description: Modifies the default navigation behavior for the requested URL.
bestAttempt:
type: boolean
description: Causes Browserless to continue when async events fail or timeout.
rejectResourceTypes:
type: array
items:
type: string
description: A list of resource types to block
rejectRequestPattern:
type: array
items:
type: string
description: A list of regex patterns to block certain requests
waitForEvent:
type: object
description: Waits for an event to happen on the page before continuing
waitForFunction:
type: object
description: Waits for the provided function to return before continuing
waitForSelector:
type: object
description: Wait for a selector to appear in the page
waitForTimeout:
type: integer
description: Maximum number of milliseconds to wait
examples:
example1:
summary: Basic Request
value:
url: "https://example.com/"
example2:
summary: Request with Navigation Options
value:
url: "https://example.com/"
gotoOptions: { "waitUntil": "networkidle2" }
responses:
'200':
description: Success
content:
text/html:
schema:
type: string
description: The site's HTML after it has been rendered and evaluated inside the browser.
90 changes: 90 additions & 0 deletions api/v2/10.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
openapi: 3.0.0
info:
title: Browserless.io API
version: v2
servers:
- url: https://production-sfo.browserless.io/
- url: https://production-lon.browserless.io/
paths:
/config:
get:
summary: Get your worker's configuration
operationId: getWorkerConfig
parameters:
- name: token
in: query
required: true
schema:
type: string
example: MY_API_TOKEN
responses:
'200':
description: Successful operation
content:
application/json:
schema:
type: object
properties:
allowCORS:
type: boolean
allowFileProtocol:
type: boolean
allowGetCalls:
type: boolean
concurrent:
type: integer
data:
type: string
debug:
type: string
errorAlertURL:
type: string
healthFailureURL:
type: string
host:
type: string
maxCPU:
type: integer
maxMemory:
type: integer
metricsJSONPath:
type: string
port:
type: integer
queued:
type: integer
queuedAlertURL:
type: string
rejectAlertURL:
type: string
retries:
type: integer
timeout:
type: integer
timeoutAlertURL:
type: string
token:
type: string
example:
allowCORS: true
allowFileProtocol: false
allowGetCalls: false
concurrent: 10
data: "/tmp/browserless-data-dirs"
debug: "browserless*,-**:verbose"
errorAlertURL: null
healthFailureURL: null
host: "localhost"
maxCPU: 99
maxMemory: 99
metricsJSONPath: "/tmp/browserless-metrics.json"
port: 3001
queued: 10
queuedAlertURL: null
rejectAlertURL: null
retries: 5
timeout: 30000
timeoutAlertURL: null
token: "6R0W53R135510"
tags:
- name: Management-REST-APIs
138 changes: 138 additions & 0 deletions api/v2/11.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
openapi: 3.0.0
info:
title: Browserless API Documentation
version: v2.0.0
servers:
- url: https://production-sfo.browserless.io
- url: https://production-lon.browserless.io

paths:
/metrics:
get:
summary: Fetch metrics
description: Retrieve an array of session statistics. The data returned will have a maximum date of 1 week.
parameters:
- name: token
in: query
required: true
description: API key.
schema:
type: string
responses:
200:
description: Array of session statistics
content:
application/json:
schema:
type: array
items:
type: object
properties:
error:
type: integer
maxConcurrent:
type: integer
queued:
type: integer
rejected:
type: integer
running:
type: integer
sessionTimes:
type: array
items:
type: integer
successful:
type: integer
timedout:
type: integer
unauthorized:
type: integer
unhealthy:
type: integer
maxTime:
type: integer
meanTime:
type: integer
minTime:
type: integer
totalTime:
type: integer
units:
type: integer
date:
type: integer
cpu:
type: number
memory:
type: number
example:
- error: 3
maxConcurrent: 4
queued: 0
rejected: 0
running: 3
sessionTimes: [992, 1041, 802]
successful: 0
timedout: 0
unauthorized: 0
unhealthy: 0
maxTime: 1041
meanTime: 945
minTime: 802
totalTime: 2835
units: 3
date: 1709134233732
cpu: 0.024877870173220466
memory: 0.7784158564199399

/metrics/total:
get:
summary: Fetch total metrics
description: This route will output a similar payload, but with the total stats of all sessions.
responses:
200:
description: Total session statistics
content:
application/json:
schema:
type: object
properties:
error:
type: integer
maxConcurrent:
type: integer
queued:
type: integer
rejected:
type: integer
running:
type: integer
sessionTimes:
type: array
items:
type: integer
successful:
type: integer
timedout:
type: integer
unauthorized:
type: integer
unhealthy:
type: integer
maxTime:
type: integer
meanTime:
type: integer
minTime:
type: integer
totalTime:
type: integer
units:
type: integer
date:
type: integer
cpu:
type: number
memory:
type: number
81 changes: 81 additions & 0 deletions api/v2/2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
openapi: 3.0.1
info:
title: Browserless API
version: v2
servers:
- url: 'https://production-sfo.browserless.io'
- url: 'https://production-lon.browserless.io'
paths:
/download:
post:
summary: Download file from Puppeteer script
operationId: download
description: Invoke Puppeteer script code and download any files created within the context of the browser.
requestBody:
required: true
content:
application/javascript:
schema:
type: string
example: |
export default function ({ page }){
await page.evaluate(() => {
const json = {
ping: "pong",
rnd: [...Array(5)].map(() => Math.random())
}
const jsonContent = `data:application/json,${JSON.stringify(json)}`;
const encodedUri = encodeURI(jsonContent);
const link = document.createElement('a');
link.setAttribute('href', encodedUri);
link.setAttribute('download', 'data.json');
document.body.appendChild(link);
return link.click();
});
}
application/json:
schema:
type: object
properties:
code:
type: string
description: Custom download code
context:
type: object
description: Value used to pass context values and arguments to the `code`
properties:
url:
type: string
description: The URL to be used in the context
arrayLen:
type: integer
description: Length of the random array
required:
- code
- context
example:
code: "async function({page:t,context:a}){await t.evaluate(t=>{let a={url:t.url,ping:`pong`,rnd:[...Array(t.arrayLen)].map(()=>Math.random())},e=`data:application/json,${JSON.stringify(a)}`,n=encodeURI(e),r=document.createElement(`a`);return r.setAttribute(`href`,n),r.setAttribute(`download`,`data.json`),document.body.appendChild(r),r.click()},a)};"
context:
url: "https://browserless.io/"
arrayLen: 10
responses:
200:
description: File created by Puppeteer code
content:
application/octet-stream:
schema:
type: string
format: binary
400:
description: Invalid request
500:
description: Server error
components:
securitySchemes:
ApiKeyAuth:
type: apiKey
in: query
name: token
security:
- ApiKeyAuth: []
Loading

0 comments on commit c958800

Please sign in to comment.