-
Notifications
You must be signed in to change notification settings - Fork 2
Add Reference section for the HTTP API #79
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b8af55b
Add reference/http-api section documenting the /api/fetch endpoint
cdebled a444bae
Slim usage/api.mdx down to a practical guide, linking to the new refe…
cdebled 6409ea5
Address review: document the country parameter's two-letter format co…
cdebled d3a52b7
Merge branch 'main' into http-api-reference
cdebled 579330e
Merge branch 'main' into http-api-reference
cdebled File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| --- | ||
| title: HTTP API | ||
| description: Reference of the Lightpanda Cloud HTTP API endpoints. | ||
| --- | ||
|
|
||
| # HTTP API | ||
|
|
||
| Fetch a URL and retrieve the rendered page. See [how to use the HTTP API](/usage/api) for practical documentation. | ||
|
|
||
| ## Fetch a URL | ||
|
|
||
| The `POST /api/fetch` endpoint returns a JSON message containing the page's content. | ||
|
|
||
| ### Request | ||
|
|
||
| The request requires a bearer authorization header with your token and the `Content-Type: application/json` header. | ||
|
|
||
| The endpoint accepts the following parameters: | ||
|
|
||
| | Parameter | Type | Required | Default | Description | | ||
| |---|---|---|---|---| | ||
| | `url` | string | Yes | — | The URL to fetch. | | ||
| | `output_format` | `html` \| `markdown` | No | `html` | — | | ||
| | `wait_ms` | uint | No | `5000` | Time to wait before retrieving the page, in milliseconds. `0` also falls back to the default; it doesn't mean "don't wait". | | ||
| | `wait_event` | `DOMContentLoaded` \| `load` \| `networkAlmostIdle` \| `networkIdle` | No | `networkIdle` | Event to wait for before retrieving the page. | | ||
| | `raw` | bool | No | `false` | If true, the raw HTML or markdown is returned directly, without the JSON wrapper, with `Content-Type: text/html` or `text/plain` respectively. | | ||
| | `proxy_name` | string | No | `fast_dc` | — | | ||
| | `country` | string | No | — | Two-letter country code, case-insensitive. Only used with the `datacenter` proxy. | | ||
|
|
||
| ```sh copy | ||
| curl -XPOST \ | ||
| -H "Authorization: Bearer YOUR_TOKEN" \ | ||
| -H "Content-Type: application/json" \ | ||
| https://euwest.cloud.lightpanda.io/api/fetch \ | ||
| --data '{ | ||
| "url": "https://lightpanda.io", | ||
| "output_format": "markdown", | ||
| "wait_ms": 50000, | ||
| "wait_event": "networkIdle", | ||
| "raw": false | ||
| }' | ||
| ``` | ||
|
|
||
| ### Response | ||
|
|
||
| If the request sets `raw` to `false`, a JSON response is returned. | ||
|
|
||
|
cdebled marked this conversation as resolved.
|
||
| | Field | Type | Description | | ||
| |---|---|---| | ||
| | `data` | string | The page's content, in the format specified by the `output_format` parameter. | | ||
| | `status` | int | The response status code. | | ||
| | `headers` | object, optional | The HTTP headers returned by the server. | | ||
|
|
||
| ```json copy | ||
| { | ||
| "data": "\n# Example Domain\n\nThis domain is for use in documentation examples without needing permission. Avoid use in operations.\n\n[Learn more](https://iana.org/domains/example)\n", | ||
| "status": 200, | ||
| "headers": { | ||
| "age": "10026", | ||
| "allow": "GET, HEAD", | ||
| "cf-cache-status": "HIT", | ||
| "cf-ray": "9f0dd9374a2320ab-IAD", | ||
| "content-encoding": "br", | ||
| "content-type": "text/html", | ||
| "date": "Thu, 23 Apr 2026 15:19:47 GMT", | ||
| "last-modified": "Sat, 18 Apr 2026 00:51:00 GMT", | ||
| "server": "cloudflare" | ||
| } | ||
| } | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Heads up that all four PRs in the series (#76, #77, #78, this one) create this same file with a different single key, so the last three to merge each need a small conflict resolution here, and the final key order decides the sidebar order of the Reference section.
Uh oh!
There was an error while loading. Please reload this page.
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.
Yes, I chose to create independent PRs, all based on the main branch, so as not to constrain which one we want to merge first. But sure, I'll handle the conflicts after each merge (not a complex conflict). As for the order, I'm planning: CLI, HTTP API, MCP tools, Pandascript.