Class: QuestionAPI
Question & Answer API client for managing product questions and answers. Provides methods to retrieve questions, answers, and question statistics.
Constructors
Constructor
new QuestionAPI(http: HttpClient, apiKey: string): QuestionAPI;Parameters
http
HttpClient
apiKey
string
Returns
QuestionAPI
Methods
getAllQuestions()
getAllQuestions(params?: {
count?: string;
fromDate?: string;
grabAll?: string;
label?: string;
page?: string;
published?: string;
updatedDate?: string;
}): Promise<QuestionsResponse>;Retrieves all questions with optional filtering and pagination.
Parameters
params?
Optional query parameters for filtering
count?
string
Number of questions per page (default: '10')
fromDate?
string
Filter questions from this date (YYYY-MM-DD format)
grabAll?
string
Whether to grab all questions (default: '1')
label?
string
Filter by label
page?
string
Page number (default: '1')
published?
string
Filter by published status ('1' or '0')
updatedDate?
string
Filter questions updated from this date
Returns
Promise<QuestionsResponse>
Promise resolving to questions response with pagination info
Throws
When the API returns an error
Throws
When a network error occurs
Example
const questions = await sdk.questions().getAllQuestions({
count: '20',
page: '1',
published: '1'
});getBatchQuestionLikeCounts()
getBatchQuestionLikeCounts(questionIds: string[], userIdentifier?: string): Promise<QuestionBatchLikeData>;Retrieves like counts for up to 100 Q&A questions in a single request.
Parameters
questionIds
string[]
userIdentifier?
string
Returns
Promise<QuestionBatchLikeData>
Example
const likes = await sdk.questions().getBatchQuestionLikeCounts(['q-1', 'q-2']);getProductQuestionCount()
getProductQuestionCount(productId: string): Promise<QuestionCount>;Retrieves the total count of questions for a specific product.
Parameters
productId
string
The product ID to get question count for
Returns
Promise<QuestionCount>
Promise resolving to question count
Throws
When the API returns an error
Throws
When a network error occurs
Example
const count = await sdk.questions().getProductQuestionCount('product-123');
console.log(`Total questions: ${count.count}`);getProductQuestions()
getProductQuestions(productId: string): Promise<Question[]>;Retrieves all questions for a specific product.
Parameters
productId
string
The product ID to get questions for
Returns
Promise<Question[]>
Promise resolving to an array of questions
Throws
When the API returns an error
Throws
When a network error occurs
Example
const questions = await sdk.questions().getProductQuestions('product-123');
questions.forEach(q => console.log(q.question));getQuestionLikeCount()
getQuestionLikeCount(questionId: string, userIdentifier?: string): Promise<QuestionLikeData>;Retrieves the like (and optionally dislike) count for a Q&A question. Use isDislikeEnabled to check whether dislike fields are present.
Parameters
questionId
string
userIdentifier?
string
Returns
Promise<QuestionLikeData>
toggleQuestionLike()
toggleQuestionLike(
questionId: string,
userIdentifier?: string,
options?: {
vote?: LikeVote;
}): Promise<QuestionLikeData>;Toggles a like or dislike on a Q&A question. Toggle semantics match the review endpoint. Q&A has a single widget context, so there is no widget_type parameter.
Parameters
questionId
string
userIdentifier?
string
options?
vote?
Returns
Promise<QuestionLikeData>
Throws
When vote='down' is not permitted for Q&A
Throws
When the per-user rate limit is exceeded
Example
await sdk.questions().toggleQuestionLike('q-123', 'cust_abc');
await sdk.questions().toggleQuestionLike('q-123', 'cust_abc', { vote: 'down' });