# Best Practices

## 1. Use Caching Where Data Does Not Need Real-Time Refresh

Cache responses when second-by-second updates are unnecessary.

Recommended for:

* Token metadata
* Historical market data
* Token directory queries
* Slow-changing holder metrics

Benefits:

* Lower request volume
* Faster app performance
* Reduced costs
* Better rate-limit efficiency

***

## 2. Batch Requests for Multiple Assets

When querying multiple tokens, send batched requests where supported.

Use comma-separated:

* token\_ids
* token\_tickers
* token\_addresses

Recommended batch size:

```
Up to 30 assets per request
```

Benefits:

* Lower network overhead
* Faster scans
* Cleaner workflows

***

## 3. Use Real-Time Polling Selectively

Poll high-frequency endpoints only where freshness matters.

Examples:

* Perp Intelligence
* Trending Tokens
* Smart Money Trends

Use slower refresh intervals for:

* Token Directory
* Historical Data
* Staking Metrics

***

## 4. Handle Errors Gracefully

Always inspect HTTP status codes and implement retry logic.

Common responses:

| Code | Meaning                           | Recommended Action             |
| ---- | --------------------------------- | ------------------------------ |
| 400  | Bad request                       | Validate parameters            |
| 401  | Unauthorized                      | Check API key / auth           |
| 402  | Payment required                  | Complete x402 payment flow     |
| 423  | Temporarily locked / rate limited | Retry with backoff             |
| 429  | Too many requests                 | Slow down request rate         |
| 500+ | Server issue                      | Retry with exponential backoff |

***

## 5. Implement Retries with Backoff

For temporary failures:

* exponential backoff
* jittered retries
* capped retry count

Avoid aggressive retry loops.

***

## 6. Use the Right Access Model

### API Keys

Best for:

* dashboards
* apps
* predictable workloads

### x402 Payments

Best for:

* AI agents
* bots
* dynamic usage
* pay-per-call workloads

***

## 7. Separate Core Data from Intelligence Calls

Use lower-frequency refresh for:

* Token Directory
* Historical Market Data

Use higher-frequency refresh for:

* Perp Intelligence
* Smart Money Trends
* Trending Tokens

This improves efficiency.

***

## 8. Design for Schema Stability

Use typed parsers and version-safe wrappers.

Do not hardcode assumptions beyond documented fields.

***

## 9. Monitor Usage and Limits

Track:

* request volume
* latency
* error rates
* payment failures
* rate-limit events

Reach out to DappLooker for higher limits or enterprise throughput.

***

## 10. Stay Updated

Check docs regularly for:

* new endpoints
* schema upgrades
* additional supported chains
* new DEX integrations
* new agent tools

***

## Pro Tip for AI Agents

Use direct APIs for deterministic outputs and MCP / NLP APIs for flexible reasoning workflows.


---

# 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.dapplooker.com/resources/best-practices.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.
