npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

buymeua-api-fe

v0.40.0

Published

TypeScript/JavaScript client for BuyMeUA API with RTK Query integration.

Readme

Buymeua API Frontend

TypeScript/JavaScript client for BuyMeUA API with RTK Query integration.

npm version License: ISC

🚀 Installation

npm install buymeua-api-fe @reduxjs/toolkit react-redux
# or
yarn add buymeua-api-fe @reduxjs/toolkit react-redux
# or
pnpm add buymeua-api-fe @reduxjs/toolkit react-redux

📖 Quick Start

Table of Contents

1. Configure API and Setup Redux Store

import { configureStore } from '@reduxjs/toolkit';
import { configureBuymeuaApi, Session } from 'buymeua-api-fe';

// Configure API before store setup
const buymeuaApi = configureBuymeuaApi({
  baseUrl: 'https://api.buymeua.com/',
  pusher: {
    appKey: 'your-pusher-app-key',
    cluster: 'eu',
  },
  prepareHeaders: (headers) => {
    headers.set('Accept', 'application/json');
    headers.set('Content-Type', 'application/json');

    headers.set('X-SESSION', Session.Dropshipper);

    const token = localStorage.getItem('auth-token');
    if (token) {
      headers.set('Authorization', `Bearer ${token}`);
    }
  },
  onUnauthorized: (args, api, extraOptions) => {
    // Handle 401 errors with full request context
    console.log('Unauthorized request:', args);
    localStorage.removeItem('auth-token');
    window.location.href = '/login';
  },
});

// Setup Redux store
export const store = configureStore({
  reducer: {
    [buymeuaApi.reducerPath]: buymeuaApi.reducer,
  },
  middleware: (getDefaultMiddleware) =>
    getDefaultMiddleware().concat(buymeuaApi.middleware),
});

2. Usage in React Components

import React from 'react';
import { productApi } from 'buymeua-api-fe';

function ProductList() {
  const { data, isLoading, error, fetchNextPage, hasNextPage } = productApi.useGetProductsInfiniteQuery({
    per_page: 20,
    core_filter: 'phone'
  });

  if (isLoading) return <div>Loading...</div>;
  if (error) return <div>Error loading products</div>;

  return (
    <div>
      {data?.pages.map((page, pageIndex) => (
        <div key={pageIndex}>
          {page.data.map((product) => (
            <div key={product.id}>{product.name}</div>
          ))}
        </div>
      ))}
      {hasNextPage && (
        <button onClick={() => fetchNextPage()}>Load More</button>
      )}
    </div>
  );
}

📚 API Reference

Configuration

configureBuymeuaApi(config: ApiConfig)

Configures the global API client.

getPusher(): Promise<Pusher>

Returns a shared Pusher instance for real-time subscriptions. Uses lazy initialization and automatically handles authentication for private channels.

import { getPusher } from 'buymeua-api-fe';

// Subscribe to a channel
const pusher = await getPusher();
const channel = pusher.subscribe('my-channel');
channel.bind('my-event', (data) => {
  console.log('Received:', data);
});

Parameters:

  • config.baseUrl - Base API URL
  • config.prepareHeaders - Function to prepare headers (receives Headers object and API context)
  • config.onUnauthorized - Optional callback for handling 401 errors (receives args, api, extraOptions for context)

Returns: Configured API instance ready for Redux store setup

Products

import { productApi } from 'buymeua-api-fe';

// Get products list with infinite scroll
const { data, fetchNextPage, hasNextPage } = productApi.useGetProductsInfiniteQuery({
  per_page?: number;
  core_filter?: string;
  filter_has_special?: boolean | null;
  order_by?: string | string[];
  category_filter?: number[];
  option_value_filter?: {
    option_value_ids: number[];
    warehouse_ids: number[];
  };
  attribute_filter?: {
    attribute_ids: number[];
    attribute_values: `${number}:$${number}`[];
  };
  filter_customer_id?: number;
  filter_has_customer_id?: boolean;
  filter_advertised?: boolean;
  filter_product_ids?: number[];
  filter_exclude_product_ids?: number[];
  filter_bestseller?: boolean;
  price_from?: number;
  price_to?: number;
  retail_price_from?: number;
  retail_price_to?: number;
  margin_from?: number;
  margin_to?: number;
  only_in_root_category?: boolean;
  price_type?: string;
});

