getApiUsage
This method allows you to retrieve Linked API usage statistics so you can monitor your limits and stay within their recommended values.
try {
// Get usage stats for the last 7 days
const endDate = new Date();
const startDate = new Date(endDate.getTime() - 7 * 24 * 60 * 60 * 1000);
const { data } = await linkedapi.getApiUsage({
start: startDate.toISOString(),
end: endDate.toISOString()
});
if (data) {
console.log('Usage statistics retrieved successfully');
console.log('Total actions executed:', statsResponse.length);
// Analyze the statistics
const successfulActions = statsResponse.result?.filter(action => action.success);
const failedActions = statsResponse.result?.filter(action => !action.success);
console.log('Successful actions:', successfulActions?.length);
console.log('Failed actions:', failedActions?.length);
}
} catch (e) {
// A list of all critical errors can be found here:
// https://linkedapi.io/sdks/handling-results-and-errors/#handling-critical-errors
if (e instanceof LinkedApiError) {
console.error(`Critical Error - Type: ${e.type}, Message: ${e.message}`);
} else {
console.error('An unexpected, non-API error occurred:', e);
}
}
# Python SDK is coming soon!
#
# You can always use Linked API through HTTP
# https://linkedapi.io/docs/
// Go SDK is coming soon!
//
// You can always use Linked API through HTTP
// https://linkedapi.io/docs/
Params
start
– timestamp from which the statistics will be retrieved.end
– timestamp up to which the statistics will be retrieved.
The difference between
start
and end
must not exceed 30 days.Data
Array of HTTP API actions. Each action contains:
actionType
– type of the action (e.g.,st.sendMessage
,st.openCompanyPage
).success
– boolean indicating whether the action executed successfully.time
– timestamp when the action was executed.
Errors
The method has no execution errors (errors
is always []
).