# Mantiqh Query String

## Developed by Mantiqh Technologies

### Basic Details

- Lightweight package for converting objects into query strings.
- Supports nested objects, arrays, and encoding.
- Ideal for APIs like Strapi, AWS, and custom backend queries.
- Package uses **pnpm** as the package manager.

---

## Installation

```sh
npm i mantiqh-query-string
```

---

## Usage

```javascript
import { toQS } from 'mantiqh-query-string'

// Example object for API queries
const queryObject = {
  populate: {
    table1: {
      fields: ['title'],
    },
    table2: {
      filters: {
        name: { $eq: 'dynamite' },
      },
    },
  },
}

// Convert object to query string
const queryString = toQS(queryObject)
console.log(queryString)
// Output: populate[table1][fields][0]=title&populate[table2][filters][name][$eq]=dynamite

// Making an API request with the generated query string
const url = `http://localhost:1337/api/dealer-admins?${queryString}`

fetch(url)
  .then((response) => response.json())
  .then((data) => console.log('API Response:', data))
  .catch((error) => console.error('Error:', error))
```

---

## Features

- **Supports Nested Objects:** Easily converts deeply nested objects.
- **Handles Arrays:** Properly formats arrays for API-friendly queries.
- **Encoding Support:** Ensures special characters are URL-encoded.
- **Lightweight & Fast:** No external dependencies.

---

## Changelog

### v1.0.0 - Initial Release

- Added support for converting objects to query strings.
- Handles nested objects and arrays.
- Supports encoding special characters.

### v1.0.0-1 - Enhancements & Fixes

- Improved handling of empty objects and arrays.
- Optimized query string generation for performance.

### v1.0.0-2 - New Features

- Fixed minor encoding issues.

### v1.0.0-3 - New Features

- Added support for custom key formatting.

### v1.0.0-4 - New Features

- Option to exclude `null` or `undefined` values.

---

## Requirements

No external setup is required. Just install and use it in your JavaScript/TypeScript projects.

---

Enjoy seamless API query string generation with **Mantiqh Query String**! 🚀