// Get products with standard pagination
const { data } = productApi.useGetPaginatedProductsQuery({
  page?: number;
  per_page?: number;
  core_filter?: string;
  filter_has_special?: boolean | null;
  order_by?: string | string[];
  category_filter?: number[];
  option_value_filter?: {
    option_value_ids?: number[];
    warehouse_ids?: number[];
  };
  attribute_filter?: {
    attribute_ids: number[];
    attribute_values: `${number}:$${number}`[];
  };
  filter_customer_id?: number;
  filter_has_customer_id?: boolean;
  filter_advertised?: boolean;
  filter_product_ids?: number[];
  filter_exclude_product_ids?: number[];
  filter_bestseller?: boolean;
  price_from?: number;
  price_to?: number;
  retail_price_from?: number;
  retail_price_to?: number;
  margin_from?: number;
  margin_to?: number;
  only_in_root_category?: boolean;
  price_type?: string;
});

// Get products by QR code
const { data, fetchNextPage, hasNextPage } = productApi.useGetProductsByQrInfiniteQuery({
  'filter[barcode]'?: string;
  'filter[product_id]'?: number;
  warehouse_id?: number;
  show_sizes?: boolean;
  per_page?: number;
});

// Get single product by ID
const { data } = productApi.useGetProductQuery({ product: number });

// Get product statistics
const { data } = productApi.useGetProductStatisticsQuery({ product: number });

// Get product details
const { data } = productApi.useGetProductDetailsQuery({ product: number });

// Get product attributes for filtering
const { data } = productApi.useGetProductAttributesQuery({
  search?: string;
  product_id?: number;
  category_id?: number;
  attribute_ids?: number[];
  option_value_filter?: {
    option_value_ids?: number[];
    warehouse_ids?: number[];
  };
  attribute_filter?: {
    attribute_ids?: number[];
    attribute_values?: `${number}:${string}`[];
  };
});

// Get product options for filtering
const { data } = productApi.useGetProductOptionsQuery({
  search?: string;
  product_id?: number;
  category_id?: number;
  option_id?: number;
  option_value_ids?: number[];
  warehouse_ids?: number[];
  attribute_filter?: {
    attribute_ids?: number[];
    attribute_values?: `${number}:${string}`[];
  };
});

// Get supplier products with infinite scroll
const { data, fetchNextPage, hasNextPage } = productApi.useGetSupplierProductsInfiniteQuery({
  core_filter?: string;
  category_filter?: number[];
  buyme_category_filter?: number[];
  filter_buyme_category_set_main_category?: boolean;
  filter_customer_id?: number;
  filter_exclude_supplier_ids?: number[];
  filter_advertised?: boolean;
  only_in_root_category?: boolean;
  option_value_filter?: {
    option_value_ids?: number[];
    warehouse_ids?: number[];
  };
  price_from?: number;
  price_to?: number;
  per_page?: number;
  price_type?: 'price' | 'price_drop';
});

// Get supplier products with standard pagination
const { data } = productApi.useGetPaginatedSupplierProductsQuery({
  page?: number;
  core_filter?: string;
  category_filter?: number[];
  buyme_category_filter?: number[];
  filter_buyme_category_set_main_category?: boolean;
  filter_customer_id?: number;
  filter_exclude_supplier_ids?: number[];
  filter_advertised?: boolean;
  only_in_root_category?: boolean;
  option_value_filter?: {
    option_value_ids?: number[];
    warehouse_ids?: number[];
  };
  price_from?: number;
  price_to?: number;
  per_page?: number;
  price_type?: 'price' | 'price_drop';
});

// Get supplier product details
const { data } = productApi.useGetSupplierProductDetailsQuery({ id: number });

// Generate product description using AI
const { data } = productApi.useGenerateProductDescriptionQuery({ product: number });
// data.description - AI-generated product description

