PostSync generates fully typed API clients from your Postman collections, ensuring seamless integration with zero manual endpoint coding.
import { createApiClient } from 'postsync';
import postmanCollection from './collection.json';
// Create a type-safe API client
const api = createApiClient(postmanCollection, {
baseUrl: 'https://api.example.com',
headers: {
'Content-Type': 'application/json'
}
});
// Make typed API calls
async function getUser(id) {
const response = await api.users.get.getUserById({
pathParams: { id }
});
return response.data; // Fully typed!
}
Full TypeScript support with auto-generated interfaces for endpoints and responses, catching errors before runtime.
Update your Postman collection and your API client updates automatically - no manual code changes required.
Zero dependencies and tree-shakable codebase ensures minimal impact on your bundle size.
Works seamlessly in server-side rendering environments like Next.js and Remix.
Configure headers, timeouts, and error handling to match your project's requirements.
Use with any JavaScript or TypeScript project, from React to Node.js and beyond.
npm install postsync
Export your collection as JSON from Postman and save it in your project.
import { createApiClient } from 'postsync';
import postmanCollection from './postman-collection.json';
export const api = createApiClient(postmanCollection, {
baseUrl: 'https://api.example.com'
});
Our intuitive API makes integrating with your Postman collections straightforward and type-safe. Here's how to get the most out of PostSync in your projects.
// Initialize your API client
import { createApiClient } from 'postsync';
import postmanCollection from './collection.json';
const api = createApiClient(postmanCollection, {
baseUrl: 'https://api.example.com'
});
// GET request with path parameters
const user = await api.users.get.getUserById({
pathParams: { id: '123' }
});
// POST request with JSON body
const newPost = await api.posts.post.createPost({
body: {
title: 'New Post',
content: 'Post content'
}
});
// GET request with query parameters
const filteredProducts = await api.products.get.searchProducts({
queryParams: {
category: 'electronics',
sort: 'price'
}
});
PostSync organizes your endpoints logically by resource, HTTP method, and operation name:
api.resourceGroup.httpMethod.endpointName(options)
try {
const response = await api.users.get.getUserById({
pathParams: { id: '123' }
});
// Access the response data
if (response.ok) {
console.log(response.data); // Typed response data
console.log(response.status); // HTTP status code
console.log(response.headers); // Response headers
}
} catch (error) {
console.error('Error:', error.message);
console.error('Status:', error.status);
console.error('Data:', error.data);
}
const api = createApiClient(postmanCollection, {
// Base URL for all requests
baseUrl: 'https://api.example.com',
// Default headers sent with every request
headers: {
'Authorization': 'Bearer token123',
'Content-Type': 'application/json',
'Accept': 'application/json'
},
// Request timeout in milliseconds
timeoutMs: 10000,
// Retry configuration (optional)
retryConfig: {
maxRetries: 3,
retryDelay: 1000,
retryableStatusCodes: [408, 429, 500, 502, 503, 504]
}
});
Get full IntelliSense support and type checking for all your API calls and responses.
Use PostSync in server environments like Next.js with our SSR-friendly implementation.
Add custom logic to modify requests before they're sent or process responses.