> For the complete documentation index, see [llms.txt](https://docs.alpha-lenz.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.alpha-lenz.com/ko/api-reference/public-api/authentication.md).

# 인증

## 시작하기

다음 단계를 따라 API 키를 발급받고 Alpha Lenz API 요청을 시작하세요.

### 1단계: 계정 생성

1. <https://alpha-lenz.com>에서 회원가입
2. 이메일 주소 인증
3. 대시보드에 로그인

### 2단계: API 키 생성

1. 대시보드에서 **설정** > **API 키**로 이동
2. **"새 API 키 만들기"** 버튼 클릭
3. API 키에 설명적인 이름 지정 (예: "프로덕션 키")
4. **"생성"** 클릭

> **⚠️ 중요:** API 키는 한 번만 표시됩니다. 즉시 안전한 위치에 복사하여 저장하세요. 키를 분실하면 새 키를 생성해야 합니다.

### 3단계: 첫 API 호출하기

`X-API-Key` 헤더에 API 키를 포함합니다:

```bash
curl -X GET "https://api.alpha-lenz.com/api/public/v1/financial/companies" \
     -H "X-API-Key: ak_aBcDeFgHiJkLmNoPqRsTuVwXyZ123456"
```

**응답 예시:**

```json
{
  "data": [
    {
      "company_id": "KR7005930003",
      "company_name": "Samsung Electronics",
      "ticker": "005930"
    }
  ]
}
```

### 4단계: 애플리케이션에 통합

**Python 예시:**

```python
import requests

API_KEY = "ak_aBcDeFgHiJkLmNoPqRsTuVwXyZ123456"
BASE_URL = "https://api.alpha-lenz.com/api/public/v1"

headers = {
    "X-API-Key": API_KEY
}

response = requests.get(f"{BASE_URL}/financial/companies", headers=headers)
companies = response.json()
```

**JavaScript 예시:**

```javascript
const API_KEY = 'ak_aBcDeFgHiJkLmNoPqRsTuVwXyZ123456';
const BASE_URL = 'https://api.alpha-lenz.com/api/public/v1';

const response = await fetch(`${BASE_URL}/financial/companies`, {
  headers: {
    'X-API-Key': API_KEY
  }
});

const companies = await response.json();
```

## API 키 관리

### 프로그래밍 방식으로 API 키 생성

API를 사용하여 프로그래밍 방식으로 API 키를 생성할 수도 있습니다:

**엔드포인트:** `POST /api/v1/api-keys`

**헤더:**

```
Authorization: Bearer <your_jwt_token>
Content-Type: application/json
```

**요청 본문:**

```json
{
  "name": "프로덕션 키",
  "scopes": ["read:financial", "read:stock"],
  "expires_at": "2025-12-31T23:59:59Z",
  "rate_limit": 2000,
  "rate_period": 3600
}
```

**응답:**

```json
{
  "id": 1,
  "name": "프로덕션 키",
  "key": "ak_aBcDeFgHiJkLmNoPqRsTuVwXyZ123456",
  "key_prefix": "ak_aBcDeFgH",
  "scopes": ["read:financial", "read:stock"],
  "expires_at": "2025-12-31T23:59:59Z",
  "created_at": "2024-01-15T10:30:00Z"
}
```

### API 키 조회

대시보드의 **API 키** 섹션에서 다음을 수행할 수 있습니다:

* 활성 API 키 전체 보기 (보안상 접두사만 표시)
* 각 키의 생성 시간 및 마지막 사용 시간 확인
* 현재 상태 확인 (활성/취소됨)
* 사용량 및 요청 제한 모니터링

### API 키 취소

API 키가 유출되었거나 더 이상 필요하지 않은 경우:

1. **설정** > **API 키**로 이동
2. 취소할 키 찾기
3. **"취소"** 버튼 클릭
4. 작업 확인

취소된 키는 복원할 수 없습니다. 필요한 경우 새 키를 생성해야 합니다.

## 요청 제한

기본값: **시간당 1,000회 요청**

요청 제한은 API 키별로 적용됩니다. 제한 초과 시:

```
HTTP/1.1 429 Too Many Requests
Retry-After: 3600

{
  "detail": "Rate limit exceeded"
}
```

### 맞춤 요청 제한

API 키 생성 시 맞춤 요청 제한을 설정할 수 있습니다:

* `rate_limit`: 허용되는 요청 수
* `rate_period`: 시간(초) (60-86400)

더 높은 제한이 필요한 경우 챗봇을 통해 문의하세요.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.alpha-lenz.com/ko/api-reference/public-api/authentication.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
