Calculate cost basis from transactions
const url = 'https://api.qeychain.xyz/api/calculate/cost-basis';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"transactions":[{}],"wallets":["example"]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.qeychain.xyz/api/calculate/cost-basis \ --header 'Content-Type: application/json' \ --data '{ "transactions": [ {} ], "wallets": [ "example" ] }'Runs full cost basis calculation on provided transactions using FIFO method.
Returns:
- All tax lots (open, partial, closed)
- All lot consumptions with realized gains/losses
- Aggregate short-term and long-term capital gains
Request Bodyrequired
Section titled “Request Bodyrequired”Request for cost basis calculation.
object
List of transactions in Zerion format
object
List of wallet addresses to include in calculation
Examplegenerated
{ "transactions": [ {} ], "wallets": [ "example" ]}Responses
Section titled “Responses”Successful Response
Response from cost basis calculation.
object
All tax lots
Tax lot with cost basis information.
Enhanced with detailed origin tracking for full money trail:
- WHERE it came from (origin_address, origin_chain)
- HOW it was acquired (origin_type, origin_symbol)
object
Unique lot identifier (e.g., ‘ETH-ARB-001’)
Token symbol
Blockchain network
Original quantity acquired
Remaining quantity after disposals
Cost per unit in USD
Total cost basis in USD
Remaining cost basis
Acquisition type (purchase, swap_in, etc.)
Source of price data
Lot status: OPEN, PARTIAL, or CLOSED
Whether this lot has unknown cost basis
Whether user should provide cost basis manually
Whether user has provided manual cost basis
List of consumption events
Individual lot consumption event.
Enhanced with destination tracking for full money trail:
- WHERE the lot went (destination_type, destination_address)
- WHAT it became (destination_symbol, destination_lot_id)
object
Lots this lot came from (e.g., SCR lots that became this ETH lot)
Reference to a lot in the lineage chain (money trail).
object
Unique lineage key (chain:symbol:lot_id)
Lot identifier
Token symbol
Blockchain network
Quantity from/to this lot
Cost basis contribution
Lots this lot became (e.g., ETH lot that this SCR lot was swapped for)
Reference to a lot in the lineage chain (money trail).
object
Unique lineage key (chain:symbol:lot_id)
Lot identifier
Token symbol
Blockchain network
Quantity from/to this lot
Cost basis contribution
Gas fee (USD) included in cost basis (IRS allows adding gas to acquisition cost)
All lot consumption events
Individual lot consumption event.
Enhanced with destination tracking for full money trail:
- WHERE the lot went (destination_type, destination_address)
- WHAT it became (destination_symbol, destination_lot_id)
object
Total realized gain/loss
Example
{ "lots": [ { "is_untracked": false, "needs_manual_cost_basis": false, "manual_cost_basis_set": false, "consumptions": [ { "is_wash_sale": false } ], "gas_fee_included": "0" } ], "consumptions": [ { "is_wash_sale": false } ]}Bad Request
Not Found
Validation Error
object
object
Examplegenerated
{ "detail": [ { "loc": [ "example" ], "msg": "example", "type": "example" } ]}Internal Server Error
