> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # QueryLoyaltyTransactions # Package: accounts # Namespace: LoyaltyTransactions # Method link: https://dev.wix.com/docs/api-reference/crm/loyalty-program/accounts/transactions/query-loyalty-transactions.md ## Permission Scopes: Read Loyalty: SCOPE.DC-LOYALTY.READ-LOYALTY ## Introduction Retrieves a list of loyalty transactions with the specified paging, filtering, and sorting. To learn about working with _Query_ methods, see [API Query Language](https://dev.wix.com/docs/rest/articles/get-started/api-query-language.md), [Sorting and Paging](https://dev.wix.com/docs/rest/articles/get-started/sorting-and-paging.md), and [Field Projection](https://dev.wix.com/docs/rest/articles/get-started/field-projection.md). --- ## REST API ### Schema ``` Method: queryLoyaltyTransactions Description: Retrieves a list of loyalty transactions with the specified paging, filtering, and sorting. To learn about working with _Query_ methods, see [API Query Language](https://dev.wix.com/docs/rest/articles/get-started/api-query-language.md), [Sorting and Paging](https://dev.wix.com/docs/rest/articles/get-started/sorting-and-paging.md), and [Field Projection](https://dev.wix.com/docs/rest/articles/get-started/field-projection.md). URL: https://www.wixapis.com/v1/loyalty-transactions/query Method: POST Method parameters: param name: query | type: CursorQuery - name: cursorPaging | type: CursorPaging | description: Cursor paging options. Learn more about [cursor paging](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#cursor-paging). - name: limit | type: integer | description: Maximum number of items to return in the results. - name: cursor | type: string | description: Pointer to the next or previous page in the list of results. Pass the relevant cursor token from the `pagingMetadata` object in the previous call's response. Not relevant for the first request. - name: filter | type: object | description: Filter object. Learn more about [filtering](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#filters). - name: sort | type: array | description: Sort object. Learn more about [sorting](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#sorting). - name: fieldName | type: string | description: Name of the field to sort by. - name: order | type: SortOrder | description: Sort order. - enum: ASC, DESC Return type: QueryLoyaltyTransactionsResponse - name: loyaltyTransactions | type: array | description: Retrieved loyalty transactions. - ONE-OF: - name: earnInfo | type: EarnInfo | description: Information on points earned. - ONE-OF: - name: followedSocialMedia | type: FollowedSocialMedia | description: Details on following on social media. - name: channel | type: string | description: Social media channel. For example, `"FACEBOOK"` or `"INSTAGRAM"`. - name: appId | type: string | description: GUID of the app that generated the earned points. - name: activityType | type: string | description: Activity type. - name: orderId | type: string | description: Order GUID. - name: limitApplied | type: boolean | description: Whether the points amount was adjusted by an earn points limit provider. - name: redeemInfo | type: RedeemInfo | description: Information on points redeemed. - name: rewardId | type: string | description: GUID of the reward that was redeemed. - name: rewardType | type: string | description: Type of reward that was redeemed. - name: referenceEntityId | type: string | description: GUID of the specific item that was redeemed in this transaction. Each reward that's redeemed has a unique `referenceEntityId`. - name: adjustInfo | type: AdjustInfo | description: Information on points adjusted. - name: appId | type: string | description: GUID of the app that initiated the points adjustment. - name: amountBefore | type: integer | description: Amount before adjustment. - name: amountAfter | type: integer | description: Amount after adjustment. - name: refundInfo | type: RefundInfo | description: Information on points refunded. - name: appId | type: string | description: GUID of the app that refunded points. - name: refundedTransactionId | type: string | description: GUID of the transaction that was refunded. - name: expireInfo | type: ExpireInfo | description: Information on points expired. - name: amountBefore | type: integer | description: Amount before expiration. - name: amountAfter | type: integer | description: Amount after expiration. - name: earnAttemptInfo | type: EarnAttemptInfo | description: Information on a limited earn attempt recorded with 0 points. - name: appId | type: string | description: GUID of the app that generated the earn operation. - name: activityType | type: string | description: Activity type. - name: orderId | type: string | description: Order GUID. - name: id | type: string | description: Transaction GUID. - name: accountId | type: string | description: Account GUID. - name: createdDate | type: string | description: Date and time the transaction was created. - name: amount | type: integer | description: The number of points earned, adjusted, redeemed, or expired in the transaction. + `EARN`: Number of points earned by a customer taking an action. + `REDEEM`: The number of points redeemed by a customer for a reward. + `ADJUST`: The number of points adjusted to a customer's balance. + `REFUND`: The number of points refunded for a previously redeemed reward. + `EXPIRE`: The number of points that expired due to customer inactivity for a configured period. - name: transactionType | type: TransactionType | description: Type of transaction. - enum: - UNKNOWN: Unknown transaction type. - EARN: Number of points earned by a customer taking an action. See [Earn Points](https://dev.wix.com/docs/rest/crm/loyalty-program/accounts/earn-points.md). - REDEEM: Number of points redeemed by a customer for a reward. - ADJUST: Number of points adjusted to a customer's balance. See [Adjust Points](https://dev.wix.com/docs/rest/crm/loyalty-program/accounts/adjust-points.md). - REFUND: Number of points refunded for a previously redeemed reward. - EXPIRE: Number of points that expired due to customer inactivity for a configured period. - EARN_ATTEMPT: Record of an earn attempt that was limited to 0 points. - name: description | type: string | description: Transaction description. - name: idempotencyKey | type: string | description: Unique identifier, generated by the client. Used to recognize repeated attempts of the same request. Only present when manually adding points with [Earn Points](https://dev.wix.com/docs/rest/crm/loyalty-program/accounts/earn-points.md). - name: pagingMetadata | type: CursorPagingMetadata | description: Paging metadata. - name: count | type: integer | description: Number of items returned in current page. - name: cursors | type: Cursors | description: Cursor strings that point to the next page, previous page, or both. - name: next | type: string | description: Cursor string pointing to the next page in the list of results. - name: prev | type: string | description: Cursor pointing to the previous page in the list of results. - name: hasNext | type: boolean | description: Whether there are more pages to retrieve following the current page. + `true`: Another page of results can be retrieved. + `false`: This is the last page. ``` ### Examples ### Query loyalty transactions ```curl curl -X POST \ 'https://www.wixapis.com/loyalty-transactions/v1/loyalty-transactions/query' \ -H 'Authorization: ' \ -H 'Content-Type: application/json' \ --data-binary '{ "query": { "filter": { "transactionType": { "$eq": "EARN" } } } }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.accounts.LoyaltyTransactions.queryLoyaltyTransactions(query) Description: Retrieves a list of loyalty transactions with the specified paging, filtering, and sorting. To learn about working with _Query_ methods, see [API Query Language](https://dev.wix.com/docs/rest/articles/get-started/api-query-language.md), [Sorting and Paging](https://dev.wix.com/docs/rest/articles/get-started/sorting-and-paging.md), and [Field Projection](https://dev.wix.com/docs/rest/articles/get-started/field-projection.md). # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: query Method parameters: param name: query | type: LoyaltyTransactionQuery | required: true - name: cursorPaging | type: CursorPaging | description: Cursor paging options. Learn more about [cursor paging](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#cursor-paging). - name: limit | type: integer | description: Maximum number of items to return in the results. - name: cursor | type: string | description: Pointer to the next or previous page in the list of results. Pass the relevant cursor token from the `pagingMetadata` object in the previous call's response. Not relevant for the first request. - name: filter | type: object | description: Filter object. Learn more about [filtering](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#filters). - name: sort | type: array | description: Sort object. Learn more about [sorting](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#sorting). - name: fieldName | type: string | description: Name of the field to sort by. - name: order | type: SortOrder | description: Sort order. - enum: ASC, DESC Return type: PROMISE - name: loyaltyTransactions | type: array | description: Retrieved loyalty transactions. - ONE-OF: - name: earnInfo | type: EarnInfo | description: Information on points earned. - ONE-OF: - name: followedSocialMedia | type: FollowedSocialMedia | description: Details on following on social media. - name: channel | type: string | description: Social media channel. For example, `"FACEBOOK"` or `"INSTAGRAM"`. - name: appId | type: string | description: GUID of the app that generated the earned points. - name: activityType | type: string | description: Activity type. - name: orderId | type: string | description: Order GUID. - name: limitApplied | type: boolean | description: Whether the points amount was adjusted by an earn points limit provider. - name: redeemInfo | type: RedeemInfo | description: Information on points redeemed. - name: rewardId | type: string | description: GUID of the reward that was redeemed. - name: rewardType | type: string | description: Type of reward that was redeemed. - name: referenceEntityId | type: string | description: GUID of the specific item that was redeemed in this transaction. Each reward that's redeemed has a unique `referenceEntityId`. - name: adjustInfo | type: AdjustInfo | description: Information on points adjusted. - name: appId | type: string | description: GUID of the app that initiated the points adjustment. - name: amountBefore | type: integer | description: Amount before adjustment. - name: amountAfter | type: integer | description: Amount after adjustment. - name: refundInfo | type: RefundInfo | description: Information on points refunded. - name: appId | type: string | description: GUID of the app that refunded points. - name: refundedTransactionId | type: string | description: GUID of the transaction that was refunded. - name: expireInfo | type: ExpireInfo | description: Information on points expired. - name: amountBefore | type: integer | description: Amount before expiration. - name: amountAfter | type: integer | description: Amount after expiration. - name: earnAttemptInfo | type: EarnAttemptInfo | description: Information on a limited earn attempt recorded with 0 points. - name: appId | type: string | description: GUID of the app that generated the earn operation. - name: activityType | type: string | description: Activity type. - name: orderId | type: string | description: Order GUID. - name: _id | type: string | description: Transaction GUID. - name: accountId | type: string | description: Account GUID. - name: _createdDate | type: Date | description: Date and time the transaction was created. - name: amount | type: integer | description: The number of points earned, adjusted, redeemed, or expired in the transaction. + `EARN`: Number of points earned by a customer taking an action. + `REDEEM`: The number of points redeemed by a customer for a reward. + `ADJUST`: The number of points adjusted to a customer's balance. + `REFUND`: The number of points refunded for a previously redeemed reward. + `EXPIRE`: The number of points that expired due to customer inactivity for a configured period. - name: transactionType | type: TransactionType | description: Type of transaction. - enum: - UNKNOWN: Unknown transaction type. - EARN: Number of points earned by a customer taking an action. See [Earn Points](https://dev.wix.com/docs/rest/crm/loyalty-program/accounts/earn-points.md). - REDEEM: Number of points redeemed by a customer for a reward. - ADJUST: Number of points adjusted to a customer's balance. See [Adjust Points](https://dev.wix.com/docs/rest/crm/loyalty-program/accounts/adjust-points.md). - REFUND: Number of points refunded for a previously redeemed reward. - EXPIRE: Number of points that expired due to customer inactivity for a configured period. - EARN_ATTEMPT: Record of an earn attempt that was limited to 0 points. - name: description | type: string | description: Transaction description. - name: idempotencyKey | type: string | description: Unique identifier, generated by the client. Used to recognize repeated attempts of the same request. Only present when manually adding points with [Earn Points](https://dev.wix.com/docs/rest/crm/loyalty-program/accounts/earn-points.md). - name: pagingMetadata | type: CursorPagingMetadata | description: Paging metadata. - name: count | type: integer | description: Number of items returned in current page. - name: cursors | type: Cursors | description: Cursor strings that point to the next page, previous page, or both. - name: next | type: string | description: Cursor string pointing to the next page in the list of results. - name: prev | type: string | description: Cursor pointing to the previous page in the list of results. - name: hasNext | type: boolean | description: Whether there are more pages to retrieve following the current page. + `true`: Another page of results can be retrieved. + `false`: This is the last page. ``` ### Examples ### Query loyalty transaction (with elevated permissions) ```javascript import { transactions } from "@wix/loyalty"; import { auth } from "@wix/essentials"; const elevatedQueryLoyaltyTransactions = auth.elevate(transactions.queryLoyaltyTransactions); async function queryLoyaltyTransactions() { const { items } = await elevatedQueryLoyaltyTransactions().find(); } /* Promise resolves to: * * { * "_createdDate": "2024-06-10T14:55:26.916Z", * "_id": "1d0d1159-f578-4f37-98df-f988fa728ff9", * "accountId": "ec8a038b-aefb-4bed-bd15-635906cc6a60", * "transactionType": "ADJUST", * "amount": -70, * "description": "", * "idempotencyKey": "1d0d1159-f578-4f37-98df-f988fa728ff9", * "adjustInfo": { * "appId": "553c79f3-5625-4f38-b14b-ef7c0d1e87df", * "amountBefore": 70, * "amountAfter": 0 * } * }, * { * "_createdDate": "2024-06-10T15:27:31.073Z", * "_id": "318563e8-ebca-4531-b284-27cec8807b5e", * "accountId": "d0dc5ba3-4a10-4cfc-b304-c976d8ac7303", * "transactionType": "ADJUST", * "amount": 50, * "description": "", * "idempotencyKey": "318563e8-ebca-4531-b284-27cec8807b5e", * "adjustInfo": { * "appId": "553c79f3-5625-4f38-b14b-ef7c0d1e87df", * "amountBefore": 0, * "amountAfter": 50 * } * } */ ``` ### Query loyalty transaction ```javascript import { transactions } from "@wix/loyalty"; async function queryLoyaltyTransactions() { const { items } = await transactions.queryLoyaltyTransactions().find(); } /* Promise resolves to: * * { * "_createdDate": "2024-06-10T14:55:26.916Z", * "_id": "1d0d1159-f578-4f37-98df-f988fa728ff9", * "accountId": "ec8a038b-aefb-4bed-bd15-635906cc6a60", * "transactionType": "ADJUST", * "amount": -70, * "description": "", * "idempotencyKey": "1d0d1159-f578-4f37-98df-f988fa728ff9", * "adjustInfo": { * "appId": "553c79f3-5625-4f38-b14b-ef7c0d1e87df", * "amountBefore": 70, * "amountAfter": 0 * } * }, * { * "_createdDate": "2024-06-10T15:27:31.073Z", * "_id": "318563e8-ebca-4531-b284-27cec8807b5e", * "accountId": "d0dc5ba3-4a10-4cfc-b304-c976d8ac7303", * "transactionType": "ADJUST", * "amount": 50, * "description": "", * "idempotencyKey": "318563e8-ebca-4531-b284-27cec8807b5e", * "adjustInfo": { * "appId": "553c79f3-5625-4f38-b14b-ef7c0d1e87df", * "amountBefore": 0, * "amountAfter": 50 * } * } */ ``` ### queryLoyaltyTransactions (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { transactions } from '@wix/loyalty'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { transactions }, // Include the auth strategy and host as relevant }); async function queryLoyaltyTransactions(query) { const response = await myWixClient.transactions.queryLoyaltyTransactions(query); }; ``` ---