Apex Ascend SDK
npm install @apexfintechsolutions/ascend-sdkIn today's fast-paced digital ecosystem, developers need tools that not only streamline the development process but also unlock new possibilities for innovation and efficiency.
Enter the Apex Typescript SDK, a cutting-edge software development kit designed to empower fintech app developers like never before.
With our SDK, you can more easily integrate new account creation, optimize trading, and elevate your applications with realtime buying power, all through a seamless SDK interface.
Whether you're building complex, data-driven platforms or simplified, user-centric applications, Apex Typescript SDK was created to offer the flexibility, power, and ease of use to bring your visions to life faster and more effectively.
Join us in redefining the boundaries of what your applications can achieve.
Start your journey with Apex today.
``bash`
npm add @apexfintechsolutions/ascend-sdk
`bash`
pnpm add @apexfintechsolutions/ascend-sdk
`bash`
bun add @apexfintechsolutions/ascend-sdk
`bash
yarn add @apexfintechsolutions/ascend-sdk zod
Supported JavaScript Runtimes
This SDK is intended to be used in JavaScript runtimes that support the following features:
* [Web Fetch API][web-fetch]
* Web Streams API and in particular
ReadableStream
* [Async iterables][async-iter] using Symbol.asyncIterator[web-fetch]: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
[web-streams]: https://developer.mozilla.org/en-US/docs/Web/API/Streams_API
[async-iter]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols
Runtime environments that are explicitly supported are:
- Evergreen browsers which include: Chrome, Safari, Edge, Firefox
- Node.js active and maintenance LTS releases
- Currently, this is v18 and v20
- Bun v1 and above
- Deno v1.39
- Note that Deno does not currently have native support for streaming file uploads backed by the filesystem ([issue link][deno-file-streaming])
[deno-file-streaming]: https://github.com/denoland/deno/issues/11018
Initializing the SDK
The following sample shows how to initialise the SDK, using the API Key and Service Account Credentials you received during sign-up:
`typescript
import {Apexascend} from "@apexfintechsolutions/ascend-sdk";const apexascend = new Apexascend({
security: {
apiKey: "ABCDEFGHIJ0123456789abcdefghij0123456789",
serviceAccountCreds: {
privateKey: "-----BEGIN PRIVATE KEY--{OMITTED FOR BREVITY}",
name: "FinFirm",
organization: "correspondents/00000000-0000-0000-0000-000000000000",
type: "serviceAccount",
},
},
});
async function run() {
// With an instance of the SDK, invoke any operation e.g.
let resp = await apexascend.accountCreation.getAccount("VALID_ACCOUNT_ID");
console.log(resp);
}
run();
`
Error Handling
ApexascendError is the base class for all HTTP error responses. It has the following properties:| Property | Type | Description |
| ------------------------- | ---------- | --------------------------------------------------------------------------------------- |
|
error.message | string | Error message |
| error.httpMeta.response | Response | HTTP response. Access to headers and more. |
| error.httpMeta.request | Request | HTTP request. Access to headers and more. |
| error.data$ | | Optional. Some errors may contain structured data. See Error Classes. |$3
`typescript
import { Apexascend } from "@apexfintechsolutions/ascend-sdk";
import * as errors from "@apexfintechsolutions/ascend-sdk/models/errors";const apexascend = new Apexascend({
security: {
apiKey: "ABCDEFGHIJ0123456789abcdefghij0123456789",
serviceAccountCreds: {
privateKey: "-----BEGIN PRIVATE KEY--{OMITTED FOR BREVITY}",
name: "FinFirm",
organization: "correspondents/00000000-0000-0000-0000-000000000000",
type: "serviceAccount",
},
},
});
async function run() {
try {
const result = await apexascend.accountCreation.getAccount(
"01HC3MAQ4DR9QN1V8MJ4CN1HMK",
);
console.log(result);
} catch (error) {
// The base class for HTTP error responses
if (error instanceof errors.ApexascendError) {
console.log(error.message);
console.log(error.httpMeta.response.status);
console.log(error.httpMeta.response.headers);
console.log(error.httpMeta.request);
// Depending on the method different errors may be thrown
if (error instanceof errors.Status) {
console.log(error.data$.code); // number
console.log(error.data$.details); // Any[]
console.log(error.data$.message); // string
}
}
}
}
run();
`$3
Primary errors:
* ApexascendError: The base class for HTTP error responses.
* Status: The status message serves as the general-purpose service error message. Each status message includes a gRPC error code, error message, and error details.Less common errors (6)
ConnectionError: HTTP client was unable to make a request to a server.
* RequestTimeoutError: HTTP request timed out due to an AbortSignal signal.
* RequestAbortedError: HTTP request was aborted by the client.
* InvalidRequestError: Any input used to create a request is invalid.
* UnexpectedClientError: Unrecognised or unexpected error.ApexascendError:
* ResponseValidationError: Type mismatch between the data returned from the server and the structure expected by the SDK. See error.rawValue for the raw value and error.pretty() for a nicely formatted multi-line string.
Server Selection
$3
You can override the default server globally by passing a server name to the
server: keyof typeof ServerList optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the names associated with the available servers:| Name | Server | Description |
| ------ | -------------------------- | -------------------------- |
|
uat | https://uat.apexapis.com | our uat environment |
| prod | https://api.apexapis.com | our production environment |
| sbx | https://sbx.apexapis.com | our sandbox environment |#### Example
`typescript
import { Apexascend } from "@apexfintechsolutions/ascend-sdk";const apexascend = new Apexascend({
server: "sbx",
security: {
apiKey: "ABCDEFGHIJ0123456789abcdefghij0123456789",
serviceAccountCreds: {
privateKey: "-----BEGIN PRIVATE KEY--{OMITTED FOR BREVITY}",
name: "FinFirm",
organization: "correspondents/00000000-0000-0000-0000-000000000000",
type: "serviceAccount",
},
},
});
async function run() {
const result = await apexascend.accountCreation.getAccount(
"01HC3MAQ4DR9QN1V8MJ4CN1HMK",
);
console.log(result);
}
run();
`$3
The default server can also be overridden globally by passing a URL to the
serverURL: string optional parameter when initializing the SDK client instance. For example:
`typescript
import { Apexascend } from "@apexfintechsolutions/ascend-sdk";const apexascend = new Apexascend({
serverURL: "https://uat.apexapis.com",
security: {
apiKey: "ABCDEFGHIJ0123456789abcdefghij0123456789",
serviceAccountCreds: {
privateKey: "-----BEGIN PRIVATE KEY--{OMITTED FOR BREVITY}",
name: "FinFirm",
organization: "correspondents/00000000-0000-0000-0000-000000000000",
type: "serviceAccount",
},
},
});
async function run() {
const result = await apexascend.accountCreation.getAccount(
"01HC3MAQ4DR9QN1V8MJ4CN1HMK",
);
console.log(result);
}
run();
`
Custom HTTP Client
The TypeScript SDK makes API calls using an
HTTPClient that wraps the native
Fetch API. This
client is a thin wrapper around fetch and provides the ability to attach hooks
around the request lifecycle that can be used to modify the request or handle
errors and response.The
HTTPClient constructor takes an optional fetcher argument that can be
used to integrate a third-party HTTP client or when writing tests to mock out
the HTTP client and feed in fixtures.The following example shows how to use the
"beforeRequest" hook to to add a
custom header and a timeout to requests and how to use the "requestError" hook
to log errors:`typescript
import { Apexascend } from "@apexfintechsolutions/ascend-sdk";
import { HTTPClient } from "@apexfintechsolutions/ascend-sdk/lib/http";const httpClient = new HTTPClient({
// fetcher takes a function that has the same signature as native
fetch.
fetcher: (request) => {
return fetch(request);
}
});httpClient.addHook("beforeRequest", (request) => {
const nextRequest = new Request(request, {
signal: request.signal || AbortSignal.timeout(5000)
});
nextRequest.headers.set("x-custom-header", "custom value");
return nextRequest;
});
httpClient.addHook("requestError", (error, request) => {
console.group("Request Error");
console.log("Reason:",
${error});
console.log("Endpoint:", ${request.method} ${request.url});
console.groupEnd();
});const sdk = new Apexascend({ httpClient });
`
Available Resources and Operations
Available methods
$3
* createAccount - Create Account
* getAccount - Get Account
$3
* listAccounts - List Accounts
* updateAccount - Update Account
* addParty - Add Party
* updateParty - Update Party
* replaceParty - Replace Party
* removeParty - Remove Party
* closeAccount - Close Account
* createTrustedContact - Create Trusted Contact
* updateTrustedContact - Update Trusted Contact
* deleteTrustedContact - Delete Trusted Contact
* createInterestedParty - Create Interested Party
* updateInterestedParty - Update Interested Party
* deleteInterestedParty - Delete Interested Party
* listAvailableRestrictions - List Available Restrictions
* createRestriction - Create Restriction
* endRestriction - End Restriction
$3
* createTransfer - Create Transfer
* listTransfers - List Transfers
* acceptTransfer - Accept Transfer
* rejectTransfer - Reject Transfer
* getTransfer - Get Transfer
$3
* createAchDeposit - Create ACH Deposit
* getAchDeposit - Get ACH Deposit
* cancelAchDeposit - Cancel ACH Deposit
* createAchWithdrawal - Create ACH Withdrawal
* getAchWithdrawal - Get ACH Withdrawal
* cancelAchWithdrawal - Cancel ACH Withdrawal
$3
* listAssets - List Assets
* getAsset - Get Asset
* listAssetsCorrespondent - List Assets (By Correspondent)
* getAssetCorrespondent - Get Asset (By Correspondent)
$3
* getAssetTradingConfig - Get Asset Trading Config
* listAssetTradingConfigs - List Asset Trading Configs
$3
* generateServiceAccountToken - Generate Service Account Token
* listSigningKeys - List Signing Keys
$3
* createBankRelationship - Create Bank Relationship
* listBankRelationships - List Bank Relationships
* getBankRelationship - Get Bank Relationship
* updateBankRelationship - Update Bank Relationship
* cancelBankRelationship - Cancel Bank Relationship
* verifyMicroDeposits - Verify Micro Deposits
* reissueMicroDeposits - Reissue Micro Deposits
* reuseBankRelationship - Reuse Bank Relationship
$3
* createBasket - Create Basket
* addOrders - Add Orders
* getBasket - Get Basket
* submitBasket - Submit Basket
* listBasketOrders - List Basket Orders
* listCompressedOrders - List Compressed Orders
* removeOrders - Remove Basket Orders
* setExtraReportingData - Set Extra Reporting Data
$3
* calculateCashBalance - Get Cash Balance
$3
* getCheckDeposit - Get Check Deposit
$3
* listSnapshots - List Snapshots
$3
* enrollAccount - Enroll Account
* listAvailableEnrollments - List Available Enrollments
* accountsListAvailableEnrollmentsByAccountGroup - List Available Enrollments (by Account Group)
* deactivateEnrollment - Deactivate Enrollment
* listEnrollments - List Account Enrollments
* affirmAgreements - Affirm Agreements
* listAgreements - List Account Agreements
* listEntitlements - List Account Entitlements
$3
* createFee - Create Fee
* getFee - Get Fee
* cancelFee - Cancel Fee
* createCredit - Create Credit
* getCredit - Get Credit
* cancelCredit - Cancel Credit
$3
* previewOrderCost - Preview Order Cost
* retrieveQuote - Retrieve Quote
* retrieveFixedIncomeMarks - Retrieve Fixed Income Marks
$3
* createIctDeposit - Create ICT Deposit
* getIctDeposit - Get ICT Deposit
* cancelIctDeposit - Cancel ICT Deposit
* createIctWithdrawal - Create ICT Withdrawal
* getIctWithdrawal - Get ICT Withdrawal
* cancelIctWithdrawal - Cancel ICT Withdrawal
* locateIctReport - Locate ICT Report
$3
* getInvestigation - Get Investigations
* updateInvestigation - Update Investigation
* listInvestigations - List Investigations
* linkDocuments - Link Documents
* getWatchlistItem - Get Watchlist Item
* getCustomerIdentification - Get Identity Verification
* createIdentityLookup - Create Identity Lookup
* verifyIdentityLookup - Verify Identity Lookup
$3
* batchCreateUploadLinks - Batch Create Upload Links
* listDocuments - List Documents
$3
* retrieveCashJournalConstraints - Retrieve Cash Journal Constraints
* createCashJournal - Create Cash Journal
* getCashJournal - Get Cash Journal
* cancelCashJournal - Cancel Cash Journal
* checkPartyType - Retrieve Cash Journal Party
$3
* listEntries - List Entries
* listActivities - List Activities
* listPositions - List Positions
* getActivity - Get Activity
* getEntry - Get Entry
$3
* getBuyingPower - Get Buying Power
$3
* createOrder - Create Order
* getOrder - Get Order
* cancelOrder - Cancel Order
* setExtraReportingData - Set Extra Reporting Data
* listCorrespondentOrders - List Correspondent Orders
$3
* createLegalNaturalPerson - Create Legal Natural Person
* listLegalNaturalPersons - List Legal Natural Persons
* getLegalNaturalPerson - Get Legal Natural Persons
* updateLegalNaturalPerson - Update Legal Natural Person
* assignLargeTrader - Assign Large Trader
* endLargeTraderLegalNaturalPerson - End Large Trader
* createLegalEntity - Create Legal Entity
* listLegalEntities - List Legal Entity
* getLegalEntity - Get Legal Entity
* updateLegalEntity - Update Legal Entity
* assignLargeTraderLegalEntity - Assign Entity Large Trader
* endLargeTrader - End Entity Large Trader
$3
* createPositionJournal - Create Position Journal
* getPositionJournal - Get Position Journal
* cancelPositionJournal - Cancel Position Journal
$3
* listEventMessages - List Event Messages
* getEventMessage - Get Event Message
$3
* listContributionSummaries - List Contribution Summaries
* retrieveContributionConstraints - Retrieve Contribution Constraints
* listDistributionSummaries - List Distribution Summaries
* retrieveDistributionConstraints - Retrieve Distribution Constraints
$3
* listScheduleSummaries - List Schedule Summaries
* createAchDepositSchedule - Create ACH Deposit Schedule
* listAchDepositSchedules - List ACH Deposit Schedules
* getAchDepositSchedule - Get ACH Deposit Schedule
* updateAchDepositSchedule - Update ACH Deposit Schedules
* cancelAchDepositSchedule - Cancel ACH Deposit Schedule
* createAchWithdrawalSchedule - Create ACH Withdrawal Schedule
* listAchWithdrawalSchedules - List ACH Withdrawal Schedules
* getAchWithdrawalSchedule - Get ACH Withdrawal Schedule
* updateAchWithdrawalSchedule - Update ACH Withdrawal Schedule
* cancelAchWithdrawalSchedule - Cancel ACH Withdrawal Schedule
* createCheckWithdrawalSchedule - Create Check Withdrawal Schedule
* listCheckWithdrawalSchedules - List Check Withdrawal Schedules
* getCheckWithdrawalSchedule - Get Check Withdrawal Schedule
* updateCheckWithdrawalSchedule - Update Check Withdrawal Schedule
* cancelCheckWithdrawalSchedule - Cancel Check Withdrawal Schedule
* createWireWithdrawalSchedule - Create Wire Withdrawal Schedule
* listWireWithdrawalSchedules - List Wire Withdrawal Schedules
* getWireWithdrawalSchedule - Get Wire Withdrawal Schedule
* updateWireWithdrawalSchedule - Update Wire Withdrawal Schedule
* cancelWireWithdrawalSchedule - Cancel Wire Withdrawal Schedule
$3
* createPushSubscription - Create Push Subscription
* listPushSubscriptions - List Push Subscriptions
* getPushSubscription - Get Push Subscription
* updatePushSubscription - Update Subscription
* deletePushSubscription - Delete Subscription
* getPushSubscriptionDelivery - Get Subscription Event Delivery
* listPushSubscriptionDeliveries - List Push Subscription Event Deliveries
$3
* simulateCreateCheckDeposit - Simulate Check Deposit Creation
* forceApproveCheckDeposit - Check Deposit Approval
* forceApproveAchDeposit - ACH Deposit Approval
* forceNocAchDeposit - NOC for a Deposit
* forceRejectAchDeposit - ACH Deposit Rejection
* forceReturnAchDeposit - ACH Deposit Return
* forceApproveAchWithdrawal - ACH Withdrawal Approval
* forceNocAchWithdrawal - ACH Withdrawal NOC
* forceRejectAchWithdrawal - ACH Withdrawal Rejection
* forceReturnAchWithdrawal - ACH Withdrawal Return
* getMicroDepositAmounts - Get Relationship Micro Deposit Verification
* forceApproveIctDeposit - Force Approve ICT Deposit
* forceRejectIctDeposit - Force Reject ICT Deposit
* forceApproveIctWithdrawal - Force Approve ICT Withdrawal
* forceRejectIctWithdrawal - Force Reject ICT Withdrawal
* forceApproveWireWithdrawal - Force Approve Wire Withdrawal
* forceRejectWireWithdrawal - Force Reject Wire Withdrawal
* simulateWireDeposit - Simulate Wire Deposit
* forceApproveWireDeposit - Force Approve Wire Deposit
* forceRejectWireDeposit - Force Reject Wire Deposit
* forceApproveCashJournal - Force Approve Cash Journal
* forceRejectCashJournal - Force Reject Cash Journal
* forceApprovePositionJournal - Force Approve Position Journal
* forceRejectPositionJournal - Force Reject Position Journal
$3
* createTradeAllocation - Create Trade Allocation
* getTradeAllocation - Get Trade Allocation
* cancelTradeAllocation - Cancel Trade Allocation
* rebookTradeAllocation - Rebook Trade Allocation
$3
* createTrade - Create Trade
* getTrade - Get Trade
* completeTrade - Complete Trade
* cancelTrade - Cancel Trade
* rebookTrade - Rebook Trade
* createExecution - Create Execution
* getExecution - Get Execution
* cancelExecution - Cancel Execution
* rebookExecution - Rebook Execution
$3
* getWireDeposit - Get Wire Deposit
* createWireWithdrawal - Create Wire Withdrawal
* getWireWithdrawal - Get Wire Withdrawal
* cancelWireWithdrawal - Cancel Wire Withdrawal
Pagination
Some of the endpoints in this SDK support pagination. To use pagination, you
make your SDK calls as usual, but the returned response object will also be an
async iterable that can be consumed using the [
for await...of][for-await-of]
syntax.[for-await-of]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of
Here's an example of one such pagination call:
`typescript
import { Apexascend } from "@apexfintechsolutions/ascend-sdk";const apexascend = new Apexascend();
async function run() {
const result = await apexascend.authentication.listSigningKeys({
apiKeyAuth: "",
});
for await (const page of result) {
console.log(page);
}
}
run();
`
Retries
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
`typescript
import { Apexascend } from "@apexfintechsolutions/ascend-sdk";const apexascend = new Apexascend();
async function run() {
const result = await apexascend.authentication.generateServiceAccountToken({
apiKeyAuth: "",
}, {
jws:
"eyJhbGciOiAiUlMyNTYifQ.eyJuYW1lIjogImpkb3VnaCIsIm9yZ2FuaXphdGlvbiI6ICJjb3JyZXNwb25kZW50cy8xMjM0NTY3OC0xMjM0LTEyMzQtMTIzNC0xMjM0NTY3ODkxMDEiLCJkYXRldGltZSI6ICIyMDI0LTAyLTA1VDIxOjAyOjI3LjkwMTE4MFoifQ.IMy3KmYoG8Ppf+7hXN7tm7J4MrNpQLGL7WCWvhh4nZWAVKkluL3/u3KC6hZ6Mb/5p7Y54CgZ68aWT2BcP5y4VtzIZR1Chm5pxbLfgE4aJuk+FnF6K3Gc3bBjOWCL58pxY2aTb0iU/exDEA1cbMDvbCzmY5kRefDvorLOqgUS/tS2MJ2jv4RlZFPlmHv5PtOruJ8xUW19gEgGhsPXYYeSHFTE1ZlaDvyXrKtpOvlf+FVc2RTuEw529LZnzwH4/eJJR3BpSpHyJTjQqiaMT3wzpXXYKfCRqnDkSSKJDzCzTb0/uWK/Lf0uafxPXk5YLdis+dbo1zNQhVVKjwnMpk1vLw",
}, {
retries: {
strategy: "backoff",
backoff: {
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
},
retryConnectionErrors: false,
},
});
console.log(result);
}
run();
`If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
`typescript
import { Apexascend } from "@apexfintechsolutions/ascend-sdk";const apexascend = new Apexascend({
retryConfig: {
strategy: "backoff",
backoff: {
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
},
retryConnectionErrors: false,
},
});
async function run() {
const result = await apexascend.authentication.generateServiceAccountToken({
apiKeyAuth: "",
}, {
jws:
"eyJhbGciOiAiUlMyNTYifQ.eyJuYW1lIjogImpkb3VnaCIsIm9yZ2FuaXphdGlvbiI6ICJjb3JyZXNwb25kZW50cy8xMjM0NTY3OC0xMjM0LTEyMzQtMTIzNC0xMjM0NTY3ODkxMDEiLCJkYXRldGltZSI6ICIyMDI0LTAyLTA1VDIxOjAyOjI3LjkwMTE4MFoifQ.IMy3KmYoG8Ppf+7hXN7tm7J4MrNpQLGL7WCWvhh4nZWAVKkluL3/u3KC6hZ6Mb/5p7Y54CgZ68aWT2BcP5y4VtzIZR1Chm5pxbLfgE4aJuk+FnF6K3Gc3bBjOWCL58pxY2aTb0iU/exDEA1cbMDvbCzmY5kRefDvorLOqgUS/tS2MJ2jv4RlZFPlmHv5PtOruJ8xUW19gEgGhsPXYYeSHFTE1ZlaDvyXrKtpOvlf+FVc2RTuEw529LZnzwH4/eJJR3BpSpHyJTjQqiaMT3wzpXXYKfCRqnDkSSKJDzCzTb0/uWK/Lf0uafxPXk5YLdis+dbo1zNQhVVKjwnMpk1vLw",
});
console.log(result);
}
run();
`
Debugging
You can setup your SDK to emit debug logs for SDK requests and responses.
You can pass a logger that matches
console's interface as an SDK option.> [!WARNING]
> Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production.
`typescript
import { Apexascend } from "@apexfintechsolutions/ascend-sdk";const sdk = new Apexascend({ debugLogger: console });
``