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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@xapi-js/core

v1.3.0

Published

Core utilities and types for X-API.

Downloads

25

Readme

@xapi-ts/core

This package provides core utilities and types for working with X-API data.

Installation

# npm
npm install @xapi-ts/core

# yarn
yarn add @xapi-ts/core

# pnpm
pnpm add @xapi-ts/core

# bun
bun add @xapi-ts/core

# deno
deno add @xapi-ts/core

Usage

@xapi-ts/core provides the fundamental classes and functions for working with X-API data.

Parsing X-API XML

You can parse an X-API XML string into an XapiRoot object:

import { parse, XapiRoot } from '@xapi-ts/core';

const xmlString = `<?xml version="1.0" encoding="UTF-8"?>
<Root xmlns="http://www.tobesoft.com/platform/Dataset" ver="4000">
  <Parameters>
    <Parameter id="service">stock</Parameter>
    <Parameter id="method">search</Parameter>
  </Parameters>
</Root>`;

const xapi = parse(xmlString);
console.log('Service:', xapi.getParameter('service')?.value);
console.log('Method:', xapi.getParameter('method')?.value);

Creating and Manipulating XapiRoot

You can create an XapiRoot object and add parameters and datasets programmatically:

import { XapiRoot, Dataset } from '@xapi-ts/core';

const xapi = new XapiRoot();

// Add parameters
xapi.addParameter({ id: 'resultCode', value: '0' });
xapi.addParameter({ id: 'resultMsg', value: 'SUCCESS' });

// Create and add a dataset
const usersDataset = new Dataset('users');
usersDataset.addColumn({ id: 'id', type: 'INT' });
usersDataset.addColumn({ id: 'name', type: 'STRING' });

usersDataset.newRow();
usersDataset.setColumn(0, 'id', 1);
usersDataset.setColumn(0, 'name', 'Alice');

usersDataset.newRow();
usersDataset.setColumn(1, 'id', 2);
usersDataset.setColumn(1, 'name', 'Bob');

xapi.addDataset(usersDataset);

console.log('XapiRoot created:', xapi);

Serializing XapiRoot to XML

You can serialize an XapiRoot object back into an X-API XML string:

import { write, XapiRoot, Dataset } from '@xapi-ts/core';

const xapi = new XapiRoot();
xapi.addParameter({ id: 'status', value: 'OK' });

const productsDataset = new Dataset('products');
productsDataset.addColumn({ id: 'productId', type: 'STRING' });
productsDataset.addColumn({ id: 'price', type: 'INT' });
productsDataset.newRow();
productsDataset.setColumn(0, 'productId', 'P001');
productsDataset.setColumn(0, 'price', 1000);
xapi.addDataset(productsDataset);

const xmlOutput = write(xapi);
console.log('Generated XML:\n', xmlOutput);

@xapi-ts/core

이 패키지는 X-API 데이터를 다루기 위한 핵심 유틸리티 및 타입을 제공합니다.

설치

# npm
npm install @xapi-ts/core

# yarn
yarn add @xapi-ts/core

# pnpm
pnpm add @xapi-ts/core

# bun
bun add @xapi-ts/core

# deno
deno add @xapi-ts/core

사용법

@xapi-ts/core는 X-API 데이터를 다루기 위한 기본적인 클래스와 함수를 제공합니다.

X-API XML 파싱

X-API XML 문자열을 XapiRoot 객체로 파싱할 수 있습니다:

import { parse, XapiRoot } from '@xapi-ts/core';

const xmlString = `<?xml version="1.0" encoding="UTF-8"?>
<Root xmlns="http://www.tobesoft.com/platform/Dataset" ver="4000">
  <Parameters>
    <Parameter id="service">stock</Parameter>
    <Parameter id="method">search</Parameter>
  </Parameters>
</Root>`;

const xapi = parse(xmlString);
console.log('서비스:', xapi.getParameter('service')?.value);
console.log('메서드:', xapi.getParameter('method')?.value);

XapiRoot 생성 및 조작

XapiRoot 객체를 생성하고 매개변수 및 데이터셋을 프로그래밍 방식으로 추가할 수 있습니다:

import { XapiRoot, Dataset } from '@xapi-ts/core';

const xapi = new XapiRoot();

// 매개변수 추가
xapi.addParameter({ id: 'resultCode', value: '0' });
xapi.addParameter({ id: 'resultMsg', value: 'SUCCESS' });

// 데이터셋 생성 및 추가
const usersDataset = new Dataset('users');
usersDataset.addColumn({ id: 'id', type: 'INT' });
usersDataset.addColumn({ id: 'name', type: 'STRING' });
let rowIdx: number;
rowIdx = usersDataset.newRow();
usersDataset.setColumn(rowIdx, 'id', 1);
usersDataset.setColumn(rowIdx, 'name', 'Alice');

rowIdx = usersDataset.newRow();
usersDataset.setColumn(rowIdx, 'id', 2);
usersDataset.setColumn(rowIdx, 'name', 'Bob');

xapi.addDataset(usersDataset);

console.log('XapiRoot 생성됨:', xapi);

XapiRoot를 XML로 직렬화

XapiRoot 객체를 X-API XML 문자열로 다시 직렬화할 수 있습니다:

import { write, XapiRoot, Dataset } from '@xapi-ts/core';

const xapi = new XapiRoot();
xapi.addParameter({ id: 'status', value: 'OK' });

const productsDataset = new Dataset('products');
productsDataset.addColumn({ id: 'productId', type: 'STRING' });
productsDataset.addColumn({ id: 'price', type: 'INT' });
productsDataset.newRow();
productsDataset.setColumn(0, 'productId', 'P001');
productsDataset.setColumn(0, 'price', 1000);
xapi.addDataset(productsDataset);

const xmlOutput = write(xapi);
console.log('생성된 XML:\n', xmlOutput);