# /Events-by-Author

## Overview

The `/events-by-author` endpoint retrieves the latest events created by a specific author (identified by their public key). It returns a list of events along with the author's profile information.

## Endpoint Details

* **URL**: `/events-by-author`
* **Method**: GET
* **Auth Required**: No
* **Permissions Required**: None

## Request Parameters

| Parameter | Description                                                                                   | Required |
| --------- | --------------------------------------------------------------------------------------------- | -------- |
| `pubkey`  | The public key of the author whose events are to be fetched.                                  | Yes      |
| `limit`   | The maximum number of events to return. Defaults to 20 if not provided.                       | No       |
| `kinds`   | Comma-separated list of event kinds to filter by. Defaults to all kinds if not provided.      | No       |
| `until`   | Unix timestamp in seconds. If provided, fetch only events that were created before this time. | No       |

## Response Schema

The response is a JSON object with the following structure:

```json
{
  "pubkey": "author_pubkey",
  "profiles": {
    "author_pubkey": {
      "id": "profile_event_id",
      "pubkey": "author_pubkey",
      "created_at": 1234567890,
      "kind": 0,
      "tags": [],
      "content": "Profile content",
      "sig": "profile_signature"
    }
  },
  "events": [
    {
      "id": "event_id",
      "pubkey": "author_pubkey",
      "created_at": 1234567890,
      "kind": 1,
      "tags": [],
      "content": "Event content",
      "sig": "event_signature"
    }
  ]
}
```

* `pubkey`: The public key of the author whose events are being returned.
* `profiles`: A map containing the author's profile information.
* `events`: An array of events created by the author, sorted by creation time in descending order.

## Example Call

```bash
curl -X GET "https://huddlers-ovduv.ondigitalocean.app/events-by-author?pubkey=82341f882b6eabcd2ba7f1ef90aad961cf074af15b9ef44a09f9d2a8fbfbe6a2&limit=10&kinds=1,6"
```

## Notes

* Events are sorted by creation time, with the most recent events first.
* The profiles map also includes authors of reposts.

## Error Responses

* **400 Bad Request**: If the pubkey is missing or invalid.
* **404 Not Found**: If no events or profile information can be found for the given pubkey.
* **500 Internal Server Error**: If there's an issue processing the request.


---

# Agent Instructions: 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.huddlers.dev/events-by-author.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.
