Your API routes,
auto-synced to APIYatra
Install the apiyatra package in your Node.js project. Every route you define automatically appears as a ready-to-test request in your APIYatra workspace — no manual copy-paste, ever.
How it works
4 steps from install to testing
Install the package
Add apiyatra to your Node.js project with a single command.
npm install apiyatra
Get your workspace credentials
Open APIYatra → Workspace Settings → copy your Secret ID and Secret Code.
# From APIYatra Workspace Settings Secret ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx Secret Code: your-secret-code
Call syncYatra in your app
Pass your existing Express routes array — the same one you already use to mount routes.
import { syncYatra } from 'apiyatra';
import authRouter from './modules/auth/auth.routes';
import usersRouter from './modules/users/users.routes';
await syncYatra({
secretId: 'your-workspace-secret-id',
secretCode: 'your-workspace-secret-code',
collectionName: 'My App APIs',
expressRoutes: [
{ path: '/api/v1/auth', route: authRouter },
{ path: '/api/v1/users', route: usersRouter },
],
});Open APIYatra — done
Your collection appears instantly with all routes organized into folders, ready to test.
✓ Collection 'My App APIs' synced
📁 Auth
POST /api/v1/auth/register
POST /api/v1/auth/login
POST /api/v1/auth/refresh
📁 Users
GET /api/v1/users
GET /api/v1/users/:id
PATCH /api/v1/users/:id
DELETE /api/v1/users/:idMultiple integration styles
Works with any Node.js backend setup
Express.js (Auto)
RecommendedPass your Express Router directly — package auto-extracts every route, method, and path.
import express from 'express';
import { syncYatra } from 'apiyatra';
import * as authValidators from './modules/auth/auth.validator';
const authRouter = express.Router();
authRouter.post('/register', ...);
authRouter.post('/login', ...);
authRouter.post('/refresh', ...);
// One call — all routes synced automatically
await syncYatra({
secretId: process.env.APIYATRA_SECRET_ID,
secretCode: process.env.APIYATRA_SECRET_CODE,
collectionName: 'My Backend APIs',
expressRoutes: [
{
path: '/api/v1/auth',
route: authRouter,
// Optional: pass Zod/Joi/Yup validators
// Package auto-generates request body samples
validators: authValidators,
},
],
});Manual Routes
Define routes manually with full control over names, groups, headers and body examples.
import { syncRoutes } from 'apiyatra';
await syncRoutes({
secretId: process.env.APIYATRA_SECRET_ID,
secretCode: process.env.APIYATRA_SECRET_CODE,
backendUrl: 'https://api.apiyatra.com',
collectionName: 'Payment APIs',
baseUrl: 'https://api.myapp.com',
routes: [
{
method: 'POST',
path: '/api/payments/charge',
name: 'Charge Card',
group: 'Payments',
body: {
amount: 100,
currency: 'USD',
cardToken: 'tok_visa',
},
},
{
method: 'GET',
path: '/api/payments/:id',
name: 'Get Payment',
group: 'Payments',
},
],
});OpenAPI / Swagger
Already have an OpenAPI spec? Use the CLI to sync it directly — no code changes needed.
# 1. Create config file in your project root
# .apiyatra.json
{
"secretId": "your-workspace-secret-id",
"secretCode": "your-workspace-secret-code",
"backendUrl": "https://api.apiyatra.com",
"specFile": "./openapi.yaml",
"collectionName": "My API"
}
# 2. Run the CLI
npx apiyatra sync
# Or add to package.json scripts:
# "sync:api": "apiyatra sync"With Validators
SmartPass your Zod, Joi or Yup validators — package auto-generates realistic request body samples.
import { z } from 'zod';
import { syncYatra } from 'apiyatra';
// Your existing validators
export const createUserSchema = z.object({
name: z.string(),
email: z.string().email(),
password: z.string().min(8),
role: z.enum(['admin', 'user']),
});
// Pass validators — body samples auto-generated:
// { name: "Sample Name", email: "user@example.com",
// password: "password123", role: "admin" }
await syncYatra({
secretId: '...',
secretCode: '...',
collectionName: 'User APIs',
expressRoutes: [
{
path: '/api/v1/users',
route: usersRouter,
validators: { createUserSchema }, // ← just pass exports
},
],
});Ready to sync your APIs?
Create a free APIYatra account, grab your workspace credentials, and have your first collection synced in under 2 minutes.
| Function | Use when |
|---|---|
syncYatra() | You have an Express.js app — auto-extracts all routes |
syncRoutes() | You want manual control over route names, groups, body examples |
apiyatra sync (CLI) | You have an OpenAPI / Swagger spec file |
# .env APIYATRA_SECRET_ID=your-workspace-secret-id APIYATRA_SECRET_CODE=your-workspace-secret-code