> For the complete documentation index, see [llms.txt](https://docs.forgeonchain.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.forgeonchain.ai/integrating-external-apis.md).

# Integrating External APIs

Forge is strongest when it sees everything. While its native indexer captures live on-chain events, sometimes you need context from **outside the blockchain** — like Telegram data, Twitter signals, trending words, or even centralized price feeds. That’s where API integration comes in.

This page explains how to plug external data sources into Forge so your agents can react to signals beyond Solana.

***

### Why Integrate External APIs

On-chain activity only tells half the story. Many key events start off-chain:

* A Telegram KOL posts alpha
* A deployer joins a chat group
* A wallet gets funded after a Discord mention
* A Twitter thread goes viral and sparks a memecoin pump

By integrating APIs, you allow Forge to:

* Trigger agents based on social activity
* Combine off-chain signals with on-chain responses
* Build richer prompts with external data
* Monitor coordinated behavior across platforms

This turns Forge into a multi-channel intelligence system.

***

### Common Integration Examples

Here are a few ways APIs are already used inside Forge:

#### Telegram

* Track when known wallets join groups
* Monitor messages in target chats for keywords
* Flag new deployers who joined high-risk groups

#### Twitter

* Scan tweets from influencers
* Track hashtags tied to new coins
* Monitor followers of known dev wallets

#### CoinGecko / Price APIs

* Pull current SOL price
* Compare market cap to USD
* Use real-world benchmarks in risk scoring

#### TradingView or Custom Signal Feed

* Check if a coin has crossed RSI thresholds
* Pull volume metrics for major listings

### Handling Rate Limits and Failures

Make sure your API code:

* Handles timeouts and bad responses
* Uses caching if data doesn’t change frequently
* Respects rate limits from the source

You don’t want your agents to crash just because a server is slow.

***

### Secure API Keys

If using services that require API keys:

* Store keys in `.env`
* Never log them or inject them into prompts
* Use proxy services if needed to obscure source

Example:

```
iniCopyEditTWITTER_API_KEY=xxxxx
```

Inside your code:

```ts
tsCopyEditconst headers = {
  Authorization: `Bearer ${process.env.TWITTER_API_KEY}`
}
```

***

### Best Practices

* Keep off-chain data short and relevant in the prompt
* Timestamp everything, especially when correlating with blockchain events
* Sanitize and label external content clearly
* Don’t overload your prompt with unnecessary noise

Remember, the goal is to make the AI **smarter**, not just feed it more data.


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.forgeonchain.ai/integrating-external-apis.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
