> ## Documentation Index
> Fetch the complete documentation index at: https://glasser.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 调用指定接口

通过 **HTTP API** 从后端调用已知接口，无需 Agent。

**Your backend**Fixed Endpoint
→
**Glasser**HTTP API
→
**Provider**Data

## 调用接口

示例：接收应用中的 Instagram 用户名，获取其最新公开帖子。

**1. 连接后端**

**服务地址：**`https://api.glasser.ai`\
&#x20;**请求头：**`Authorization: Bearer <your Key>`

\*\*使用产品账号：\*\*使用工作空间的 [API Key](https://app.glasser.ai/keys?locale=zh-CN)。\
&#x20;\*\*使用用户账号：\*\*为每次请求选择该用户的 API Key。

将 API Key 保存在后端，通过免费的 [GET /v1/balance](https://glasser.ai/docs/zh/api-reference/balance/get.md) 请求检查连接。

**2. 配置时检查一次接口**

向 [POST /v1/endpoints/inspect](https://glasser.ai/docs/zh/api-reference/endpoints/inspect.md) 发送 JSON：

```json wrap theme={null}
{
  "provider": "apify",
  "endpoint": "/apify/instagram-post-scraper"
}
```

\*\*获取：\*\*输入 Schema 和当前价格。该接口必须提供 `username`，即包含一个用户名的数组。检查免费。

**3. 从产品中调用**

向 [POST /v1/runs](https://glasser.ai/docs/zh/api-reference/runs/create.md) 发送 JSON，使用相同的 Authorization 请求头和 `Content-Type: application/json`，并为本次执行提供唯一的 `Idempotency-Key` 请求头。

```json wrap theme={null}
{
  "provider": "apify",
  "endpoint": "/apify/instagram-post-scraper",
  "input": { "username": ["mkbhd"] }
}
```

将 `mkbhd` 替换为用户输入。

\*\*获取：\*\*包含 `id`、`status` 和 `charge_usd` 的 Run。就绪后，`output` 包含最多 10 条公开帖子，包括文案、点赞数和评论数。

对于 `QUEUED` 或 `RUNNING`，持续[读取该 Run](https://glasser.ai/docs/zh/api-reference/runs/get.md)，直至进入终态。Run 使用所连接工作空间的余额。

> [accordion] 重试与响应处理
>
> * 使用检查结果中的 `endpoint_version`，或省略以使用默认版本。版本不会锁定价格；新 Run 使用受理时的价格。
> * 重试同一请求时，使用**相同的** `Idempotency-Key` 和输入。Run 尚未结束时，继续读取已有 Run，不要重新创建。
> * 使用 `output` 前，同时检查 `status` 和 `provider_response.http_status`。 `COMPLETED` 状态的 Run 仍可能包含数据提供商错误。
> * 在产品请求记录中保留 Run ID 和 `charge_usd`。失败的 Run 仍可能按接口定价产生费用。
> * 分别保管各用户的 API Key，从已认证的用户连接中选取，不要从请求输入字段中获取。

## 浏览数据提供商 API

在[数据源](https://glasser.ai/zh/datasources)中选择接口，再检查其 Schema。之后可以复用，无需在每次 Run 前重新搜索。

如需在代码中列出数据提供商和接口，使用 [GET /public/catalog](https://glasser.ai/docs/zh/api-reference/endpoints/list.md)。该请求无需 API Key，且免费：

```bash wrap theme={null}
curl https://api.glasser.ai/public/catalog
```

* \*\*`providers`：\*\*数据提供商名称、描述和接口数。
* \*\*`entries`：\*\*接口标识、描述、分类和展示价格。通过 `provider` 查找某家数据提供商的接口。
* \*\*一次响应：\*\*返回完整公开列表，不分页。

响应经过缓存，不应用 API Key 的 Policy。运行前，使用 API Key [检查](https://glasser.ai/docs/zh/api-reference/endpoints/inspect.md)所选接口，获取输入 Schema 和当前价格。

## 可选：Solutions

**GTM Solution** 通过 HTTP 提供六项固定能力，Glasser 负责选择接口、转换输入，并在支持的失败类型下尝试其他数据提供商。

* [网页研究](https://glasser.ai/docs/zh/api-reference/solutions/gtm/web_research.md)：网页搜索、新闻和页面内容。
* [公司信息](https://glasser.ai/docs/zh/api-reference/solutions/gtm/company_intelligence.md)：按域名查询公司详情。
* [人员搜索](https://glasser.ai/docs/zh/api-reference/solutions/gtm/people_search.md)：人员与商务联系信息。
* [SEO 研究](https://glasser.ai/docs/zh/api-reference/solutions/gtm/seo_research.md)：关键词、排名和外链。
* [社交数据研究](https://glasser.ai/docs/zh/api-reference/solutions/gtm/social_research.md)：社交资料、帖子和搜索。
* [市场数据](https://glasser.ai/docs/zh/api-reference/solutions/gtm/market_data.md)：房产数据和股票报价。

各能力在 `/v1/solutions/gtm/` 下有独立 API。使用相同的 API Key，并提供 `Idempotency-Key` 请求头；响应为 Run。示例和数据提供商选择规则见 [Solutions 概览](https://glasser.ai/docs/zh/api-reference/solutions/overview.md)。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.