SDK API Reference / RawAPI
Class: RawAPI
Raw API for making authenticated HTTP requests to any TD API endpoint
Example
typescript
// GET request
const result = await tdx.api.request('/v3/database/list');
// POST with body
const result = await tdx.api.request('/v3/database/create/mydb', {
method: 'POST',
body: { name: 'mydb' }
});
// Custom headers
const result = await tdx.api.request('/v3/database/list', {
headers: { 'X-Custom': 'value' }
});
// Different API type
const result = await tdx.api.request('/audiences/v1/workspaces/123/audiences', {
apiType: 'cdp'
});
// Include response headers
const result = await tdx.api.request('/v3/database/list', {
includeHeaders: true
});
console.log(result.headers);Methods
request()
request<
T>(endpoint,options):Promise<RawAPIResult<T>>
Make a raw HTTP request to any TD API endpoint
Type Parameters
T
T = unknown
Parameters
endpoint
string
API endpoint path (must start with /)
options
RawAPIRequestOptions = {}
Request options
Returns
Promise<RawAPIResult<T>>
API response wrapped with data and optional headers
Throws
Error if endpoint is invalid or request fails
readBodyFromFile()
staticreadBodyFromFile(filePath):string
Helper method to read request body from a file
Parameters
filePath
string
Path to file containing request body
Returns
string
File contents as string
Throws
Error if file cannot be read