# Use Elfa AI

The `Use Elfa AI` tool, part of AgentiPy, allows users to leverage the Elfa AI platform (`https://api.elfa.ai`) for insights related to the Solana blockchain and crypto markets. It can fetch data such as token mentions, trending tokens, and Twitter account statistics. This tool requires an Elfa AI API key.

## Functionality

This tool is implemented in the `ElfaAiManager` class and interacts directly with the Elfa AI API using `aiohttp`. The API key is passed via headers, which are prepared by `agentipy.utils.elfa_ai.get_headers(agent)`.

### Key Methods:

* `ping_elfa_ai_api(agent: SolanaAgentKit) -> dict`: Pings the Elfa AI API to check connectivity.
* `get_elfa_ai_api_key_status(agent: SolanaAgentKit) -> dict`: Checks the status of the provided Elfa AI API key.
* `get_smart_mentions(agent: SolanaAgentKit, limit: int = 100, offset: int = 0) -> dict`: Retrieves "smart mentions" (curated or important mentions) from Elfa AI.
* `get_top_mentions_by_ticker(agent: SolanaAgentKit, ticker: str, time_window: str = "1h", page: int = 1, page_size: int = 10, include_account_details: bool = False) -> dict`: Fetches top mentions for a specific token `ticker` within a `time_window`.
* `search_mentions_by_keywords(agent: SolanaAgentKit, keywords: str, from_timestamp: int, to_timestamp: int, limit: int = 20, cursor: str = None) -> dict`: Searches for mentions based on `keywords` within a given timestamp range.
* `get_trending_tokens_using_elfa_ai(agent: SolanaAgentKit, time_window: str = "24h", page: int = 1, page_size: int = 50, min_mentions: int = 5) -> dict`: Gets a list of trending tokens based on mention activity.
* `get_smart_twitter_account_stats(agent: SolanaAgentKit, username: str) -> dict`: Retrieves statistics for a given Twitter `username`.

##

**Important Considerations:**

* **API Key:** An Elfa AI API key is mandatory for using this tool. It should be set in the `SolanaAgentKit` instance as `agent.elfa_ai_api_key`.
* **External API:** The tool's functionality is entirely dependent on the Elfa AI API. Check Elfa AI's documentation for rate limits, data structure details, and terms of service.

## Source Code

You can find the source code for this tool on GitHub: <https://github.com/niceberginc/agentipy/blob/main/agentipy/tools/use_elfa_ai.py>


---

# 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.agentipy.fun/tools/use-elfa-ai.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.
