{"id":23171709,"url":"https://github.com/smarthypercube/browse-api-serverless","last_synced_at":"2025-08-18T07:32:16.127Z","repository":{"id":212981217,"uuid":"732743950","full_name":"SmartHypercube/browse-api-serverless","owner":"SmartHypercube","description":"一些为 AI 提供打开 URL 的能力的 API，均设计为部署在 AWS Lambda 上的无服务器云函数。","archived":false,"fork":false,"pushed_at":"2024-05-15T02:27:25.000Z","size":30,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-05-15T20:15:14.719Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SmartHypercube.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2023-12-17T17:31:06.000Z","updated_at":"2024-05-15T02:27:28.000Z","dependencies_parsed_at":"2024-01-23T07:42:15.316Z","dependency_job_id":null,"html_url":"https://github.com/SmartHypercube/browse-api-serverless","commit_stats":null,"previous_names":["smarthypercube/browse-api-serverless"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartHypercube%2Fbrowse-api-serverless","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartHypercube%2Fbrowse-api-serverless/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartHypercube%2Fbrowse-api-serverless/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartHypercube%2Fbrowse-api-serverless/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SmartHypercube","download_url":"https://codeload.github.com/SmartHypercube/browse-api-serverless/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230216034,"owners_count":18191559,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2024-12-18T04:19:18.432Z","updated_at":"2024-12-18T04:19:41.963Z","avatar_url":"https://github.com/SmartHypercube.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# browse-api-serverless\n\n一些为 AI 提供打开 URL 的能力的 API，均设计为部署在 AWS Lambda 上的无服务器云函数。\n\n目前包含 4 个 API：\n\n- `browse-text`：用 headless Chromium 尝试打开网页，提取网页标题和显示的所有文字。\n- `github`：获取 GitHub 仓库的元信息和 README。\n- `pdf`：下载 PDF 并提取其中的文字。\n- `youtube`：获取 YouTube 视频标题、所属频道、描述、字幕。\n\n## 部署\n\n安装并配置以下依赖：\n\n- [Serverless Framework](https://serverless.com/)\n- [Node.js](https://nodejs.org/)\n- [Python 3.9](https://www.python.org/)\n- `zip`, `make` 等基础工具\n\n然后在项目根目录下执行 `make`。运行结束后会输出各 API 的 URL。\n\n## 使用\n\n每个 API 都应当使用 `POST` 方法调用，请求体类似如下格式：\n\n```json\n{\n    \"url\": \"https://example.com/\"\n}\n```\n\n每个 API 成功时都返回类似如下格式的 JSON。如果返回码不是 200，说明这个 API 无法打开指定的 URL。注意：某个 API 能打开某个 URL，并不意味着这个 API 是最佳选择。例如 `browse-text` API 可以打开 YouTube 视频的 URL，但是 `youtube` API 可能是更好的选择。\n\n```json\n{\n    \"truncated\": false,\n    \"template\": [\n        {\"field\": \"foo\", \"name\": \"Foo\", \"type\": \"inline\"},\n        {\"field\": \"bar\", \"name\": \"Bar\", \"type\": \"inline\"},\n        {\"field\": \"baz\", \"name\": \"Baz\", \"type\": \"block\"},\n        {\"field\": \"qux\", \"name\": \"Qux\", \"type\": \"block\"}\n    ],\n    \"data\": {\n        \"foo\": \"some text\",\n        \"baz\": \"some text\\nmore text\",\n        \"qux\": \"some text\\nmore text\"\n    }\n}\n```\n\n其中 `truncated` 指示是否截断了部分数据以满足 AWS Lambda 的 6MB 返回值大小限制，`template` 列出了 `data` 中所有可能的字段，以及如何格式化以便提供给 AI 模型的建议。\n\n用户可以忽略 `template` 部分，直接以 JSON 格式传递 `data` 给 AI 模型，也可以按 `template` 给出的建议，用类似如下格式拼接字符串：\n\n```plain\nFoo: some text\n\nBaz:\nsome text\nmore text\n\nQux:\nsome text\nmore text\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmarthypercube%2Fbrowse-api-serverless","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmarthypercube%2Fbrowse-api-serverless","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmarthypercube%2Fbrowse-api-serverless/lists"}