Instructions for AI coding agents working on this repository.
Elixir client library for the Taapi.io technical analysis API. Provides typed functions for all 208 indicators with compile-time code generation.
User calls Taapi.rsi(opts)
→ defdelegate to Taapi.Indicators.rsi(opts)
→ Taapi.Client.get("rsi", opts)
→ Req.get() to https://api.taapi.io/rsi
→ {:ok, map()} or {:error, Taapi.Error.t()}
| Module | Purpose | Notes |
|---|---|---|
Taapi |
Public API | Delegates 208 indicator functions + discovery API |
Taapi.Indicators |
Indicator definitions | Uses indicator/2 macro, generates functions at compile time |
Taapi.Indicator |
DSL macro | @before_compile generates functions from @indicator_defs |
Taapi.Delegator |
Delegation macro | Generates defdelegate calls from Taapi to Taapi.Indicators |
Taapi.Client |
HTTP client | Low-level Req wrapper, escape hatch for custom endpoints |
Taapi.Error |
Error struct | Typed errors: :missing_api_key, :rate_limited, etc. |
If Taapi.io adds new indicators:
-
Add to
lib/taapi/indicators.ex:indicator(:new_indicator, endpoint: "new_indicator", description: "Description from Taapi docs", categories: [:category1, :category2] )
-
Run
mix compile- function is auto-generated -
Add integration test to
test/integration/live_test.exsin appropriate category
mix test.json --quiet # Unit tests (JSON output)
mix test --include integration # Integration tests (requires TAAPI_API_KEY)
mix format # Format code
mix credo --strict # Static analysis
mix dialyzer # Type checking
mix doctor # Documentation quality
mix docs # Generate docs- Explicit credentials: All functions require
api_key:option, no env fallback - No global state: Each call is independent
- Multi-tenant safe: Multiple API keys can be used in same app
- All functions return
{:ok, map()} | {:error, Taapi.Error.t()} - HTTP errors mapped to semantic types (
:rate_limited,:unauthorized, etc.) - Raw upstream errors preserved in
details
The indicator/2 macro is idiomatic Elixir for declarative APIs:
- Accumulates definitions via module attribute
@before_compilegenerates functions + metadata- Compile-time validation catches typos
- Single source of truth for 208 indicators
- Test error paths without API calls
- Test delegation and discovery functions
- Run with
mix test.json --quiet
- Require
TAAPI_API_KEYenvironment variable - Tagged with
@moduletag :integration - Excluded by default, run with
mix test --include integration - Handle rate limiting gracefully (log warning, pass test)
| File | Does | Does NOT |
|---|---|---|
Taapi |
Public API, delegation, discovery | HTTP calls, indicator definitions |
Taapi.Indicators |
Indicator definitions only | HTTP logic, error handling |
Taapi.Client |
HTTP requests, response parsing | Indicator knowledge |
Taapi.Error |
Error types and constructors | HTTP or API logic |
- Dialyzer: 0 warnings
- Credo: No issues on
--strict - Doctor: 100% doc coverage (macro modules excluded)
- Tests: All passing
- Format:
mix format --check-formatted