Skip to content

Client options ​

createMxik() works without options. These are the defaults:

OptionDefaultDescription
lang'ru'Language of names in results: 'ru' or 'uz'
pageSize20Page size for search, filter and dvCert
timeout10000Request timeout in ms, 0 disables it
cachefalsetrue or your own cache, see Cache
baseURLtasnif.soliq.uzAPI root, see Proxy
fetchglobalThis.fetchSee Custom fetch
headersHeaders added to every request

The full default baseURL is https://tasnif.soliq.uz/api/cls-api.

ts
const mxik = createMxik({
  lang: 'uz',
  pageSize: 50,
  timeout: 5000,
})

Per request ​

Every method takes options as its last argument. They override the client defaults for that call:

OptionMethodsDescription
langallLanguage of names
signalallAbortSignal to cancel the request
pagesearch, filter, dvCertPage number, starting from 1
sizepaginated and *All methodsPage size
ts
await mxik.search('кофе', {
  page: 2,
  lang: 'uz',
  signal: AbortSignal.timeout(3000),
})

Proxy ​

If your server can't reach tasnif.soliq.uz directly, put a proxy in Uzbekistan in front of it and point baseURL at it. Paths and query strings stay the same:

ts
const mxik = createMxik({
  baseURL: 'https://mxik-proxy.example.uz/api/cls-api',
  headers: { authorization: `Bearer ${process.env.PROXY_TOKEN}` },
})

Custom fetch ​

Pass your own fetch for runtimes without a global one, for logging, or to mock the API in tests:

ts
const mxik = createMxik({
  fetch: async () => Response.json({
    success: true,
    data: [{ mxikCode: '00901001001048023' }],
    recordTotal: 1,
  }),
})

const { items } = await mxik.search('anything')
items[0].mxikCode // '00901001001048023'

Destructuring ​

The client is a plain object without this, so methods work on their own:

ts
const { search, get } = createMxik()

Unofficial client, not affiliated with the Tax Committee of Uzbekistan or tasnif.soliq.uz.
Released under the MIT License.