response-formats

command
v2.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Command response-formats demonstrates the *Response value every context-first SDK method returns alongside its typed data — the part most examples discard with a blank identifier.

It covers four things the other examples never touch:

  • the CSV facet (client.Stocks.AsCSV() and friends), which asks the API for format=csv and hands back the raw text
  • the format predicates (IsJSON / IsCSV / IsHTML)
  • Response.Body(), the raw payload as the API sent it
  • Response.SaveToFile(), which writes that payload straight to disk

It also shows the correct way to total API credits for a session: sum resp.RateLimit.Consumed across your own calls. client.RateLimits() is a snapshot of the last completed response, so its Consumed field is what that single request cost — not a running total. The other examples' footers say so and point here.

Usage:

go run ./examples/response-formats [-symbol AAPL] [-outdir /tmp/md]

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL