SecioEx.StreamApi (secio_ex v0.1.0)
A WebSocket client for streaming SEC (Securities and Exchange Commission) filing data in real-time using the sec-api.io service.
Example Usage
# Define a custom callback to process 8-K filings
custom_callback = fn
[%{"formType" => form_type, "entities" => entities, "linkToTxt" => link_to_txt}]
when form_type in ["8-K", "8-K/A"] ->
IO.puts("Entities: #{inspect(entities)}")
IO.puts("Form Type: #{form_type}")
IO.puts("Link to HTML: #{link_to_txt}\n\n")
_ ->
IO.puts("Form type not matched or unexpected data structure\n ")
end
# Start the WebSocket connection
{:ok, pid} = SecioEx.StreamApi.sec_stream("your_api_key_here", custom_callback)
Summary
Functions
Internal callback that handles incoming WebSocket messages. Decodes JSON messages and passes them to the specified callback function.
Establishes a WebSocket connection to the SEC API streaming service.
Functions
Internal callback that handles incoming WebSocket messages. Decodes JSON messages and passes them to the specified callback function.
Parameters
{:text, msg}
- Tuple containing the received WebSocket framestate
- Current callback function
Returns
{:ok, state}
- Tuple indicating successful message processing
Establishes a WebSocket connection to the SEC API streaming service.
Parameters
api_key
- Your SEC API authentication keycallback
- Optional function to process incoming messages. Defaults todefault_callback/1
Returns
{:ok, pid}
- On successful connection{:error, term}
- On failure
Example
SecioEx.StreamApi.sec_stream("your_api_key_here")
SecioEx.StreamApi.sec_stream("your_api_key_here", &MyModule.process_filing/1)