feat: add userAgent parameter for custom User-Agent headers
Some checks failed
Build & Deploy to Staging / Build & Deploy to Staging (push) Has been cancelled

- Add userAgent?: string to ScreenshotOptions interface
- Implement validation (max 500 chars, no newlines for security)
- Call page.setUserAgent() after page acquisition, before navigation
- Add route handler support for both POST body and GET query
- Add comprehensive test coverage (11 new tests)
- Update OpenAPI documentation with parameter specs and examples
- Update Node.js and Python SDK README examples
- All userAgent tests passing (414 → 425 total tests)

Fixes potential HTTP header injection by rejecting newlines.
Enables custom User-Agent strings for specific browser emulation needs.
This commit is contained in:
SnapAPI Developer 2026-03-05 15:10:06 +01:00
parent a17f492cc3
commit 9290c759da
5 changed files with 313 additions and 0 deletions

View file

@ -86,6 +86,17 @@ dark_screenshot = snap.capture(
)
```
### Custom User Agent
```python
# Set a custom User-Agent string for the request
screenshot = snap.capture(
"https://example.com",
user_agent="Mozilla/5.0 (compatible; SnapAPI/1.0)",
format="png",
)
```
### Hide Elements Before Capture
```python