Cart

import { cartApi } from 'buymeua-api-fe';

// Get cart count
const { data } = cartApi.useGetCartCountQuery();

// Get cart merchants
const { data, fetchNextPage, hasNextPage } = cartApi.useGetCartMerchantsInfiniteQuery({
  per_page?: number;
});

// Get cart merchant items
const { data, fetchNextPage, hasNextPage } = cartApi.useGetCartMerchantItemsInfiniteQuery({
  merchant_id: number;
  per_page?: number;
});

// Add item to cart
const [addToCart] = cartApi.useAddToCartMutation();
await addToCart({
  product_type: 'buyme' | 'supplier';
  product_id: number;
  product_option_value_id: number;
  quantity: number;
  warehouse_id: number | null; // only for buyme products
});

// Remove item from cart
const [removeFromCart] = cartApi.useRemoveItemFromCartMutation();
await removeFromCart({
  cart_item_id: number;
  merchantId: number;
  quantity: number;
});

// Remove entire merchant from cart
const [removeMerchant] = cartApi.useRemoveMerchantFromCartMutation();
await removeMerchant({ merchant_id: number });

// Update cart item quantity
const [updateQuantity] = cartApi.useUpdateCartItemQuantityMutation();
await updateQuantity({
  cart_item_option_value_id: number;
  quantity: number;
  type: 'increase' | 'decrease';
  merchantId: number;
  optionIndex: number;
});

// Toggle gift package
const [toggleGift] = cartApi.useToggleGiftPackageMutation();
await toggleGift({
  gift_package: boolean;
});

Authentication

import { authApi } from 'buymeua-api-fe';

// Sign in with phone number
const [signIn] = authApi.useSignInMutation();
await signIn({
  telephone: string;
});

// Confirm verification code
const [confirmCode] = authApi.useConfirmCodeMutation();
await confirmCode({
  telephone: string;
  code: string;
});

// Sign up
const [signUp] = authApi.useSignUpMutation();
await signUp({
  telephone: string;
  firstname: string;
  lastname: string;
  term: 1;
});

// Register as guest
const [registerGuest] = authApi.useRegisterGuestMutation();
const { data } = await registerGuest(); // Returns Customer with token

// Logout
const [logout] = authApi.useLogoutMutation();
await logout();

Customer Account

import { customerApi } from 'buymeua-api-fe';

// Save customer settings
const [saveSettings] = customerApi.useSaveCustomerSettingsMutation();
await saveSettings({
  customer_group_id?: number;
  firstname?: string;
  lastname?: string;
  middlename?: string;
  email?: string;
  iban?: string;
  card_fio?: string;
  ederpou?: string;
  avatar?: File; // jpeg, png, jpg, gif, max: 2048kb
});

// Delete customer account
const [deleteAccount] = customerApi.useDeleteCustomerAccountMutation();
await deleteAccount();

Categories

import { categoryApi, useCategoryBreadcrumbs } from 'buymeua-api-fe';

// Get categories tree (full hierarchy)
const { data } = categoryApi.useGetCategoriesQuery({
  search?: string;
  filter_parent_id?: number;
  filter_with_products?: boolean;
  filter_with_supplier_products?: boolean;
  filter_prepared_for_site?: boolean;
});

// Build category breadcrumbs
// For regular categories
const { breadcrumbs, isLoading } = useCategoryBreadcrumbs(categoryId);

// For regular categories with filter params
const { breadcrumbs, isLoading } = useCategoryBreadcrumbs(categoryId, undefined, {
  filter_with_products: true
});

// For supplier categories
const { breadcrumbs, isLoading } = useCategoryBreadcrumbs(categoryId, supplierId);

// For supplier categories with filter params
const { breadcrumbs, isLoading } = useCategoryBreadcrumbs(categoryId, supplierId, {
  search: 'electronics'
});
// Returns array of categories from root to current

// Get supplier categories
const { data } = categoryApi.useGetSupplierCategoriesQuery({
  search?: string;
  filter_parent_id?: number;
  filter_customer_id?: number;
  filter_has_products?: boolean;
  filter_status?: boolean;
});

