# User Profile API

Base URL: `${FORGEJO_URL}/api/v1`

## Get Current Authenticated User

```
GET /user
```

```bash
curl -s \
  -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/user"
```

**Response (User):**
| Field | Type | Description |
|-------|------|-------------|
| id | integer | User ID |
| login | string | Username |
| login_name | string | Login name (for auth) |
| full_name | string | Display name |
| email | string | Email address |
| avatar_url | string | Avatar URL |
| html_url | string | Profile page URL |
| language | string | Preferred language |
| is_admin | boolean | Site administrator |
| last_login | string | Last login timestamp |
| created | string | Account creation timestamp |
| restricted | boolean | Restricted user |
| active | boolean | Account is active |
| prohibit_login | boolean | Login is prohibited |
| location | string | Location |
| pronouns | string | Pronouns |
| website | string | Website URL |
| description | string | Bio/description |
| visibility | string | Profile visibility |
| followers_count | integer | Number of followers |
| following_count | integer | Number following |
| starred_repos_count | integer | Starred repos count |

---

## Get User by Username

```
GET /users/{username}
```

```bash
curl -s \
  -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/users/{username}"
```

Returns the same `User` object as above.

---

## Search Users

```
GET /users/search
```

**Parameters:**
| Name | Type | In | Description |
|------|------|------|-------------|
| q | string | query | Search keyword |
| page | integer | query | Page number (1-based) |
| limit | integer | query | Page size |

```bash
curl -s \
  -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/users/search?q=john&page=1&limit=10"
```

**Response:**
```json
{
  "ok": true,
  "data": [ /* array of User objects */ ]
}
```

---

## Contribution Heatmap

```
GET /users/{username}/heatmap
```

Returns daily contribution counts for the past year.

```bash
curl -s \
  -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/users/{username}/heatmap"
```

**Response:** Array of heatmap entries:
| Field | Type | Description |
|-------|------|-------------|
| timestamp | integer | Unix timestamp (start of day) |
| contributions | integer | Number of contributions |

**Example Response:**
```json
[
  {"timestamp": 1704067200, "contributions": 5},
  {"timestamp": 1704153600, "contributions": 12}
]
```

---

## Activity Feed

```
GET /users/{username}/activities/feeds
```

**Parameters:**
| Name | Type | In | Description |
|------|------|------|-------------|
| only_performed_by | boolean | query | Only show actions performed by user |
| date | string | query | Date filter (YYYY-MM-DD) |
| page | integer | query | Page number (1-based) |
| limit | integer | query | Page size |

```bash
curl -s \
  -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/users/{username}/activities/feeds?page=1&limit=10"
```

---

## Set User Avatar

```
POST /user/avatar
```

**Request Body:**
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| image | string | yes | Base64-encoded image data |

```bash
curl -s -X POST \
  -H "Authorization: token ${FORGEJO_PAT}" \
  -H "Content-Type: application/json" \
  -d "{\"image\": \"$(base64 -w 0 avatar.png)\"}" \
  "${FORGEJO_URL}/api/v1/user/avatar"
```

---

## Delete User Avatar

```
DELETE /user/avatar
```

```bash
curl -s -X DELETE \
  -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/user/avatar"
```

Returns `204 No Content` on success.

---

## Block User

```
PUT /user/block/{username}
```

```bash
curl -s -X PUT \
  -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/user/block/{username}"
```

Returns `204 No Content` on success.

---

## Unblock User

```
PUT /user/unblock/{username}
```

```bash
curl -s -X PUT \
  -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/user/unblock/{username}"
```

Returns `204 No Content` on success.

---

## List Blocked Users

```
GET /user/list_blocked
```

**Parameters:**
| Name | Type | In | Description |
|------|------|------|-------------|
| page | integer | query | Page number (1-based) |
| limit | integer | query | Page size |

```bash
curl -s \
  -H "Authorization: token ${FORGEJO_PAT}" \
  "${FORGEJO_URL}/api/v1/user/list_blocked"
```

**Response:** Array of `BlockedUser` objects:
| Field | Type | Description |
|-------|------|-------------|
| block_id | integer | Block record ID |
| created_at | string | Timestamp of block |
| blocked_user | object | User object of blocked user |
