{"id":37161924,"url":"https://github.com/techulus/capture-go","last_synced_at":"2026-01-14T19:16:29.369Z","repository":{"id":303158219,"uuid":"1014576181","full_name":"techulus/capture-go","owner":"techulus","description":"Go SDK for Capture","archived":false,"fork":false,"pushed_at":"2025-07-06T06:48:49.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-14T13:42:38.067Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/techulus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-07-06T02:01:49.000Z","updated_at":"2025-07-06T06:48:52.000Z","dependencies_parsed_at":"2025-07-06T03:24:26.878Z","dependency_job_id":"4df3379a-bc8a-420c-85f3-1cebaea24be5","html_url":"https://github.com/techulus/capture-go","commit_stats":null,"previous_names":["techulus/capture-go"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/techulus/capture-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techulus%2Fcapture-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techulus%2Fcapture-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techulus%2Fcapture-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techulus%2Fcapture-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/techulus","download_url":"https://codeload.github.com/techulus/capture-go/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techulus%2Fcapture-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28432071,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T18:57:19.464Z","status":"ssl_error","status_checked_at":"2026-01-14T18:52:48.501Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-14T19:16:28.551Z","updated_at":"2026-01-14T19:16:29.343Z","avatar_url":"https://github.com/techulus.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Capture Go SDK\n\nA Go SDK for the [Capture browser API](https://capture.page) that provides easy access to web page screenshots, PDF generation, content extraction, and metadata retrieval.\n\n## Features\n\n- **Image Capture**: Generate screenshots of web pages\n- **PDF Generation**: Convert web pages to PDF documents\n- **Content Extraction**: Extract HTML and text content from web pages\n- **Metadata Retrieval**: Get metadata information from web pages\n- **Edge Mode Support**: Use edge servers for faster processing\n- **Custom HTTP Client**: Configure custom HTTP client settings\n- **Type Safety**: Full Go type safety with proper error handling\n\n## Installation\n\n```bash\ngo get github.com/techulus/capture-go\n```\n\n## Quick Start\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n    \"os\"\n\n    \"github.com/techulus/capture-go\"\n)\n\nfunc main() {\n    // Initialize the Capture client\n    key := os.Getenv(\"CAPTURE_KEY\")\n    secret := os.Getenv(\"CAPTURE_SECRET\")\n    \n    c := capture.New(key, secret)\n    \n    // Capture a screenshot\n    imageData, err := c.FetchImage(\"https://www.google.com\", capture.RequestOptions{\n        \"vw\":  1920,\n        \"vh\": 1080,\n    })\n    if err != nil {\n        log.Fatal(err)\n    }\n    \n    // Save the image\n    os.WriteFile(\"screenshot.png\", imageData, 0644)\n    fmt.Println(\"Screenshot saved!\")\n}\n```\n\n## API Reference\n\n\u003e **Note**: This SDK implements the official Capture API. For the complete list of available options and their detailed descriptions, refer to the [official Capture API documentation](https://docs.capture.page/docs).\n\n### Initialization\n\n```go\n// Basic initialization\nc := capture.New(key, secret)\n\n// With edge mode enabled\nc := capture.New(key, secret, capture.WithEdge())\n\n// With custom HTTP client\nclient := \u0026http.Client{Timeout: 30 * time.Second}\nc := capture.New(key, secret, capture.WithHTTPClient(client))\n```\n\n### URL Building\n\nBuild URLs for different capture types without making HTTP requests:\n\n```go\n// Build image URL\nimageURL, err := c.BuildImageURL(\"https://example.com\", capture.RequestOptions{\n    \"vw\":  1920,\n    \"vh\": 1080,\n    \"format\": \"png\",\n})\n\n// Build PDF URL\npdfURL, err := c.BuildPDFURL(\"https://example.com\", capture.RequestOptions{\n    \"format\": \"A4\",\n})\n\n// Build content URL\ncontentURL, err := c.BuildContentURL(\"https://example.com\", capture.RequestOptions{})\n\n// Build metadata URL\nmetadataURL, err := c.BuildMetadataURL(\"https://example.com\", capture.RequestOptions{})\n```\n\n### Fetching Data\n\nFetch actual data from the Capture API:\n\n```go\n// Fetch image as bytes\nimageData, err := c.FetchImage(\"https://example.com\", capture.RequestOptions{\n    \"vw\":  800,\n    \"vh\": 600,\n})\n\n// Fetch PDF as bytes\npdfData, err := c.FetchPDF(\"https://example.com\", capture.RequestOptions{\n    \"format\": \"A4\",\n})\n\n// Fetch content with structured response\ncontentResp, err := c.FetchContent(\"https://example.com\", capture.RequestOptions{})\nif err == nil {\n    fmt.Printf(\"HTML: %s\\n\", contentResp.HTML)\n    fmt.Printf(\"Text: %s\\n\", contentResp.TextContent)\n}\n\n// Fetch metadata with structured response\nmetadataResp, err := c.FetchMetadata(\"https://example.com\", capture.RequestOptions{})\nif err == nil {\n    fmt.Printf(\"Metadata: %+v\\n\", metadataResp.Metadata)\n}\n```\n\n### Request Options\n\nThe `RequestOptions` type is a map that accepts various configuration options. Different request types support different options:\n\n#### Screenshot Options\n\n```go\noptions := capture.RequestOptions{\n    // Basic options\n    \"url\":                \"https://example.com\",     // Target URL (required)\n    \"httpAuth\":           \"base64url_encoded_auth\",  // HTTP Basic Authentication\n    \"userAgent\":          \"Custom User Agent\",       // Custom user agent\n    \n    // Viewport and sizing\n    \"vw\":                 1440,                       // Viewport Width (default: 1440)\n    \"vh\":                 900,                        // Viewport Height (default: 900)\n    \"scaleFactor\":        1,                          // Screen scale factor (default: 1)\n    \"width\":              1920,                       // Clipping Width (default: Viewport Width)\n    \"height\":             1080,                       // Clipping Height (default: Viewport Height)\n    \"top\":                0,                          // Top offset for clipping (default: 0)\n    \"left\":               0,                          // Left offset for clipping (default: 0)\n    \n    // Timing and waiting\n    \"delay\":              2,                          // Delay in seconds (default: 0)\n    \"waitFor\":            \".selector\",                // Wait for CSS selector\n    \"waitForId\":          \"element-id\",               // Wait for element ID\n    \n    // Capture behavior\n    \"full\":               true,                       // Full page capture (default: false)\n    \"darkMode\":           true,                       // Dark mode screenshot (default: false)\n    \"transparent\":        true,                       // Transparent background (default: false)\n    \"selector\":           \".specific-element\",        // Screenshot specific element\n    \"selectorId\":         \"specific-id\",              // Screenshot element by ID\n    \n    // Content blocking\n    \"blockCookieBanners\": true,                       // Block cookie banners (default: false)\n    \"blockAds\":           true,                       // Block ads (default: false)\n    \"bypassBotDetection\": true,                       // Bypass bot detection (default: false)\n    \n    // Image processing\n    \"type\":               \"png\",                      // Image type: png, jpeg, webp (default: png)\n    \"bestFormat\":         true,                       // Best format (default: false)\n    \"resizeWidth\":        800,                        // Resize width\n    \"resizeHeight\":       600,                        // Resize height\n    \n    // Caching and reloading\n    \"timestamp\":          \"1234567890\",               // Force reload\n    \"fresh\":              true,                       // Fresh screenshot (default: false)\n    \n    // S3 integration\n    \"fileName\":           \"screenshot.png\",           // S3 file name\n    \"s3Acl\":              \"public-read\",              // S3 ACL\n    \"s3Redirect\":         true,                       // Redirect to S3 URL (default: false)\n    \"skipUpload\":         true,                       // Skip S3 upload (default: false)\n}\n```\n\n#### PDF Options\n\n```go\noptions := capture.RequestOptions{\n    // Basic options\n    \"url\":          \"https://example.com\",     // Target URL (required)\n    \"httpAuth\":     \"base64url_encoded_auth\",  // HTTP Basic Authentication\n    \"userAgent\":    \"Custom User Agent\",       // Custom user agent\n    \n    // Paper size and format\n    \"format\":       \"A4\",                      // Paper format: Letter, Legal, Tabloid, Ledger, A0-A6 (default: A4)\n    \"width\":        \"8.5in\",                   // Custom paper width with units\n    \"height\":       \"11in\",                    // Custom paper height with units\n    \n    // Margins\n    \"marginTop\":    \"1in\",                     // Top margin with units\n    \"marginRight\":  \"1in\",                     // Right margin with units\n    \"marginBottom\": \"1in\",                     // Bottom margin with units\n    \"marginLeft\":   \"1in\",                     // Left margin with units\n    \n    // Rendering\n    \"scale\":        1,                         // Scale of webpage rendering (default: 1)\n    \"landscape\":    true,                      // Paper orientation (default: false)\n    \n    // Timing\n    \"delay\":        2,                         // Delay in seconds (default: 0)\n    \"timestamp\":    \"1234567890\",              // Force reload\n    \n    // S3 integration\n    \"fileName\":     \"document.pdf\",            // S3 file name\n    \"s3Acl\":        \"public-read\",             // S3 ACL\n    \"s3Redirect\":   true,                      // Redirect to S3 URL (default: false)\n}\n```\n\n#### Content Options\n\n```go\noptions := capture.RequestOptions{\n    \"url\":       \"https://example.com\",     // Target URL (required)\n    \"httpAuth\":  \"base64url_encoded_auth\",  // HTTP Basic Authentication\n    \"userAgent\": \"Custom User Agent\",       // Custom user agent\n    \"delay\":     2,                         // Delay in seconds (default: 0)\n    \"waitFor\":   \".selector\",               // Wait for CSS selector\n    \"waitForId\": \"element-id\",              // Wait for element ID\n}\n```\n\n#### Metadata Options\n\n```go\noptions := capture.RequestOptions{\n    \"url\":       \"https://example.com\",     // Target URL (required)\n    \"httpAuth\":  \"base64url_encoded_auth\",  // HTTP Basic Authentication\n    \"userAgent\": \"Custom User Agent\",       // Custom user agent\n    \"delay\":     2,                         // Delay in seconds (default: 0)\n    \"waitFor\":   \".selector\",               // Wait for CSS selector\n    \"waitForId\": \"element-id\",              // Wait for element ID\n}\n```\n\n### Request Type Differences\n\nEach request type supports different options:\n\n- **Screenshot**: Supports the most options including viewport settings, image processing, content blocking, and S3 integration\n- **PDF**: Supports paper size, margins, orientation, and basic timing options\n- **Content**: Supports basic options for authentication, timing, and element waiting\n- **Metadata**: Supports the same basic options as Content\n\nFor detailed information about which options are supported by each request type, see the [official API documentation](https://docs.capture.page/docs).\n\n### Response Types\n\n#### ContentResponse\n```go\ntype ContentResponse struct {\n    Success     bool   `json:\"success\"`\n    HTML        string `json:\"html\"`\n    TextContent string `json:\"textContent\"`\n}\n```\n\n#### MetadataResponse\n```go\ntype MetadataResponse struct {\n    Success  bool                   `json:\"success\"`\n    Metadata map[string]interface{} `json:\"metadata\"`\n}\n```\n\n## Configuration Options\n\n### Edge Mode\n\nEnable edge mode for faster processing:\n\n```go\nc := capture.New(key, secret, capture.WithEdge())\n```\n\n### Custom HTTP Client\n\nConfigure a custom HTTP client:\n\n```go\nclient := \u0026http.Client{\n    Timeout: 30 * time.Second,\n    Transport: \u0026http.Transport{\n        MaxIdleConns:        10,\n        IdleConnTimeout:     30 * time.Second,\n        DisableCompression:  true,\n    },\n}\n\nc := capture.New(key, secret, capture.WithHTTPClient(client))\n```\n\n## Error Handling\n\nThe SDK provides comprehensive error handling:\n\n```go\nimageData, err := c.FetchImage(\"https://example.com\", capture.RequestOptions{})\nif err != nil {\n    switch {\n    case strings.Contains(err.Error(), \"key and secret are required\"):\n        log.Fatal(\"Missing API credentials\")\n    case strings.Contains(err.Error(), \"url is required\"):\n        log.Fatal(\"Missing target URL\")\n    case strings.Contains(err.Error(), \"HTTP error\"):\n        log.Fatal(\"API request failed\")\n    default:\n        log.Fatal(\"Unexpected error:\", err)\n    }\n}\n```\n\n## Examples\n\nSee the `example/` directory for complete working examples:\n\n- Basic usage examples\n- Error handling\n- File saving\n- Different capture types\n- Edge mode usage\n\nSet these environment variables for authentication while running the examples:\n\n```bash\nexport CAPTURE_KEY=\"your_api_key\"\nexport CAPTURE_SECRET=\"your_api_secret\"\n```\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Add tests if applicable\n5. Submit a pull request\n\n## Support\n\nFor support and questions:\n- GitHub Issues: [https://github.com/techulus/capture-go/issues](https://github.com/techulus/capture-go/issues)\n- Documentation: [https://capture.page/docs](https://capture.page/docs) ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechulus%2Fcapture-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechulus%2Fcapture-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechulus%2Fcapture-go/lists"}