Favorites

import { favoriteApi } from 'buymeua-api-fe';

// Get favorite count
const { data } = favoriteApi.useGetFavoriteCountQuery();

// Get favorite merchants
const { data, fetchNextPage, hasNextPage } = favoriteApi.useGetFavoriteMerchantsInfiniteQuery({
  per_page?: number;
});

// Get favorite merchant items
const { data, fetchNextPage, hasNextPage } = favoriteApi.useGetFavoriteMerchantItemsInfiniteQuery({
  merchant_id: number;
});

// Add to favorites
const [addToFavorite] = favoriteApi.useAddFavoriteMerchantItemMutation();
await addToFavorite({
  product_type: 'buyme' | 'supplier';
  product_id: number;
  optimisticUpdate?: {
    product: BaseProduct; // For optimistic UI updates
  };
});

// Remove from favorites
const [removeFromFavorite] = favoriteApi.useDeleteFavoriteMerchantItemMutation();
await removeFromFavorite({
  product_type: 'buyme' | 'supplier';
  product_id: number;
  optimisticUpdate?: {
    product: BaseProduct; // For optimistic UI updates
  };
});

Chat

import { chatApi } from 'buymeua-api-fe';

// Get chat list
const { data, fetchNextPage, hasNextPage } = chatApi.useGetChatsInfiniteQuery({
  per_page?: number;
});

// Get chat info
const { data } = chatApi.useGetChatInfoQuery({
  customerChatThread: number;
});

// Get chat messages
const { data, fetchNextPage, hasNextPage } = chatApi.useGetChatInfiniteQuery({
  customerChatThreadId: number;
  per_page?: number;
});

// Get single chat message
const { data } = chatApi.useGetChatMessageQuery({
  customerChatThreadId: number;
  customerChatId: number;
});

// Create chat
const [createChat] = chatApi.useCreateChatMutation();
await createChat({
  customer_id: number;
  supplier_id?: number; // Required if admin_id not provided
  admin_id?: number; // Required if supplier_id not provided
});

// Send message
const [sendMessage] = chatApi.useSendChatMessageMutation();
await sendMessage({
  customerChatThreadId: number;
  message: string;
  supplier_story_id?: number; // ID of supplier story being replied to
  medias?: File[];
});

// Update message
const [updateMessage] = chatApi.useUpdateChatMessageMutation();
await updateMessage({
  customerChatThreadId: number;
  customerChatId: number;
  message: string;
  medias?: File[];
});

// Mark messages as read
const [markAsRead] = chatApi.useMarkChatMessagesAsReadMutation();
await markAsRead({
  customerChatThreadId: number;
  chats: number[]; // Message IDs
});

// Mark all messages as read
const [markAllAsRead] = chatApi.useMarkAllChatMessagesAsReadMutation();
await markAllAsRead({
  customerChatThreadId: number;
});

// Delete chat
const [deleteChat] = chatApi.useDeleteChatMutation();
await deleteChat({
  customerChatThread: number;
  customer_id: number;
});

// Delete message
const [deleteMessage] = chatApi.useDeleteChatMessageMutation();
await deleteMessage({
  customerChatThread: number;
  chat: number; // Message ID
});

// Resend message
const [resendMessage] = chatApi.useResendChatMessageMutation();
await resendMessage({
  customerChatThreadId: number;
  customerChatId: number;
  message: string;
  medias?: File[];
});

// Get chat warnings
const { data } = chatApi.useGetChatWarningsQuery({
  customerChatThread: number;
});
// Real-time updates are automatically enabled via Pusher WebSocket

// Acknowledge chat warning
const [acknowledgeWarning] = chatApi.useAcknowledgeChatWarningMutation();
await acknowledgeWarning({
  customerChatThread: number;
  warning: number;
});

Notifications

import { notificationApi } from 'buymeua-api-fe';

// Get notifications
const { data, fetchNextPage, hasNextPage } = notificationApi.useGetNotificationsInfiniteQuery({
  per_page?: number;
  'filter[type]'?: string;
  'filter[event]'?: string;
  'filter[date_from]'?: string;
  'filter[date_to]'?: string;
});

