Platform API
The Platform API is designed for backend operations and provides features in Fynd Commerce for the sellers. This includes tasks like inventory management, order processing, and other administrative functions. It is used when you need to perform operations that are administrative or management-focused, such as updating product details, managing orders, or handling logistics.
Refer to Platform Rest API for the full list of APIs available.
Using SDK
We recommend using the SDK methods under the platformClient
object to make Platform API calls. These platformClient
methods are provided by our Javascript client library.
Inside API Calls
All routes registered under the fdkExtension.platformApiRoutes
express-router will have platformClient
in the request object.
const { setupFdk } = require("@gofynd/fdk-extension-javascript/express")
const fdkExtension = setupFdk({ ... });
app.use(fdkExtension.platformApiRoutes);
fdkExtension.platformApiRoutes.get('/test/routes', async (req, res, next) => {
let data = await req.platformClient.lead.getTickets();
res.json(data);
});
In Background Tasks
Background tasks running under some consumer or webhook or under any queue can get platform client via fdkExtension.getPlatformClient
method.
function backgroundHandler(company_id) {
const platformClient = await fdkExtension.getPlatformClient(company_id);
let data = await platformClient.lead.getTickets();
// Some business logic here using {data}
}
The access_mode
in the setupFdk
function must be set to 'offline'
to access platformClient
in a background task.
Example
An e-commerce business wants to streamline its order management process by automating the creation of orders through the Fynd Platform API. This will help them manage increased order volumes efficiently, reduce manual data entry errors, and ensure a smoother order fulfillment process.
A customer selects several products from the e-commerce website and proceeds to checkout. Upon completing their payment information and confirming the purchase, the system automatically creates a new order in the backend using the Create Order API.
fdkExtension.platformApiRoutes.post('/create-order', async (req, res, next) => {
try {
// Construct the order details payload
const orderDetails = {"body":{"shipments":[{"line_items":[{"charges":[{"name":"Product Charge","amount":{"currency":"INR","value":1500},"tax":{"name":"GST","rate":18,"amount":{"value":270}},"code":"GST18","type":"tax"}],"quantity":2,"seller_identifier":"seller123","external_line_id":"line123"}],"external_shipment_id":"ship123","location_id":101,"order_type":"ecommerce","tags":[{"slug":"express_delivery","display_text":"Express Delivery"}],"delivery_address_json":{"name":"John Doe","address":"1234 Street, City","pincode":"560034","phone":"9876543210","email":"john.doe@example.com"}}],"billing_info":{"name":"John Doe","address":"1234 Street, City","pincode":"560034","phone":"9876543210","email":"john.doe@example.com"}}};
// Create a new order using the Fynd Order API
// https://partners.fynd.com/help/docs/sdk/latest/platform/company/order#createOrder
const data = await req.platformClient.order.createOrder(orderDetails);
res.json(data)
} catch (err) {
res.status(500).json({ error: err.message })
}
})
Once the API call is successful, the order is recorded in the system with all the necessary details including shipping, billing, and payment information. The customer receives an email and SMS confirmation with their order details and expected delivery date.