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

# 认证

> 使用 API 密钥对 Olostep 的搜索、抓取和爬取 API 进行认证。

API 端点要求你使用 API 令牌进行认证。

## 生成令牌

令牌可以从 Olostep 仪表板生成。请在[这里](https://www.olostep.com/auth/)创建一个账户。

## 使用你的令牌

你可以通过在所有 HTTP 调用中添加 `Authorization` 头来进行认证。Authorization 头的格式如下：`Authorization: Bearer <API-TOKEN>`（用你的令牌替换 `<API-TOKEN>`）。如果你没有令牌，可以从 Olostep 的[仪表板](https://www.olostep.com/dashboard/)免费生成一个。

示例：

<CodeGroup>
  ```python Python theme={null}
  # pip install requests

  import requests

  endpoint = 'https://api.olostep.com/v1/scrapes/<SCRAPE_ID>'
  headers = {
      'Authorization': 'Bearer <API-TOKEN>',
      'Accept': 'application/json'
  }

  response = requests.get(endpoint, headers=headers)
  print(response.status_code)
  print(response.json())
  ```

  ```js Node theme={null}
  // npm install node-fetch

  // ESM
  import fetch from 'node-fetch'

  const endpoint = 'https://api.olostep.com/v1/scrapes/<SCRAPE_ID>'
  const res = await fetch(endpoint, {
    headers: {
      'Authorization': 'Bearer <API-TOKEN>',
      'Accept': 'application/json'
    }
  })
  console.log(res.status)
  console.log(await res.json())
  ```

  ```bash cURL theme={null}
  curl -L -X GET 'https://api.olostep.com/v1/scrapes/<SCRAPE_ID>' \
    -H 'Accept: application/json' \
    -H 'Authorization: Bearer <API-TOKEN>'
  ```
</CodeGroup>

## 使用 CLI

如果你在使用 [Olostep CLI](/sdks/cli)，可以跳过手动密钥处理并从终端登录：

```bash theme={null}
npm install -g olostep-cli
olostep login
```

浏览器会打开，你点击 **Authorize**，然后密钥会被本地保存。对于 CI，请设置 `OLOSTEP_API_KEY`。

## 使用 SDKs

[Python](/sdks/python) 和 [Node.js](/sdks/node-js) SDKs 会从环境中读取 `OLOSTEP_API_KEY`，或者在构造客户端时直接接受密钥。