// Get single notification
const { data } = notificationApi.useGetNotificationQuery({
  notification: number;
});

// Get notifications count
const { data } = notificationApi.useGetNotificationsCountQuery();

// Get new suppliers count
const { data } = notificationApi.useGetNewSuppliersCountQuery();

// Mark all as read
const [markAllAsRead] = notificationApi.useMarkAllNotificationsAsReadMutation();
await markAllAsRead();

// Mark single notification as read
const [markAsRead] = notificationApi.useMarkNotificationAsReadMutation();
await markAsRead({ notification: number });

// Delete all notifications
const [deleteAll] = notificationApi.useDeleteAllNotificationsMutation();
await deleteAll();

// Delete single notification
const [deleteNotification] = notificationApi.useDeleteNotificationMutation();
await deleteNotification({ notification: number });

Stories

import { storiesApi } from 'buymeua-api-fe';

// Get stories
const { data, fetchNextPage, hasNextPage } = storiesApi.useGetStoriesInfiniteQuery({
  sort_type?: 'created_at' | 'views_count' | 'sort_order' | 'viewed_order';
  sort_direction?: 'asc' | 'desc';
  per_page?: number;
});

// Increase story views
const [increaseViews] = storiesApi.useIncreaseStoryViewsMutation();
await increaseViews({ story: number });

// Get suppliers with stories (infinite scroll)
const { data, fetchNextPage, hasNextPage } = storiesApi.useGetSuppliersWithStoriesInfiniteQuery({
  per_page?: number;
});

// Get suppliers with stories (pagination)
const { data } = storiesApi.useGetPaginatedSuppliersWithStoriesQuery({
  page?: number;
  per_page?: number;
});

// Get all active stories for a supplier (flat list across all groups)
const { data } = storiesApi.useGetSupplierStoriesQuery({
  customer: number;
});

// Get supplier story groups
const { data } = storiesApi.useGetSupplierStoryGroupsQuery({
  customer: number;
});

// Get stories in a group
const { data } = storiesApi.useGetSupplierStoryGroupStoriesQuery({
  customer: number;
  supplierStoryGroup: number;
});

// Save story statistics
const [saveStats] = storiesApi.useSaveSupplierStoryStatisticsMutation();
await saveStats({
  supplierStory: number;
  type: 'view' | 'like' | 'unlike' | 'share' | 'reply';
  // Optional: triggers optimistic cache update (only for view, like, unlike)
  optimisticUpdate?: { customer: number; supplierStoryGroup: number };
});

Suppliers

import { supplierApi } from 'buymeua-api-fe';

// Get suppliers list
const { data, fetchNextPage, hasNextPage } = supplierApi.useGetSuppliersInfiniteQuery({
  per_page?: number;
  search?: string;
  filter_buyme_category_ids?: number[];
});

// Get supplier info
const { data } = supplierApi.useGetSupplierInfoQuery({
  customer: number;
});

// Get supplier articles
const { data, fetchNextPage, hasNextPage } = supplierApi.useGetSupplierArticlesInfiniteQuery({
  customer: number;
  per_page?: number;
  'filter[id]'?: number;
  'filter[translations.title]'?: string;
  'filter[translations.content]'?: string;
  'filter[date_from]'?: string;
  'filter[date_to]'?: string;
});

// Get supplier reviews
const { data, fetchNextPage, hasNextPage } = supplierApi.useGetSupplierReviewsInfiniteQuery({
  supplier_id: number;
  per_page?: number;
  rating?: number;
  has_reply?: boolean;
  date_from?: string;
  date_to?: string;
  sort_by?: 'rating' | 'created_at';
  sort_direction?: 'asc' | 'desc';
});

// Add supplier review
const [addReview] = supplierApi.useAddSupplierReviewMutation();
await addReview({
  supplier_id: number;
  rating: number;
  text: string;
});

// Reply to supplier review
const [replyToReview] = supplierApi.useReplyToSupplierReviewMutation();
await replyToReview({
  review_id: number;
  reply_text: string;
});

