@awakentax/crypto-tax
v0.1.3
Published
Tax SDK for Awaken
Downloads
413
Readme
@awakentax/crypto-tax
Tax SDK for Awaken - Easily integrate crypto tax calculation links into your application.
Step 1: Get an API Key
To use this SDK, you'll need an API key. Please contact [email protected] to obtain your API key.
Installation
npm install @awakentax/crypto-taxor with yarn:
yarn add @awakentax/crypto-taxUsage
Initialize the SDK
First, import and initialize the SDK with your API key:
import { CryptoTaxSDK } from '@awakentax/crypto-tax';
const cryptotax = new CryptoTaxSDK({
apiKey: 'your-api-key-here'
});Get the Link URL
Create a link by providing wallet addresses:
import type { CreateLinkRequest } from '@awakentax/crypto-tax';
const request: CreateLinkRequest = {
wallets: [
{
address: '0x1234567890123456789012345678901234567890',
name: 'My Main Wallet' // Optional
},
{
address: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcd'
}
]
};
const response = await cryptotax.createLink(request);
console.log('Link URL:', response.url);
console.log('Link Code:', response.code);Open the Link
Once you have the URL, you can open it in a browser or redirect your users:
// In a browser environment
window.location.href = response.url;
// Or open in a new tab/window
window.open(response.url, '_blank');
// In a Node.js environment, you can log it or use a library like 'open'
console.log('Open this URL:', response.url);Complete Example
import { CryptoTaxSDK } from '@awakentax/crypto-tax';
import type { CreateLinkRequest } from '@awakentax/crypto-tax';
async function createTaxLink() {
// Initialize SDK
const cryptotax = new CryptoTaxSDK({
apiKey: process.env.AWAKEN_API_KEY!,
});
// Prepare wallet data
const request: CreateLinkRequest = {
wallets: [
{
address: '0x1234567890123456789012345678901234567890',
name: 'My Main Wallet'
}
]
};
try {
// Create the link
const { url, code } = await cryptotax.createLink(request);
// Open the link (browser example)
window.location.href = url;
// Or redirect users to the tax calculation page
// window.open(url, '_blank');
} catch (error) {
console.error('Failed to create link:', error);
}
}What It Looks Like
When you open up the URL we generate for you, it will look something like this. If the user doesn't have an Awaken account, it will prompt them to create one and then automatically add the wallets for them. If they already have an account, it'll be a one click add for them to link these wallets to their existing Awaken account.
Alternative: Using cURL (Without SDK)
If you prefer not to use the SDK, you can make direct API calls using cURL:
Create Partner Account Link
curl -X POST https://api.link.awaken.tax/api/links \
-H "Content-Type: application/json" \
-H "x-api-key: your-api-key-here" \
-d '{
"wallets": [
{
"address": "0x1234567890123456789012345678901234567890",
"name": "My Wallet"
},
{
"address": "0xabcdefabcdefabcdefabcdefabcdefabcdefabcd"
}
]
}'Request Body:
wallets(array, required): Array of wallet objectsaddress(string, required): Wallet addressname(string, optional): Wallet name
Response:
- Success (201): Returns
codeandurlfor the created link - Success (200): Returns existing link if wallet hash already exists
- Error (400): Validation error with details
- Error (404): Partnership not found
- Error (500): Internal server error
Example Response:
{
"code": "abc123xyz",
"url": "https://awaken.tax/link?code=abc123xyz"
}API Reference
CryptoTaxSDK
Constructor
new CryptoTaxSDK(options: SDKOptions)Options:
apiKey(string, required): Your API keybaseUrl(string, optional): Base URL for the API. Defaults tohttps://api.link.awaken.tax
Methods
createLink(request: CreateLinkRequest): Promise<CreateLinkResponse>
Creates a new tax calculation link.
Parameters:
request.wallets: Array of wallet objects withaddress(required) and optionalname
Returns:
code: Unique code for the linkurl: Full URL to access the tax calculation interface
