What is Jiren?
Jiren is a lightweight, blazing-fast HTTP client for Node.js and Bun that makes fetching data from APIs simple and intuitive. Unlike other HTTP libraries that come with tons of dependencies and complex configurations, Jiren is designed to be minimal yet powerful.
Whether you're building a small script or a large-scale application, Jiren provides a clean and consistent API that gets out of your way and lets you focus on what matters - your application logic.
Why Another HTTP Client?
You might be wondering: why use Jiren when there's Axios, node-fetch, or got? Here's what makes Jiren different:
- 🚀 Blazing Fast - Optimized for performance with minimal overhead
- 📦 Zero Dependencies - No bloated node_modules, just pure functionality
- 🎯 Simple API - Intuitive methods that feel natural to use
- 💪 TypeScript First - Full type safety out of the box
- 🔧 Highly Configurable - Customizable defaults for headers, timeouts, and more
Installation
Getting started with Jiren is as simple as running a single command. Install it using your favorite package manager:
Using npm
npm install jirenUsing Bun
bun add jirenUsing Yarn
yarn add jirenUsing pnpm
pnpm add jirenBasic Usage
Let's start with the basics. Here's how to create a Jiren client and make your first GET request:
import { Jiren } from 'jiren';
// Create a new client instance
const client = new Jiren();
// Make a GET request
const response = await client.get('https://api.example.com/users');
// Access the response data
console.log(response.data);
console.log(response.status); // 200
console.log(response.headers); // Response headersThat's it! No complex configuration needed. Jiren handles all the heavy lifting for you.
Making POST Requests
Sending data to an API is just as straightforward. Jiren automatically handles JSON serialization:
import { Jiren } from 'jiren';
const client = new Jiren();
// Create a new user
const response = await client.post('https://api.example.com/users', {
body: {
name: 'John Doe',
email: 'john@example.com',
role: 'developer'
}
});
console.log(response.data); // The created user
console.log(response.status); // 201Other HTTP Methods
Jiren supports all standard HTTP methods with the same clean API:
PUT Request
// Update an existing resource
const response = await client.put('https://api.example.com/users/123', {
body: {
name: 'John Updated',
email: 'john.updated@example.com'
}
});PATCH Request
// Partially update a resource
const response = await client.patch('https://api.example.com/users/123', {
body: {
email: 'newemail@example.com'
}
});DELETE Request
// Delete a resource
const response = await client.delete('https://api.example.com/users/123');
console.log(response.status); // 204Setting Custom Headers
Need to add authentication or custom headers? Jiren makes it easy:
const client = new Jiren();
// Add headers to a single request
const response = await client.get('https://api.example.com/protected', {
headers: {
'Authorization': 'Bearer your-jwt-token',
'X-Custom-Header': 'custom-value'
}
});Creating a Pre-configured Client
For APIs that require consistent configuration, you can create a client with default settings:
import { Jiren } from 'jiren';
// Create a client with default configuration
const apiClient = new Jiren({
baseURL: 'https://api.example.com',
headers: {
'Authorization': 'Bearer your-api-key',
'Content-Type': 'application/json'
},
timeout: 5000 // 5 seconds
});
// Now all requests use these defaults
const users = await apiClient.get('/users');
const posts = await apiClient.get('/posts');
const comments = await apiClient.get('/comments');Error Handling
Jiren provides clear and predictable error handling:
import { Jiren } from 'jiren';
const client = new Jiren();
try {
const response = await client.get('https://api.example.com/users/999');
console.log(response.data);
} catch (error) {
if (error.status === 404) {
console.log('User not found');
} else if (error.status === 401) {
console.log('Unauthorized - please login');
} else {
console.log('An error occurred:', error.message);
}
}Real-World Example
Let's build a simple function that fetches and displays GitHub user information:
import { Jiren } from 'jiren';
interface GitHubUser {
login: string;
name: string;
bio: string;
public_repos: number;
followers: number;
}
async function getGitHubUser(username: string): PromiseConclusion
Jiren is designed to make HTTP requests in Node.js and Bun as simple as possible without sacrificing power or flexibility. Its zero-dependency architecture means faster installs and smaller bundle sizes, while its TypeScript-first approach ensures type safety throughout your application.
Ready to get started? Install Jiren today and experience the difference a well-designed HTTP client can make!
npm install jirenCheck out the full documentation and source code on npm and GitHub!