// Mark supplier as old
const [markAsOld] = supplierApi.useMarkSupplierAsOldMutation();
await markAsOld({ supplier: number });

Nova Poshta

import { novaposhtaApi } from 'buymeua-api-fe';

// Get Nova Poshta cities
const { data, fetchNextPage, hasNextPage } = novaposhtaApi.useGetNovaposhtaCitiesInfiniteQuery({
  search?: string;
  area?: string;
  settlement_type?: string;
  is_branch?: boolean;
  per_page?: number;
});

// Get Nova Poshta streets
const { data, fetchNextPage, hasNextPage } = novaposhtaApi.useGetNovaposhtaStreetsInfiniteQuery({
  search?: string;
  city_ref: string;
  streets_type?: string;
  per_page?: number;
});

// Get Nova Poshta warehouses
const { data, fetchNextPage, hasNextPage } = novaposhtaApi.useGetNovaposhtaWarehousesInfiniteQuery({
  search?: string;
  city_ref: string;
  type?: string;
  per_page?: number;
});

Orders

import { orderApi } from 'buymeua-api-fe';

// Get orders list with infinite scroll
const { data, fetchNextPage, hasNextPage } = orderApi.useGetOrdersInfiniteQuery({
  search?: string;
  filter_order_id?: number;
  filter_customer_id?: number;
  filter_is_ttn_custom?: boolean;
  filter_drop_name?: string;
  filter_date_added?: string;
  filter_drop_email?: string;
  filter_customer_telephone?: string;
  filter_customer_name?: string;
  filter_drop_telephone?: string;
  filter_email?: string;
  filter_old_novaposhta_cn_number?: string;
  filter_novaposhta_cn_number?: string;
  filter_order_status_id?: number[];
  filter_products_model?: string;
  filter_products_name?: string;
  filter_with_store?: boolean;
  filter_without_store?: boolean;
});

// Check telephone number (blacklist, duplicates)
const { data } = orderApi.useCheckTelephoneQuery({
  telephone: string;
});

// Get delivery methods for merchant
const { data } = orderApi.useGetDeliveryMethodsQuery({
  merchant_id: number;
});

// Get payment methods for merchant
const { data } = orderApi.useGetPaymentMethodsQuery({
  merchant_id: number;
  custom_ttn?: string;
  delivery_method_code?: string;
});

// Create order
const [createOrder] = orderApi.useCreateOrderMutation();
await createOrder({
  merchant_id: number;
  payment_method_code: string;
  delivery_method_code?: string;
  custom_ttn?: string;
  firstname?: string;
  lastname?: string;
  middlename?: string;
  telephone?: string;
  contact_method?: 'telegram' | 'viber' | 'phone';
  email?: string;
  comment?: string;
  city_ref?: string;
  warehouse_ref?: string;
  shipping_street_id?: number;
  shipping_house?: string;
  shipping_flat?: string;
  country_id?: number;
  city?: string;
  address?: string;
  total_pay?: number;
  custom_customer_id?: number;
  category_order_id?: number;
  ad_platform_page_id?: number;
  ad_new_client?: boolean;
});

Referrals

import { referralApi } from 'buymeua-api-fe';

// Get referral statistics
const { data, fetchNextPage, hasNextPage } = referralApi.useGetReferralStatisticsInfiniteQuery({
  date_from?: string;
  date_to?: string;
  per_page?: number;
});

// Get referral transactions
const { data, fetchNextPage, hasNextPage } = referralApi.useGetReferralTransactionsInfiniteQuery({
  referral_id: number;
  date_from?: string;
  date_to?: string;
  per_page?: number;
});

// Track referral visit
const [trackVisit] = referralApi.useTrackReferralVisitMutation();
await trackVisit({
  referral_id: number;
});

Ads

import { adApi } from 'buymeua-api-fe';

// Get ad pages
const { data } = adApi.useGetAdPagesQuery({
  platform_id: number;
});

// Get ad platforms
const { data, fetchNextPage, hasNextPage } = adApi.useGetAdPlatformsInfiniteQuery({
  per_page?: number;
});

Countries

