@bytewaveco/public
v1.2.0
Published
A TypeScript compatible library for interacting with the Public API.
Maintainers
Readme
Public API for TypeScript
An unofficial, fully typed TypeScript client for the Public investing API.
This package is not affiliated with Public. API requests use your live Public account, and order methods can execute real trades. Review every order before submitting it.
Install
pnpm add @bytewaveco/publicnpm install @bytewaveco/publicQuickstart
Create a personal API secret in your Public account settings, then create a client:
import { createClient } from '@bytewaveco/public'
const publicClient = createClient(process.env.PUBLIC_API_SECRET!)
const result = await publicClient.accounts.listAccounts()
if (result.error) {
throw result.error
}
console.log(result.data.accounts)Every request returns a discriminated result:
type Result<T> = { data: T; error: null } | { data: null; error: Error }HTTP errors are returned as PublicApiError, which includes the response
status and parsed body.
Client options
const publicClient = createClient(process.env.PUBLIC_API_SECRET!, {
accessTokenValidityInMinutes: 15,
headers: {
'X-Application': 'portfolio-tools',
},
})| Option | Description |
| ------------------------------ | ------------------------------------------------------------------ |
| accessTokenValidityInMinutes | Access-token lifetime from 5 through 1440 minutes. Defaults to 15. |
| baseUrl | Override Public's API base URL. |
| fetch | Supply a custom Fetch API implementation. |
| headers | Add headers to authenticated API requests. |
Access tokens are cached per client and refreshed shortly before expiry. Concurrent requests share the same token refresh.
API surface
Accounts
publicClient.accounts.listAccounts()
publicClient.accounts.getAccount(accountId)
publicClient.accounts.getAccountHistory(accountId, options)Instruments
publicClient.instruments.getInstruments(options)
publicClient.instruments.getInstrument(symbol, type)Instrument filters, trading states, crypto precision, bond details, shorting availability, exchanges, and option price increments are typed.
Market data
publicClient.marketData.getQuotes(accountId, instruments)
publicClient.marketData.getBars(symbol, period, options)Options
publicClient.options.getOptionGreeks(accountId, osiSymbols)
publicClient.options.getOptionExpirations(accountId, instrument)
publicClient.options.getOptionChain(accountId, instrument, expirationDate)
publicClient.options.getStrategyQuote(accountId, strategy)Orders
const orderId = publicClient.orders.createOrderId()
await publicClient.orders.preflightSingleLeg(accountId, order)
await publicClient.orders.preflightMultiLeg(accountId, order)
await publicClient.orders.placeOrder(accountId, { ...order, orderId })
await publicClient.orders.placeOrderMultiLeg(accountId, { ...order, orderId })
await publicClient.orders.replaceOrder(accountId, replacement)
await publicClient.orders.getOrder(accountId, orderId)
await publicClient.orders.cancelOrder(accountId, orderId)Order placement and cancellation are asynchronous. Use getOrder() to verify
the resulting status. Current order types include 24/5 equity sessions, margin
controls, short-sale position intent, stop-limit orders, and hypothetical
preflight validation.
Current coverage
Version 1.2.0 reflects Public's documentation reviewed on July 10, 2026, including historical bars, replace-order, multi-leg strategy quotes, portfolio strategies, option-chain Greeks, and current order controls.
Development
pnpm install
pnpm check
pnpm typecheck
pnpm test
pnpm buildpnpm checkverifies Oxlint and Oxfmt.pnpm lintapplies formatting and safe lint fixes.pnpm testruns the mocked transport tests. Tests do not contact Public or place live orders.
