Lightweight helper to determine whether a given SP-API GET operation should have usage computed and to map GET operation names to their URL paths.
- Source: src/index.ts
- Enum / mapping: src/state.ts
pnpm add spapi-get-usage-countTo use the functions checkIsNeedComputeUsageByGetApi and transformGetApiOperationToUrlPath from the spapi-get-usage-count package, you can import them as follows:
import { checkIsNeedComputeUsageByGetApi, transformGetApiOperationToUrlPath } from 'spapi-get-usage-count';Here's a basic example of how you might use these functions in your code:
const operationName = 'getFeed';
const isComputeUsageNeeded = checkIsNeedComputeUsageByGetApi(operationName);
if (isComputeUsageNeeded) {
const urlPath = transformGetApiOperationToUrlPath(operationName);
console.log(`The URL path for the operation is: ${urlPath}`);
} else {
console.log('No usage computation needed for this operation.');
}Determines if usage computation is needed for the given SP-API GET operation.
operationName: The name of the SP-API GET operation.- Returns
trueif usage computation is needed,falseotherwise.
Maps the given SP-API GET operation name to its corresponding URL path.
operationName: The name of the SP-API GET operation.- Returns the URL path as a string.