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

otapi-client

v1.0.11

Published

TypeScript client for OTApi e-commerce REST API

Readme

otapi-client

TypeScript client for the OTApi e-commerce REST API.

Installation

npm install otapi-client

Quick Start

import { OTClient } from "otapi-client";

const client = new OTClient("your-instance-key", {
  language: "en",
  secret: "your-secret", // optional, enables request signing
  debug: true,           // optional, logs responses
});

// Get an anonymous session
const session = await client.GetAnonymousSession();
console.log(session.Result);

Configuration

interface OTClientConfig {
  language?: string;  // Response language (default: "en")
  secret?: string;    // Secret key for HMAC request signing
  baseUrl?: string;   // API base URL (default: "https://otapi.net/service-json")
  debug?: boolean;    // Log API responses to console (default: false)
}

Methods

Session & Authentication

GetAnonymousSession()

Creates a new anonymous session.

const res = await client.GetAnonymousSession();
const sessionId = res.Result.Id;

Authenticate(params)

Authenticates a user with login and password.

await client.Authenticate({
  sessionId: "...",       // optional
  userLogin: "user",
  userPassword: "pass",
  rememberMe: true,       // optional
});

AuthenticateInstanceOperator(params)

Authenticates an instance operator.

await client.AuthenticateInstanceOperator({
  userLogin: "operator",
  userPassword: "pass",
});

AuthenticateAsUser(params)

Authenticates as a specific user (requires operator session).

await client.AuthenticateAsUser({
  sessionId: "operator-session-id",
  userLogin: "target-user",
});

RegisterUser(params)

Registers a new user.

await client.RegisterUser({
  sessionId: "...",          // optional
  userParameters: "<xml>",
});

Items & Search

BatchGetItemFullInfo(params)

Gets full information for an item.

await client.BatchGetItemFullInfo({
  sessionId: "...",          // optional
  itemId: "item-123",
  itemParameters: "...",     // optional
  blockList: ["Vendor", "Description"], // optional, exclude specific blocks
});

blockList values: "DeliveryCosts" | "Promotions" | "Vendor" | "RootPath" | "ProviderReviews" | "MostPopularVendorItems16" | "RecommendedItems" | "Description" | "OriginalDescription"

BatchSearchItemsFrame(params)

Searches for items with pagination.

await client.BatchSearchItemsFrame({
  sessionId: "...",          // optional
  xmlParameters: {
    ItemTitle: "phone case",
    MinPrice: 10,
    MaxPrice: 100,
    CategoryId: "cat-123",
    OrderBy: "Price",
    Configurators: [{ Pid: "1", Vid: "2" }],
    Features: [{ Name: "FreeShipping", value: true }],
  },
  framePosition: 0,
  frameSize: 20,
  blockList: ["SubCategories"], // optional
});

blockList values: "SubCategories" | "SearchProperties" | "RootPath" | "Vendor" | "Brand" | "Category" | "HintCategories" | "AvailableSearchMethods"

Full SearchItemsParameters fields:

| Field | Type | Description | |---|---|---| | Provider | string | Provider name | | SearchMethod | string | Search method to use | | CategoryId | string | Filter by category | | VendorName | string | Filter by vendor name | | VendorId | string | Filter by vendor ID | | VendorAreaId | string | Filter by vendor area | | ItemTitle | string | Search query text | | LanguageOfQuery | string | Language of the search query | | MinPrice / MaxPrice | number | Price range filter | | EnableDirectSearch | boolean | Enable direct search mode | | CurrencyCode | string | Currency for prices | | MinVolume / MaxVolume | number | Volume range filter | | MinVendorRating / MaxVendorRating | number | Vendor rating range | | BrandId | string | Filter by brand | | Configurators | SearchConfigurator[] | Product configurators ({ Pid, Vid }) | | OrderBy | string | Sort order | | OutputMode | string | Output mode | | CategoryMode | string | Category mode | | IsTmall | boolean | Tmall items only | | StuffStatus | string | Item condition | | Features | SearchFeature[] | Search features ({ Name, value }) | | UseOptimalFrameSize | boolean | Auto-optimize page size | | MinFirstLot / MaxFirstLot | number | First lot range | | MinUpdatedTime / MaxUpdatedTime | string | Updated time range | | MinCreatedTime / MaxCreatedTime | string | Created time range | | Module | string | Module name | | ImageUrl | string | Image search URL | | ImageFileId | string | Image file ID for search | | ImageItemId | string | Image item ID for search |

Catalog

GetRootCategoryInfoList()

Returns the root category list.

const categories = await client.GetRootCategoryInfoList();

GetBrandInfoList()

Returns the brand list.

const brands = await client.GetBrandInfoList();

Orders

AddOrder(params)

Creates a new order.

await client.AddOrder({
  sessionId: "...",          // optional
  xmlAddData: {
    DeliveryModeId: "dm-1",  // optional
    Comment: "Rush order",   // optional
    UserProfileId: "up-1",   // optional
    Items: [
      {
        Id: "item-123",
        Quantity: 2,
        ConfigurationId: "...", // optional
        Weight: 0.5,           // optional
        Comment: "...",        // optional
        PromotionId: "...",    // optional
        PriceType: "...",      // optional
      },
    ],
  },
});

SearchOrdersForUser(params)

Searches orders for the current user with pagination.

await client.SearchOrdersForUser({
  sessionId: "...",          // optional
  xmlSearchParameters: {
    StatusIdList: [1, 2],          // optional
    IsAwaitingUser: false,         // optional
    IsCancelled: false,            // optional
    IsCompleted: true,             // optional
    ProviderType: "...",           // optional
    IsAvailableForRecreation: false, // optional
  },
  framePosition: 0,
  frameSize: 10,
});

User Profiles

CreateUserProfile(params)

Creates a user delivery profile.

await client.CreateUserProfile({
  sessionId: "session-id",
  createData: {
    FirstName: "John",
    LastName: "Doe",
    CountryCode: "US",
    City: "New York",
    Address: "123 Main St",
    Phone: "+1234567890",
    PostalCode: "10001",
  },
});

Full UserProfileCreateData fields: FirstName, LastName, MiddleName, CountryCode, Region, City, CityCode, Address, Phone, PostalCode, ExternalDeliveryId, PickupPointCode, PassportNumber, ResetPassportIssueDate, PassportIssueDate, RegistrationAddress, INN, EnableValidation

Payments

SalesPaymentReserve(params)

Reserves a payment for a sales order.

await client.SalesPaymentReserve({
  sessionId: "session-id",
  salesId: "sales-123",
  amount: "100.00",
});

PostTransaction(params)

Posts a financial transaction.

await client.PostTransaction({
  sessionId: "...",            // optional
  customerId: "customer-123",
  amount: "50.00",
  isDebit: true,
  comment: "Refund",          // optional
  transactionDate: "2025-01-01", // optional
});

Error Handling

All methods throw OTApiError when the API returns a non-Ok error code.

import { OTApiError } from "otapi-client";

try {
  await client.Authenticate({ userLogin: "x", userPassword: "y" });
} catch (err) {
  if (err instanceof OTApiError) {
    console.log(err.code);    // e.g. "InvalidCredentials"
    console.log(err.message); // error description
  }
}

Response Format

All methods return OTApiResponse<T>:

interface OTApiResponse<T = unknown> {
  ErrorCode: string;
  ErrorDescription?: string;
  Result?: T;
}

License

ISC