sec_api 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.devcontainer/Dockerfile +54 -0
- data/.devcontainer/README.md +178 -0
- data/.devcontainer/devcontainer.json +46 -0
- data/.devcontainer/docker-compose.yml +28 -0
- data/.devcontainer/post-create.sh +51 -0
- data/.devcontainer/post-start.sh +44 -0
- data/.rspec +3 -0
- data/.standard.yml +3 -0
- data/CHANGELOG.md +5 -0
- data/CLAUDE.md +0 -0
- data/LICENSE.txt +21 -0
- data/MIGRATION.md +274 -0
- data/README.md +370 -0
- data/Rakefile +10 -0
- data/config/secapi.yml.example +57 -0
- data/docs/development-guide.md +291 -0
- data/docs/enumerator_pattern_design.md +483 -0
- data/docs/examples/README.md +58 -0
- data/docs/examples/backfill_filings.rb +419 -0
- data/docs/examples/instrumentation.rb +583 -0
- data/docs/examples/query_builder.rb +308 -0
- data/docs/examples/streaming_notifications.rb +491 -0
- data/docs/index.md +244 -0
- data/docs/migration-guide-v1.md +1091 -0
- data/docs/pre-review-checklist.md +145 -0
- data/docs/project-overview.md +90 -0
- data/docs/project-scan-report.json +60 -0
- data/docs/source-tree-analysis.md +190 -0
- data/lib/sec_api/callback_helper.rb +49 -0
- data/lib/sec_api/client.rb +606 -0
- data/lib/sec_api/collections/filings.rb +267 -0
- data/lib/sec_api/collections/fulltext_results.rb +86 -0
- data/lib/sec_api/config.rb +590 -0
- data/lib/sec_api/deep_freezable.rb +42 -0
- data/lib/sec_api/errors/authentication_error.rb +24 -0
- data/lib/sec_api/errors/configuration_error.rb +5 -0
- data/lib/sec_api/errors/error.rb +75 -0
- data/lib/sec_api/errors/network_error.rb +26 -0
- data/lib/sec_api/errors/not_found_error.rb +23 -0
- data/lib/sec_api/errors/pagination_error.rb +28 -0
- data/lib/sec_api/errors/permanent_error.rb +29 -0
- data/lib/sec_api/errors/rate_limit_error.rb +57 -0
- data/lib/sec_api/errors/reconnection_error.rb +34 -0
- data/lib/sec_api/errors/server_error.rb +25 -0
- data/lib/sec_api/errors/transient_error.rb +28 -0
- data/lib/sec_api/errors/validation_error.rb +23 -0
- data/lib/sec_api/extractor.rb +122 -0
- data/lib/sec_api/filing_journey.rb +477 -0
- data/lib/sec_api/mapping.rb +125 -0
- data/lib/sec_api/metrics_collector.rb +411 -0
- data/lib/sec_api/middleware/error_handler.rb +250 -0
- data/lib/sec_api/middleware/instrumentation.rb +186 -0
- data/lib/sec_api/middleware/rate_limiter.rb +541 -0
- data/lib/sec_api/objects/data_file.rb +34 -0
- data/lib/sec_api/objects/document_format_file.rb +45 -0
- data/lib/sec_api/objects/entity.rb +92 -0
- data/lib/sec_api/objects/extracted_data.rb +118 -0
- data/lib/sec_api/objects/fact.rb +147 -0
- data/lib/sec_api/objects/filing.rb +197 -0
- data/lib/sec_api/objects/fulltext_result.rb +66 -0
- data/lib/sec_api/objects/period.rb +96 -0
- data/lib/sec_api/objects/stream_filing.rb +194 -0
- data/lib/sec_api/objects/xbrl_data.rb +356 -0
- data/lib/sec_api/query.rb +423 -0
- data/lib/sec_api/rate_limit_state.rb +130 -0
- data/lib/sec_api/rate_limit_tracker.rb +154 -0
- data/lib/sec_api/stream.rb +841 -0
- data/lib/sec_api/structured_logger.rb +199 -0
- data/lib/sec_api/types.rb +32 -0
- data/lib/sec_api/version.rb +42 -0
- data/lib/sec_api/xbrl.rb +220 -0
- data/lib/sec_api.rb +137 -0
- data/sig/sec_api.rbs +4 -0
- metadata +217 -0
data/docs/index.md
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
# sec_api - Project Documentation Index
|
|
2
|
+
|
|
3
|
+
**Generated:** 2026-01-05
|
|
4
|
+
**Scan Level:** Quick
|
|
5
|
+
**Last Updated:** 2026-01-05T03:40:00Z
|
|
6
|
+
|
|
7
|
+
## Project Overview
|
|
8
|
+
|
|
9
|
+
**Name:** sec_api
|
|
10
|
+
**Type:** Ruby Library (Gem)
|
|
11
|
+
**Primary Language:** Ruby 3.2.3
|
|
12
|
+
**Architecture:** Client → Proxy pattern with Faraday middleware
|
|
13
|
+
**Status:** Active development (v0.1.0 → v1.0.0)
|
|
14
|
+
|
|
15
|
+
### Quick Reference
|
|
16
|
+
|
|
17
|
+
- **Purpose:** Production-grade Ruby client for SEC EDGAR filing data via sec-api.io API
|
|
18
|
+
- **Distribution:** RubyGems (rubygems.org)
|
|
19
|
+
- **License:** MIT
|
|
20
|
+
- **Repository:** https://github.com/ljuti/sec_api
|
|
21
|
+
- **Minimum Ruby Version:** 3.1.0+
|
|
22
|
+
|
|
23
|
+
### Technology Stack Summary
|
|
24
|
+
|
|
25
|
+
| Category | Technology | Version | Purpose |
|
|
26
|
+
|----------|-----------|---------|---------|
|
|
27
|
+
| **Language** | Ruby | 3.2.3 | Core language |
|
|
28
|
+
| **HTTP Client** | Faraday | Latest | HTTP requests with middleware |
|
|
29
|
+
| **Configuration** | anyway_config | Latest | YAML + env var config |
|
|
30
|
+
| **Value Objects** | dry-struct | Latest | Immutable, typed responses |
|
|
31
|
+
| **Testing** | RSpec | ~> 3.0 | Test framework |
|
|
32
|
+
| **Linting** | Standard Ruby | ~> 1.3 | Code style enforcement |
|
|
33
|
+
|
|
34
|
+
## Generated Documentation
|
|
35
|
+
|
|
36
|
+
### Core Documentation
|
|
37
|
+
|
|
38
|
+
- **[Project Overview](./project-overview.md)** - Executive summary, tech stack, project classification
|
|
39
|
+
- **[Source Tree Analysis](./source-tree-analysis.md)** - Directory structure, code organization, entry points
|
|
40
|
+
- **[Development Guide](./development-guide.md)** - Setup instructions, development workflow, testing guide
|
|
41
|
+
|
|
42
|
+
### Existing Documentation
|
|
43
|
+
|
|
44
|
+
- **[README](../README.md)** - Quick start, installation, basic usage
|
|
45
|
+
- **[CHANGELOG](../CHANGELOG.md)** - Version history and release notes
|
|
46
|
+
|
|
47
|
+
## Planning Artifacts
|
|
48
|
+
|
|
49
|
+
These comprehensive planning documents guide the v1.0.0 development:
|
|
50
|
+
|
|
51
|
+
### Solutioning Phase (Complete)
|
|
52
|
+
|
|
53
|
+
- **[Product Requirements Document (PRD)](../_bmad-output/planning-artifacts/prd.md)**
|
|
54
|
+
*Complete requirements, user journeys, success criteria, domain-specific requirements*
|
|
55
|
+
|
|
56
|
+
- **[Architecture Decision Document](../_bmad-output/planning-artifacts/architecture.md)**
|
|
57
|
+
*Architectural patterns, error handling strategy, retry/rate limiting, observability design*
|
|
58
|
+
|
|
59
|
+
- **[Epics & Stories](../_bmad-output/planning-artifacts/epics.md)**
|
|
60
|
+
*8 epics broken down into implementation-ready user stories with acceptance criteria*
|
|
61
|
+
|
|
62
|
+
### Implementation Phase (Planned)
|
|
63
|
+
|
|
64
|
+
Sprint planning and story development will be tracked in:
|
|
65
|
+
- `_bmad-output/implementation-artifacts/sprint-status.yaml` _(To be generated)_
|
|
66
|
+
- `_bmad-output/implementation-artifacts/stories/` _(To be generated)_
|
|
67
|
+
|
|
68
|
+
## Project Architecture
|
|
69
|
+
|
|
70
|
+
### Repository Structure
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
sec_api/
|
|
74
|
+
├── lib/sec_api/ # Main library code (Client → Proxy pattern)
|
|
75
|
+
│ ├── client.rb # Entry point
|
|
76
|
+
│ ├── errors/ # Exception hierarchy (TransientError/PermanentError)
|
|
77
|
+
│ ├── middleware/ # Faraday middleware (retry, rate limiting, observability)
|
|
78
|
+
│ ├── collections/ # Collection objects (Filings, etc.)
|
|
79
|
+
│ └── objects/ # Value objects (Filing, Entity, XbrlData)
|
|
80
|
+
├── spec/ # RSpec tests (VCR cassettes, shared examples)
|
|
81
|
+
├── config/ # Configuration files (YAML + env vars)
|
|
82
|
+
└── _bmad-output/ # Planning artifacts
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Key Architectural Patterns
|
|
86
|
+
|
|
87
|
+
**Client → Proxy Pattern:**
|
|
88
|
+
```ruby
|
|
89
|
+
client = SecApi::Client.new
|
|
90
|
+
client.query # Query API proxy
|
|
91
|
+
client.mapping # Mapping API proxy (ticker/CIK resolution)
|
|
92
|
+
client.extractor # Extractor API proxy
|
|
93
|
+
client.xbrl # XBRL API proxy (financial data extraction)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Exception Hierarchy:**
|
|
97
|
+
- `SecApi::Error` (base)
|
|
98
|
+
- `TransientError` - Automatic retry (rate limits, network errors, server errors)
|
|
99
|
+
- `PermanentError` - Fail immediately (authentication, not found, validation)
|
|
100
|
+
|
|
101
|
+
**Middleware Stack:**
|
|
102
|
+
```
|
|
103
|
+
Request → Instrumentation → Retry → RateLimiter → ErrorHandler → Adapter → sec-api.io
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Development Roadmap
|
|
107
|
+
|
|
108
|
+
### v0.1.0 (Current)
|
|
109
|
+
- ✅ Basic query, search, mapping, extractor endpoints
|
|
110
|
+
- ✅ Configuration via anyway_config
|
|
111
|
+
- ✅ Immutable value objects (Dry::Struct)
|
|
112
|
+
- ⚠️ Issues: Orphaned XBRL endpoint, inconsistent response wrapping, generic exceptions
|
|
113
|
+
|
|
114
|
+
### v1.0.0 (Target)
|
|
115
|
+
- 🚧 **Epic 1:** Foundation & production-grade error handling
|
|
116
|
+
- Exception hierarchy (TransientError/PermanentError)
|
|
117
|
+
- Enhanced retry middleware with exponential backoff
|
|
118
|
+
- Thread-safe response objects
|
|
119
|
+
- Wire up orphaned XBRL proxy
|
|
120
|
+
|
|
121
|
+
- 🚧 **Epic 2:** Query and search SEC filings
|
|
122
|
+
- Fluent query builder DSL
|
|
123
|
+
- Automatic pagination with `.auto_paginate`
|
|
124
|
+
- International filing support (20-F, 40-F, 6-K)
|
|
125
|
+
|
|
126
|
+
- 🚧 **Epic 3:** Entity mapping and resolution
|
|
127
|
+
- Ticker ↔ CIK resolution
|
|
128
|
+
- CUSIP and company name lookups
|
|
129
|
+
|
|
130
|
+
- 🚧 **Epic 4:** XBRL data extraction with validation
|
|
131
|
+
- Heuristic XBRL validation
|
|
132
|
+
- US GAAP and IFRS taxonomy support
|
|
133
|
+
|
|
134
|
+
- 🚧 **Epic 5:** Rate limiting intelligence
|
|
135
|
+
- Proactive header tracking
|
|
136
|
+
- Automatic throttling and request queueing
|
|
137
|
+
|
|
138
|
+
- 🚧 **Epic 6:** Real-time filing notifications
|
|
139
|
+
- WebSocket streaming API
|
|
140
|
+
- Ticker/form-type filtering
|
|
141
|
+
- <2 minute delivery latency
|
|
142
|
+
|
|
143
|
+
- 🚧 **Epic 7:** Observability and production monitoring
|
|
144
|
+
- Instrumentation callbacks
|
|
145
|
+
- Structured logging with correlation IDs
|
|
146
|
+
- Metrics exposure
|
|
147
|
+
|
|
148
|
+
- 🚧 **Epic 8:** Documentation and developer experience
|
|
149
|
+
- 100% YARD documentation coverage
|
|
150
|
+
- Migration guide (v0.1.0 → v1.0.0)
|
|
151
|
+
- Usage examples
|
|
152
|
+
|
|
153
|
+
## Getting Started
|
|
154
|
+
|
|
155
|
+
### For Developers Using This Gem
|
|
156
|
+
|
|
157
|
+
See **[README](../README.md)** for:
|
|
158
|
+
- Installation instructions
|
|
159
|
+
- Basic usage examples
|
|
160
|
+
- Configuration guide
|
|
161
|
+
|
|
162
|
+
### For Contributors
|
|
163
|
+
|
|
164
|
+
See **[Development Guide](./development-guide.md)** for:
|
|
165
|
+
- Setup instructions
|
|
166
|
+
- Development workflow
|
|
167
|
+
- Testing strategy
|
|
168
|
+
- Code style guidelines
|
|
169
|
+
|
|
170
|
+
### For Product/Technical Understanding
|
|
171
|
+
|
|
172
|
+
See **[PRD](../_bmad-output/planning-artifacts/prd.md)** for:
|
|
173
|
+
- Vision and success criteria
|
|
174
|
+
- User journeys
|
|
175
|
+
- Complete functional and non-functional requirements
|
|
176
|
+
- Domain-specific requirements (fintech, SEC filings)
|
|
177
|
+
|
|
178
|
+
See **[Architecture](../_bmad-output/planning-artifacts/architecture.md)** for:
|
|
179
|
+
- Architectural decisions and rationale
|
|
180
|
+
- Implementation patterns and consistency rules
|
|
181
|
+
- Error handling, retry, rate limiting strategies
|
|
182
|
+
- Observability and instrumentation design
|
|
183
|
+
|
|
184
|
+
## Key Features (Planned for v1.0.0)
|
|
185
|
+
|
|
186
|
+
### Production-Grade Infrastructure
|
|
187
|
+
- ✅ Automatic retry with exponential backoff (configurable)
|
|
188
|
+
- ✅ Exception hierarchy distinguishing transient vs permanent errors
|
|
189
|
+
- 🚧 Intelligent rate limiting with proactive throttling
|
|
190
|
+
- 🚧 Request queueing when rate limits are reached
|
|
191
|
+
- 🚧 Production observability hooks for monitoring tools
|
|
192
|
+
|
|
193
|
+
### Developer Experience
|
|
194
|
+
- 🚧 Fluent query builder DSL (ActiveRecord-style chaining)
|
|
195
|
+
- 🚧 Automatic pagination - memory-efficient backfill operations
|
|
196
|
+
- 🚧 Comprehensive YARD documentation (100% coverage)
|
|
197
|
+
- 🚧 VCR test fixtures for offline-runnable tests
|
|
198
|
+
- 🚧 Migration guide for v0.1.0 → v1.0.0 upgrade
|
|
199
|
+
|
|
200
|
+
### SEC Filing Coverage
|
|
201
|
+
- 🚧 Query by ticker, CIK, form type, date range
|
|
202
|
+
- 🚧 International filings (20-F, 40-F, 6-K for foreign/Canadian issuers)
|
|
203
|
+
- 🚧 Real-time filing notifications via WebSocket (<2 min latency)
|
|
204
|
+
- 🚧 XBRL extraction with validation (US GAAP + IFRS)
|
|
205
|
+
- 🚧 Entity mapping (ticker ↔ CIK, CUSIP, company name resolution)
|
|
206
|
+
|
|
207
|
+
## Workflow Integration
|
|
208
|
+
|
|
209
|
+
### For Brownfield PRD Creation
|
|
210
|
+
|
|
211
|
+
When planning new features for this project:
|
|
212
|
+
|
|
213
|
+
1. **Reference this documentation index** as the project context
|
|
214
|
+
2. **Use PRD as requirements baseline** for understanding existing scope
|
|
215
|
+
3. **Use Architecture for technical constraints** and established patterns
|
|
216
|
+
4. **Use Epics for implementation roadmap** and story structure
|
|
217
|
+
|
|
218
|
+
### For Implementation Work
|
|
219
|
+
|
|
220
|
+
When implementing stories from the Epics document:
|
|
221
|
+
|
|
222
|
+
1. **Follow architectural patterns** defined in Architecture document
|
|
223
|
+
2. **Use Development Guide** for setup and workflow
|
|
224
|
+
3. **Reference Source Tree Analysis** for code organization
|
|
225
|
+
4. **Maintain consistency** with established naming and structure patterns
|
|
226
|
+
|
|
227
|
+
## Contact & Support
|
|
228
|
+
|
|
229
|
+
- **Author:** Lauri Jutila
|
|
230
|
+
- **Email:** git@laurijutila.com
|
|
231
|
+
- **GitHub:** https://github.com/ljuti/sec_api
|
|
232
|
+
- **Issues:** https://github.com/ljuti/sec_api/issues
|
|
233
|
+
|
|
234
|
+
## License
|
|
235
|
+
|
|
236
|
+
MIT License - See [LICENSE.txt](../LICENSE.txt)
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
**Documentation Scan Details:**
|
|
241
|
+
- **Scan Type:** Initial Quick Scan
|
|
242
|
+
- **Scan Date:** 2026-01-05
|
|
243
|
+
- **Workflow:** BMAD document-project workflow
|
|
244
|
+
- **Status File:** [project-scan-report.json](./project-scan-report.json)
|