import { countryApi } from 'buymeua-api-fe';

// Get countries list
const { data, fetchNextPage, hasNextPage } = countryApi.useGetCountriesInfiniteQuery({
  search?: string;
  per_page?: number;
});

Store

import { storeApi } from 'buymeua-api-fe';

// Get list of current user's stores
const { data, fetchNextPage, hasNextPage } = storeApi.useGetStoresInfiniteQuery({
  per_page?: number;
});

// Get store information
const { data } = storeApi.useGetStoreQuery({
  store: number;
});

// Get available store domains
const { data } = storeApi.useGetStoreDomainsQuery();

// Validate store domain availability
const [validateDomain] = storeApi.useValidateStoreDomainMutation();
await validateDomain({
  link: string; // "my-store"
  store_domain_id?: number;
});

// Get store platforms (web, mobile) with prices
const { data } = storeApi.useGetStorePlatformsQuery();

// Create new store (wizard step 1)
const [createStore] = storeApi.useCreateStoreMutation();
await createStore({
  store_types: ('web' | 'mobile')[];
  name: string;
  link?: string;
  store_domain_id?: number;
  custom_domain_name?: string;
  store_template_id?: number;
  logo?: File;
  icon_mobile?: File;
  favicon?: File;
});

// Update store wizard steps (1-6)
const [updateWizard] = storeApi.useUpdateStoreWizardMutation();
await updateWizard({
  store: number;
  current_step: 1 | 2 | 3 | 4 | 5 | 6;
  // ... other step-specific fields
});

// Pay for store creation
const [payStore] = storeApi.usePayStoreCreationMutation();
await payStore({
  store: number;
});

// Update store analytics settings
const [updateAnalytics] = storeApi.useUpdateStoreAnalyticsMutation();
await updateAnalytics({
  store: number;
  gtm_id?: string;
  fb_pixel_id?: string;
  tt_pixel_id?: string;
  ga_tracking_id?: string;
  facebook_domain_verification?: string;
  google_domain_verification?: string;
  google_merchant_id?: string;
  enable_cookie_consent?: boolean;
  gtm_custom_enabled: boolean;
  gtm_custom_script_url?: string;
  gtm_custom_noscript_url?: string;
});

// Cache behavior:
// - getStore provides Store tags (specific store id + LIST)
// - payStoreCreation and updateStoreWizard invalidate Store tag by store id
// - active useGetStoreQuery({ store }) subscriptions refetch automatically

System

import { systemApi } from 'buymeua-api-fe';

// Get maintenance status (with real-time Pusher updates)
const { data } = systemApi.useGetMaintenanceStatusQuery();
// data.enable: boolean - true if system is available

// Get version check for mobile apps (with real-time Pusher updates)
const { data } = systemApi.useGetVersionCheckQuery();
// data.ios.minimumVersion, data.ios.lastUpdatedVersion
// data.android.minimumVersion, data.android.lastUpdatedVersion

// Check if Telegram user exists
const { data } = systemApi.useCheckTelegramUserQuery({
  telegram_user_name: 'username', // without @
});
// data.success: boolean

📋 TypeScript Types

The library is fully typed with TypeScript. Main types:

interface ApiConfig {
  baseUrl: string;
  prepareHeaders?: (
    headers: Headers,
    api: {
      getState: () => unknown;
      extra: unknown;
      endpoint: string;
      type: 'query' | 'mutation';
      forced?: boolean;
    } & {
      arg: unknown;
      extraOptions: unknown;
    },
  ) => Headers | void | Promise<void>;
  onUnauthorized?: (
    args: string | FetchArgs,
    api: BaseQueryApi,
    extraOptions: unknown,
  ) => void;
}

enum Session {
  Dropshipper = 'dropshipper',
  Supplier = 'supplier',
  Retail = 'retail',
}

interface PaginatedResponse {
  meta: {
    current_page: number;
    last_page: number;
    per_page: number;
    total: number;
    from: number;
    to: number;
  };
  links: {
    first: string;
    last: string;
    prev: string | null;
    next: string | null;
  };
}

📄 License

ISC License - see the LICENSE file for details.