@gofynd/fdk-client-javascript

中文文档
3.36.0发布于 2026/10/23ISCTypeScriptCommonJS构建来源已验证近 30 天下载 1万

GitHub package.json version GitHub Workflow Status ![GitH

原始使用文档
文档目录10 节
  1. Getting Started
  2. Usage
  3. Logging
  4. Sample Usage - ApplicationClient
  5. Sample Usage - PlatformClient
  6. Sample Usage - Request function.
  7. Cookie
  8. Headers
  9. Log Curl
  10. TypeScript

FDK Javascript

GitHub package.json version GitHub Workflow Status GitHub Coverage Status

FDK client for Javascript

Getting Started

Get started with the Javascript Development SDK for Fynd Platform

Usage

Node

npm install @gofynd/fdk-client-javascript

Using this method, you can require fdk-client-javascript like so:

const {
  ApplicationClient,
} = require("fdk-client-javascript");

Browser

you can load fdk-client-javascript's application browser bundle from CDN; ApplicationClient and ApplicationModels will be attached to browser's window object.

<script src="https://cdn.jsdelivr.net/gh/gofynd/fdk-client-javascript@<version>/dist/application.js"></script>

Install Specific version

<script src="https://cdn.jsdelivr.net/gh/gofynd/[email protected]/dist/application.js"></script>
const { ApplicationClient } = window;

Logging

For logging support user can pass logLevel in ApplicationClient or PlatformClient while declaration.

Available logging levels: TRACE, DEBUG, INFO, WARN, ERROR.

Default log level: ERROR

Sample Usage - ApplicationClient

const applicationClient = new ApplicationClient({
  applicationID: "YOUR_APPLICATION_ID",
  applicationToken: "YOUR_APPLICATION_TOKEN",
  locationDetails: "LOCATION_DETAILS_OBJECT"
});

applicationClient.setLocationDetails({ 
  pincode:"385001",
  country: "India",
  city:  "Ahmedabad",
  location: {longitude: "72.585022", latitude: "23.033863"}
  });


async function getProductDetails() {
  try {
    const product = await applicationClient.catalog.getProductDetailBySlug({
        slug: "product-slug"
      });
    console.log(product.name);
  } catch (err) {
    console.log(err);
  }
}

getProductDetails();

Sample Usage - PlatformClient

const { PlatformClient } = require("fdk-client-javascript");

async function getData() {
  try {
    const client = new PlatformClient({
      companyId: "COMPANY_ID",
      apiKey: "API_KEY", 
      apiSecret: "API_SECRET", 
      domain: "DOMAIN",
      useAutoRenewTimer: true // Setting `true` will use timer based logic to refresh the access token. With `false` will issue refresh token just before any api call when it is expired. 
    });

    const token = await platformClient.getAccesstokenObj({
      grant_type: 'client_credentials'    
    })
    
    platformClient.setToken(token);

    // API's without application_id
    const tickets = await client.lead.getTickets();
    console.log("tickets", tickets);

    // API's with application_id
    const customers = await client
      .application("APPLICATION_ID")
      .user.getCustomers();
    console.log("customers", customers);
  } catch (err) {
    console.log(err);
  }
}

getData();

Sample Usage - Request function.

The request function allows you to make custom API requests with ease. It is available on both platform and application client.


let auditLog = await client.request({
    url: `/service/platform/audit-trail/v1.0/company/1/logs`,
    method: 'GET',
});

The request function accepts an object with the following possible keys:

  • method (string): The HTTP method to use (e.g., 'GET', 'POST', 'PUT', 'DELETE').
  • url (string): The URL endpoint for the request.
  • query (object): Query parameters to include in the request URL.
  • body (object): The request payload to send.
  • headers (object): Additional headers to include in the request.

Following code snippet will read and write cookies on behalf of you
Cookies will get appended in subsequent requests.

const { FdkAxios } = require('@gofynd/fdk-client-javascript');
const { wrapper } =  require("axios-cookiejar-support");
const { CookieJar } = require("tough-cookie");


wrapper(FdkAxios);
const cookieJar = new CookieJar();
FdkAxios.defaults.jar = cookieJar;


module.exports = cookieJar

get the stored cookie from the CookieJar instance

const cookieJar = require('path/to/cookieJar') // replace with actual path

let cookies = await cookieJar.getCookies("https://api.fynd.com");

Headers

Adding Request Headers

To include request headers when calling a method, add requestHeaders object in the first argument.

const requestHeaders = {
  "x-api-version": "1.0"
}

const options = {
  responseHeaders: true
}

const [response, headers] = await platformClient.application("<APPLICATION_ID>").theme.getAllPages({theme_id: "<THEME_ID>", requestHeaders: requestHeaders}, options);

get Response Headers

To retrieve the response headers, simply set the responseHeaders option to true when calling the desired method. Below is an example demonstrating how to achieve this:

const options = {
  responseHeaders: true
}
const [response, headers] = await platformClient.application("<APPLICATION_ID>").theme.getAllPages({theme_id: "<THEME_ID>"}, options);

console.log("[API RESPONSE]: ", response);
console.log("[RESPONSE HEADERS]: ", headers);

Log Curl

To print the curl command in the console for all network calls made using applicationClient or platformClient, set the logger level to debug.

const {
  ApplicationClient,
} = require("fdk-client-javascript");

let applicationClient = new ApplicationClient({
  applicationID: "YOUR_APPLICATION_ID",
  applicationToken: "YOUR_APPLICATION_TOKEN",
  logLevel: "debug"
});

let response = await applicationClient.theme.getAppliedTheme(); 
console.log("Active Theme: ", response.information.name);

The above code will log the curl command in the console

curl --request GET "https://api.fynd.com/service/application/theme/v1.0/applied-theme" --header 'authorization: Bearer <authorization-token>' --header 'x-fp-sdk-version: 3.36.0' --header 'x-fp-date: 20230222T115108Z' --header 'x-fp-signature: v1.1:1e3ab3b02b5bc626e3c32a37ee844266ade02bbcbaafc28fc7a0e46a76a7a1a8'
Active Theme: Emerge

TypeScript

fdk-client-javascript includes Typescript definitions.

import { ApplicationClient } from "fdk-client-javascript";

版本与发布记录

@gofynd/fdk-client-javascript 共发布 162 个版本,首次发布于 2023/01/19;过去 12 个月发布了 29 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
3.36.0latest2026/10/2324 天前
1.4.15-beta.17beta2026/10/2225 天前
3.35.02026/09/112 个月前
3.34.02026/08/202 个月前
1.4.15-beta.162026/08/113 个月前
3.33.02026/08/053 个月前

关于 @gofynd/fdk-client-javascript 的常见问题

@gofynd/fdk-client-javascript 是什么?

![GitH

如何安装 @gofynd/fdk-client-javascript?

在项目目录运行 npm install @gofynd/fdk-client-javascript,或使用 pnpm add / yarn add / bun add。

@gofynd/fdk-client-javascript 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@gofynd/fdk-client-javascript 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@gofynd/fdk-client-javascript 可以商用吗?

@gofynd/fdk-client-javascript 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@gofynd/fdk-client-javascript 的下载量有多少?

根据 npm 官方下载统计,@gofynd/fdk-client-javascript 在 2026/10/17 – 2026/11/15 这 30 天内被下载 10,118 次,日均约 337 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@gofynd/fdk-client-javascript 还在维护吗?

最新版本 3.36.0 发布于 2026/10/23(24 天前);至今共发布 162 个版本,其中过去 12 个月发布了 29 个;首次发布于 2023/01/19。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。