Installation
Requires Node.js 18+ (uses native fetch). TypeScript 5.4+ recommended for type checking.
Initialize the Client
import { Rulebook } from "rulebook-sdk" ;
const client = new Rulebook ({ apiKey: "your-api-key" });
Or set the RULEBOOK_API_KEY environment variable and omit the parameter:
export RULEBOOK_API_KEY = "your-api-key"
import { Rulebook } from "rulebook-sdk" ;
const client = new Rulebook (); // reads from RULEBOOK_API_KEY
You can also override the base URL via the RULEBOOK_BASE_URL environment variable:
export RULEBOOK_BASE_URL = "https://your-custom-endpoint/api/v1"
List Exchanges
const response = await client . exchanges . list ();
for ( const ex of response . data ) {
console . log ( ` ${ ex . name } ( ${ ex . display_name } )` );
console . log ( ` Fee types: ${ ex . fee_types } ` );
console . log ( ` Records: ${ ex . record_count } ` );
}
console . log ( `Total exchanges: ${ response . meta . record_count } ` );
Response type: ExchangeListResponse
Field Type Description dataExchange[]Array of exchange objects metaMetaResponse metadata
Field Type Description namestringExchange identifier (e.g., nasdaq) display_namestringHuman-readable name fee_typesstring[]Available fee types record_countnumberTotal fee schedule records
Field Type Description record_countnumberTotal number of exchanges returned query_time_msnumberServer-side query execution time (ms)
Get Exchange Details
const response = await client . exchanges . retrieve ( "nasdaq" );
const detail = response . data ;
console . log ( `Date range: ${ detail . date_range . earliest } to ${ detail . date_range . latest } ` );
console . log ( `Actions: ${ detail . actions } ` );
console . log ( `Participants: ${ detail . participants } ` );
console . log ( `Fee categories: ${ detail . fee_categories } ` );
console . log ( `Query time: ${ response . meta . query_time_ms } ms` );
Response type: ExchangeDetailResponse
Field Type Description dataExchangeDetailExchange detail object metaMetaResponse metadata
Show ExchangeDetail fields
Field Type Description namestringExchange identifier display_namestringHuman-readable name date_rangeDateRange.earliest and .latest (YYYY-MM-DD)fee_typesstring[]Available fee types fee_categoriesstring[]Available fee categories actionsstring[]Available trading actions participantsstring[]Available participant types symbol_classificationsstring[]Available symbol classifications symbol_typesstring[]Available symbol types trade_typesstring[]Available trade types
Field Type Description record_countnumberNumber of records for this exchange query_time_msnumberServer-side query execution time (ms)
List Fee Schedule Results
const page = await client . feeScheduleResults . list ({
exchange_name: [ "nasdaq" ],
fee_type: [ "option" ],
fee_participant: [ "market_maker" ],
latest_only: true ,
page_size: 10 ,
});
console . log ( `Total results: ${ page . meta . record_count } ` );
for ( const result of page . data ) {
console . log ( ` ${ result . fee_action } : ${ result . fee_amount } ( ${ result . fee_symbol_type } )` );
}
Response type: PaginatedResponse<FeeScheduleResult>
Field Type Description dataFeeScheduleResult[]Array of result objects metaMetaPagination metadata
Show FeeScheduleResult fields (data)
Field Type Description record_idstringUnique identifier (UUID) exchange_namestringExchange identifier (e.g., nasdaq) scraped_timestringWhen the fee schedule was scraped (ISO 8601) version_idstringExtraction version UUID fee_typestringFee type (option, equity) source_documentstring | nullSource document name (with include_source) source_linkstring | nullSource document URL (with include_source) page_numbernumber | nullPage in source doc (with include_source) fee_categorystringFee category fee_charge_typestringFee or rebate charge type fee_amountstringFee/rebate amount fee_actionstringTrading action (make, take, open, routed, other) fee_action_detailsstring | nullAdditional action details fee_basisstring | nullBasis for fee calculation fee_participantstringMarket participant type fee_participant_detailsstring | nullParticipant classification details fee_monthly_volumestring | nullVolume threshold for tiered pricing fee_monthly_volume_criteriastring | nullVolume tier criteria fee_symbol_classificationstring | nullSymbol classification fee_symbol_typestring | nullPenny/Non-Penny classification fee_trade_typestring | nullTrade type fee_symbolstring | nullSpecific symbol(s) fee_excluded_symbolsstring | nullExcluded symbols fee_conditionsstring | nullConditions for this fee fee_exclusionsstring | nullExclusion scenarios fee_notesstring | nullAdditional notes fee_extra_infostring | nullAdditional information relationshipsobject | nullFootnotes and definitions (with include_footnotes/include_definitions)
Field Type Description record_countnumberTotal records matching the query total_pagesnumberTotal number of pages current_pagenumberCurrent page number (0-indexed) page_sizenumberRecords per page query_time_msnumber | nullQuery execution time in milliseconds
Filter parameters:
Parameter Type Description exchange_namestring[]Filter by exchange name(s) fee_typestring[]Filter by fee type(s) fee_categorystring[]Filter by fee category(s) fee_actionstring[]Filter by trading action(s) fee_participantstring[]Filter by participant type(s) fee_symbol_classificationstring[]Filter by symbol classification(s) fee_symbol_typestring[]Filter by symbol type(s) fee_trade_typestring[]Filter by trade type(s) start_datestringFilter by scraped date (YYYY-MM-DD) end_datestringFilter by scraped date (YYYY-MM-DD) latest_onlybooleanOnly latest version per exchange order_bystringSort field (default: created_on) order_dirstringSort direction: asc or desc page_sizenumberRecords per page (1–100) page_numbernumberPage number (0-indexed) include_footnotesbooleanInclude related footnotes include_definitionsbooleanInclude related definitions include_sourcebooleanInclude source document info
Get a Single Fee Schedule Result
const response = await client . feeScheduleResults . retrieve (
"a3d76e96-0cad-4ece-9db1-7ad3c743bdf8" ,
{ include_footnotes: true , include_definitions: true , include_source: true }
);
const result = response . data ;
console . log ( ` ${ result . exchange_name } — ${ result . fee_type } — ${ result . fee_category } ` );
console . log ( ` Action: ${ result . fee_action } ` );
console . log ( ` Amount: ${ result . fee_amount } ` );
console . log ( ` Participant: ${ result . fee_participant } ` );
console . log ( `Query time: ${ response . meta . query_time_ms } ms` );
Response type: FeeScheduleResultResponse
Field Type Description dataFeeScheduleResultFee schedule result object metaMetaResponse metadata
Show FeeScheduleResult fields (data)
Field Type Description record_idstringUnique identifier (UUID) exchange_namestringExchange identifier (e.g., nasdaq) scraped_timestringWhen the fee schedule was scraped (ISO 8601) version_idstringExtraction version UUID fee_typestringFee type (option, equity) source_documentstring | nullSource document name (with include_source) source_linkstring | nullSource document URL (with include_source) page_numbernumber | nullPage in source doc (with include_source) fee_categorystringFee category fee_charge_typestringFee or rebate charge type fee_amountstringFee/rebate amount fee_actionstringTrading action (make, take, open, routed, other) fee_action_detailsstring | nullAdditional action details fee_basisstring | nullBasis for fee calculation fee_participantstringMarket participant type fee_participant_detailsstring | nullParticipant classification details fee_monthly_volumestring | nullVolume threshold for tiered pricing fee_monthly_volume_criteriastring | nullVolume tier criteria fee_symbol_classificationstring | nullSymbol classification fee_symbol_typestring | nullPenny/Non-Penny classification fee_trade_typestring | nullTrade type fee_symbolstring | nullSpecific symbol(s) fee_excluded_symbolsstring | nullExcluded symbols fee_conditionsstring | nullConditions for this fee fee_exclusionsstring | nullExclusion scenarios fee_notesstring | nullAdditional notes fee_extra_infostring | nullAdditional information relationshipsRelationships | nullFootnotes and definitions (with include_footnotes/include_definitions)
Field Type Description record_countnumberAlways 1 for a single result query_time_msnumberServer-side query execution time (ms)
Get Available Filters
Discover valid filter values before querying results:
const response = await client . feeScheduleResults . getFilters ();
const filters = response . data ;
console . log ( `Exchanges: ${ filters . exchange_names } ` );
console . log ( `Fee types: ${ filters . fee_types } ` );
console . log ( `Categories: ${ filters . fee_categories } ` );
console . log ( `Actions: ${ filters . fee_actions } ` );
console . log ( `Participants: ${ filters . fee_participants } ` );
console . log ( `Total records: ${ response . meta . record_count } ` );
// Narrow filters to specific exchanges
const nasdaqFilters = await client . feeScheduleResults . getFilters ({
exchange_name: [ "nasdaq" , "nasdaq_phlx" ],
});
Response type: FeeScheduleResultFiltersResponse
Field Type Description dataFeeScheduleResultFiltersFilter values object metaMetaResponse metadata
Show FeeScheduleResultFilters fields (data)
Field Type Description exchange_namesstring[]Available exchange names fee_typesstring[]Available fee types fee_categoriesstring[]Available fee categories fee_actionsstring[]Available trading actions fee_participantsstring[]Available participant types fee_symbol_classificationsstring[]Available symbol classifications fee_symbol_typesstring[]Available symbol types fee_trade_typesstring[]Available trade types
Field Type Description record_countnumberTotal fee schedule records across filtered exchanges query_time_msnumberServer-side query execution time (ms)
Get Results by Version
Retrieve all fee schedule results from a specific extraction version:
const page = await client . feeScheduleResults . getResultsByVersion (
"b962c0b1-5d99-4ef6-b3f6-36cb18c08933" ,
{ include_source: true , include_footnotes: true , page_size: 50 },
);
console . log ( `Version has ${ page . meta . record_count } results ( ${ page . meta . total_pages } pages)` );
for ( const result of page . data ) {
console . log ( ` ${ result . fee_action } : ${ result . fee_amount } ` );
if ( result . source_document ) {
console . log ( ` Source: ${ result . source_document } (p. ${ result . page_number } )` );
}
}
Response type: PaginatedResponse<FeeScheduleResult>
Field Type Description dataFeeScheduleResult[]Array of result objects metaMetaPagination metadata
Show FeeScheduleResult fields (data)
Field Type Description record_idstringUnique identifier (UUID) exchange_namestringExchange identifier (e.g., nasdaq) scraped_timestringWhen the fee schedule was scraped (ISO 8601) version_idstringExtraction version UUID fee_typestringFee type (option, equity) source_documentstring | nullSource document name (with include_source) source_linkstring | nullSource document URL (with include_source) page_numbernumber | nullPage in source doc (with include_source) fee_categorystringFee category fee_charge_typestringFee or rebate charge type fee_amountstringFee/rebate amount fee_actionstringTrading action (make, take, open, routed, other) fee_action_detailsstring | nullAdditional action details fee_basisstring | nullBasis for fee calculation fee_participantstringMarket participant type fee_participant_detailsstring | nullParticipant classification details fee_monthly_volumestring | nullVolume threshold for tiered pricing fee_monthly_volume_criteriastring | nullVolume tier criteria fee_symbol_classificationstring | nullSymbol classification fee_symbol_typestring | nullPenny/Non-Penny classification fee_trade_typestring | nullTrade type fee_symbolstring | nullSpecific symbol(s) fee_excluded_symbolsstring | nullExcluded symbols fee_conditionsstring | nullConditions for this fee fee_exclusionsstring | nullExclusion scenarios fee_notesstring | nullAdditional notes fee_extra_infostring | nullAdditional information relationshipsobject | nullFootnotes and definitions (with include_footnotes/include_definitions)
Field Type Description record_countnumberTotal records in this version total_pagesnumberTotal number of pages current_pagenumberCurrent page number (0-indexed) page_sizenumberRecords per page query_time_msnumber | nullQuery execution time in milliseconds
Fee schedule results are paginated. Use page_number and page_size to iterate:
let page_number = 0 ;
let totalFetched = 0 ;
while ( true ) {
const page = await client . feeScheduleResults . list ({
latest_only: true ,
page_size: 50 ,
page_number ,
});
totalFetched += page . data . length ;
console . log ( `Page ${ page_number + 1 } / ${ page . meta . total_pages } : ${ page . data . length } results` );
if ( page_number >= page . meta . total_pages - 1 ) break ;
page_number ++ ;
}
console . log ( `Fetched ${ totalFetched } of ${ page . meta . record_count } total results` );
Async by Default
The TypeScript SDK is async-native — all methods return a Promise and are designed for
async/await usage. Unlike the Python SDK which provides separate Rulebook and
AsyncRulebook clients, there is no separate sync client.
import { Rulebook } from "rulebook-sdk" ;
async function main () {
const client = new Rulebook ({ apiKey: "your-api-key" });
const exchanges = await client . exchanges . list ();
const detail = await client . exchanges . retrieve ( "nasdaq" );
}
main ();
Next Steps
Error Handling Handle API errors with typed exceptions
Advanced Usage Timeouts, retries, raw responses, and per-request overrides