Generates APIs for Mongodb

Auto Generated APIs

Auto Generated MongoDB APIs with API Maker

API Maker simplifies MongoDB API development by auto generating 34 production ready APIs with just a MongoDB connection string. These APIs are fully typed, TypeScript ready, and eliminate the need for boilerplate code, enabling rapid development and deployment.

API Maker streamlines MongoDB interactions for common operations like CRUD, pagination, sorting, deep population, and array operations. With support for both schema less and schema based approaches, it caters to flexible prototyping and structured production environments.

Key Features

  • Instant API Generation: Connect your MongoDB database to generate 34 APIs instantly.
  • TypeScript Support: Fully typed APIs for seamless integration.
  • Schema less & Schema-Based: Flexible or structured data handling based on your needs.
  • No Backend Coding: Eliminates manual backend logic for faster development.
  • Deep Populate: Fetch related data across collections in a single request.
  • Streaming Support: Efficiently handle large datasets with minimal memory usage.

Core Auto-Generated APIs

1. Fetch All Data

Retrieve all records from a collection with a simple GET request. Ideal for dashboards or master lists like customer or product catalogs.

Example:

Simple get all for Autogenerated API

/api/gen/user-path/instance/database/table

Get by any field

/api/gen/user-path/instance/database/table?customer_id=1 

Get by multiple fields

?first_name=John&last_name=Nash

Auto generated schema based GET ALL API

Simple get all

/api/schema/user-path/instance/database/table

Get by any field

/api/schema/user-path/instance/database/table?customer_id=1

Get by multiple fields

?first_name=Bob&last_name=lin

2. Filter Data with Query Parameters

Fetch specific data using query string conditions (e.g., by name, status, or date).

Simple query Endpoint

/api/gen/user-path/instance/database/table?name=John Nash&status=Active

3. Pagination with skip and limit

Implement efficient pagination for frontend applications using skip and limit parameters.

Example:

GET /api/gen/user-path/instance/database/table?skip=10&limit=20

4. Limit Returned Rows

Control response size with the limit parameter to optimize performance, especially for mobile or low-bandwidth apps.

Example:

GET /api/gen/user-path/instance/database/table?limit=50

5. Sort Data

Sort results in ascending (asc) or descending (desc) order based on fields like name, price, or date.

Example:

GET /api/gen/user-path/instance/database/table?sort=date
GET /api/gen/user-path/instance/database/table?sort=-date

6. Get Total Record Count

Retrieve the total count of matching records using the withCount=true parameter, ideal for paginated interfaces.

Example:

/api/gen/user-path/instance/database/table?getTotalCount=true

Simple get count

Response:

{
    "data": [
        {
            "customer_id": 1,
            "first_name": "Bob",
            "last_name": "Lin"
        },
        {
            "customer_id": 2,
            "first_name": "Alice",
            "last_name": "Page"
        }
    ],
    "totalCount": 2
}

$gt grater than example

POST /api/schema/user-path/instance/database/table/count
{
    "find": {
        "activity_count": {
            "$gt": 4
        }
    }
}

$gte grater than equals to

EndPoint

/api/schema/user-path/instance/database/table/count

{
    "find": {
        "activity_count": {
            "$gte": 4
        }
    }
}

$lt less than

EndPoint

/api/schema/user-path/instance/database/table/count
{
    "find": {
        "isActive": {
            "$lt": 4
        }
    }
}

7. Select Specific Fields

Use the select parameter to fetch only required fields, reducing response size and improving performance.

Example:

/api/gen/user-path/instance/database/table?select=first_name,last_name
{
    "data": [
        {
            "customer_id": 1,
            "first_name": "Bob",
            "last_name": "Lin"
        },
        {
            "customer_id": 2,
            "first_name": "Alice",
            "last_name": "Page"
        },
        {
            "customer_id": 3,
            "first_name": "Mallory",
            "last_name": "Brown"
        },
        {
            "customer_id": 4,
            "first_name": "Eve",
            "last_name": "Mathly"
        },
        {
            "customer_id": 5,
            "first_name": "Eve",
            "last_name": "Page"
        }
    ]
}

8. Deep Populate (Nested Data)

Fetch related or nested data across collections using the deep parameter, similar to Mongoose population or SQL joins.

Example:

/api/schema/user-path/instance/database/table?deep=[{s_key:"state_id",t_instance:"oracle",t_db:"inventory",t_col:"states",t_key:"id"}]

MongoDB Document Operations

1. Fetch Single Document by ID

Retrieve a single MongoDB document by its _id (ObjectId) for detail views or editing.

Example:

GET /api/gen/user-path/instance/database/table/get-by-id/64fe1f2c3a76ef01b9d4c5a7
  • Supports native MongoDB ObjectId.
  • Fast document level lookup without custom logic.

2. Override Primary Key

Query documents by custom unique fields (e.g., email, username) instead of _id.

Example:

GET /api/schema/user-path/instance/database/table/get-by-id/test@example.com/email

3. Fetch Nested Data

Retrieve related data from nested or foreign collections in a single call using the deep parameter.

Example:

GET /api/gen/user-path/instance/database/table/get-by-id/64fe1f2c3a76ef01b9d4c5a7?deep=customer,address,items

Streaming Large Datasets

API Maker supports streaming APIs to fetch large MongoDB datasets without loading them into memory, ideal for exports, analytics, or big-data integrations.

Example:

GET /api/gen/user-path/instance/database/table/stream

Benefits:

  • Low memory footprint.
  • Handles millions of records efficiently.
  • Prevents out-of-memory crashes.

Distinct Value APIs

1. Get Distinct Values

Retrieve unique values from a specific field using the /distinct endpoint, perfect for category filters or tag clouds.

Example:

/api/gen/user-path/instance/database/table/distinct/pincode/desc
/api/gen/user-path/instance/database/table/distinct/pincode/asc

Response:

[
    "Apple",
    "Samsung",
    "OnePlus"
]

2. Multi-Field Distinct Combinations

Fetch unique combinations of multiple fields (e.g., brand + category).

Example:

/api/gen/user-path/instance/database/table/distinct/pincode,first_name

Response:

[
    {
        "brand": "Apple",
        "category": "Mobile"
    },
    {
        "brand": "Sony",
        "category": "Headphones"
    }
]

3. Distinct with Query

Apply MongoDB-style filters using the find parameter to get distinct values for a filtered dataset.

Example:

/api/gen/user-path/instance/database/table/distinct/first_name/asc

Response:

{
    "find": {
        "first_name": "Mallo"
    }
}

POST Example:

/api/gen/user-path/instance/database/table/distinct/customer_id
{
    "find": {
        "pincode": 382330
    }
}

Update Operations

1. Update Many

Update multiple records based on custom filters in a single, optimized API call.

Endpoint:

PUT /api/gen/user-path/instance/database/table/update-many

Example Payload:

{
    "find": {
        "first_name": "Alice"
    },
    "updateData": {
        "first_name": "MALLORY"
    }
}

2. Replace by ID

Completely overwrite a MongoDB document by _id or a custom unique field.

Example:

PUT /api/gen/user-path/instance/database/table/replace-by-id/60ae24c8c37cd955cc144162
{
	"first_name": "MALLORY"
}

2.Replace By Id(upsert)

PUT /api/gen/user-path/instance/database/table/replace-by-id/60ae24c8c37cd955cc144162?upsert=true
{
	"first_name": "MALLORY"
}

Note: replace-by-id is not supported for SQL databases; use update-by-id instead.


Array Operations (MongoDB Only)

API Maker provides auto-generated APIs for managing array fields in MongoDB documents, supporting operations like push, pull, addToSet, pullAll, pop, and set.

Endpoint:

PUT /api/gen/user-path/instance/database/table/array-operations

Supported Operations:

  • push: Add items to an array.

EndPoint

/api/gen/user-path/instance/database/table/array-operations

Request Payload:


{
    "find": {
        "customer_id": 1
    },
    "operations": [
        {
            "operation": "push",
            "path": "ages",
            "dataToPush": [
                {
                    "age": 33,
                    "birth_year": 1989,
                    "country_id": 1
                }
            ]
        }
    ]
}
  • addToSet: Add unique items to an array.

EndPoint

/api/gen/user-path/instance/database/table/array-operations

Request Payload:

{
    "find": {},
    "operations": [
        {
            "operation": "addToSet",
            "path": "ages",
            "dataToPush": {
                "age": 2,
                "birth_year": 1989
            }
        }
    ]
}
  • pull: Remove the first matching item. EndPoint
/api/gen/user-path/instance/database/table/array-operations

Request Payload


{
    "find": {
        "customer_id": 1
    },
    "operations": [
        {
            "operation": "pull",
            "path": "ages",
            "queryToRemove": {
                "age": 2,
                "birth_year": 1989,
                "country_id": 1
            }
        }
    ]
}
  • pullAll: Remove all matching items.
  • EndPoint
  /api/gen/user-path/instance/database/table/array-operations

Request Payload

{
    "find": {
        "customer_id": 1
    },
    "operations": [
        {
            "operation": "pullAll",
            "path": "ages",
            "dataToPull": [
                {
                    "age": 2,
                    "birth_year": 1989,
                    "country_id": 1
                }
            ]
        }
    ]
}
  • pop: Remove the first or last item.

EndPoint

/api/gen/user-path/instance/database/table/array-operations

Request Payload

{
    "find": {
        "customer_id": 5
    },
    "operations": [
        {
            "operation": "pop",
            "path": "ages",
            "direction": 1
        }
    ]
}
  • set: Update specific array elements or insert new ones.

EndPoint

/api/gen/user-path/instance/database/table/array-operations

Request Payload

{
    "find": {},
    "operations": [
        {
            "operation": "addToSet",
            "path": "ages",
            "dataToPush": {
                "age": 2,
                "birth_year": 1989
            }
        }
    ]
}

Save Single or Multiple Records

1. Schemaless Save API

Flexible saving without strict schema validation, ideal for prototyping.

Endpoint:

/api/gen/user-path/instance/database/table/save-single-or-multiple
{
    "first_name": "Bob",
    "last_name": "Lin"
}

2. Schema-Based Save API

Structured saving with schema validation for production environments.

Endpoint:

/api/schema/user-path/instance/database/table/save-single-or-multiple
{
    "first_name": "John",
    "last_name": "Tailor",
    "pincode": 382350,
    "isActive": 0
}

Features:

  • Save single or multiple records.
  • Automatic insert or update based on primary key presence.
  • Supports nested saves across related collections (e.g., City → State → Country).
  • Transaction rollback for data integrity.
  • Deep population and selective field returns.

Documentation:


Master Save/Update APIs

Master Save APIs support both schemaless and schema-based data models, enabling flexible or validated saving with upsert capabilities.

Features:

  • Save single or multiple records in one request.
  • Nested saves across related tables/collections.
  • Transaction rollback for consistency.
  • Deep population and field selection.

Schemaless Master-Save/Update API

Save single record

Endpoint:

/api/gen/user-path/instance/database/table/master-save
{
    "first_name": "Bob",
    "last_name": "Lin"
}

Save multiple record

Endpoint:

/api/gen/user-path/instance/database/table/master-save
[
    {
        "first_name": "Bob",
        "last_name": "Lin"
    },
    {
        "first_name": "Alice",
        "last_name": "Page"
    }
]

Documentation:

SchemaBased Master-Save/Update API

Save single record

Endpoint:

/api/schema/user-path/instance/database/table/master-save
{
    "first_name": "Bob",
    "last_name": "Mike"
}

Save multiple record

Endpoint:

/api/schema/user-path/instance/database/table/master-save
[
    {
        "first_name": "Bob",
        "last_name": "Lin"
    },
    {
        "first_name": "Alice",
        "last_name": "Page"
    }
]

Query for Get Data APIs

1. Schemaless Query API

Flexible querying for MongoDB with manual relationship mappings.

Endpoint:

/api/gen/user-path/instance/database/table/query

find, skip, limit, sort, select, deep query

2. Schema-Based Query API

Structured querying with automatic type conversion and schema-driven relationships.

Endpoint:

/api/schema/user-path/instance/database/table/query
{
   "find": {
       "owner_id": {
           "$in": [
               1,
               2,
               3
           ]
       }
   },
   "skip": 1,
   "limit": 4,
   "sort": "price",
   "select": "name, owner_id, id, price",
   "deep": [
       {
           "s_key": "owner_id",
           "t_instance": "mysql",
           "t_db": "inventory",
           "t_col": "customers",
           "t_key": "customer_id",
           "find": {
               "first_name": "Billy"
           },
           "isMultiple": true,
           "limit": 10,
           "select": "customer_id,first_name",
           "skip": 2,
           "sort": "first_name"
       }
   ],
   "getTotalCount": true,
   "groupBy": "name"
}

Provide deep information in schema

Endpoint:

/api/schema/user-path/instance/database/table/query
{
    "deep": [
        {
            "s_key": "owner_id"
        }
    ]
}

Supported Operators:

  • Comparison: $lt, $gt, $lte, $gte, $eq, $ne
  • Logical: $and, $or, $not
  • Array: $in, $nin
  • Pattern: $like, $regex

Features:

  • Deep population for nested data.
  • Multi-database joins (schema-based).
  • Pagination, sorting, and filtering.

Documentation:


Deep Population Comparison

Aspect Schemaless Schema-Based
Syntax {"s_key": "owner_id", "t_col": "customers", "t_key": "customer_id"} {"s_key": "owner_id"} (with schema)
Configuration Manual relationship mapping Schema-driven automatic mapping
Validation Basic relationship validation Full schema validation
Multi-Database Limited support Full multi-database capability

Learn More: Schema Creation with Deep Populate


Remove Operations

1. Remove by ID

Delete a single document by _id or a custom unique field.

Schemaless Example:

DELETE /api/gen/user-path/instance/database/table/1
DELETE /api/gen/user-path/instance/database/table/4/customer_id

Schema-Based Example:

DELETE /api/schema/user-path/instance/database/table/1
DELETE /api/schema/user-path/instance/database/table/4/customer_id

Documentation:

2. Remove by Query

Bulk delete records using custom queries.

Schemaless Example:

POST /api/gen/user-path/instance/database/table/query/delete
{
    "find": {
        "first_name": "Mike"
    }
}

With Advanced Filters:

POST /api/gen/user-path/instance/database/table/query/delete
{
    "find": {
        "first_name": {
            "$in": [
                "Mike"
            ]
        }
    },
    "select": "name,description",
    "limit": 1,
    "deep": [
        {
            "s_key": "customer_id",
            "t_col": "products",
            "t_key": "owner_id"
        }
    ]
}

Schema-Based Example:

POST /api/schema/user-path/instance/database/table/query/delete
{
    "find": {
        "first_name": "Bob"
    }
}

Documentation:


Aggregate APIs

Perform advanced data aggregations for reporting and analytics.

1. Schemaless Aggregate API

For flexible MongoDB collections.

Basic Aggregation:

POST /api/gen/user-path/instance/database/table/aggregate
[
    {
        "$group": {
            "_id": "$_id",
            "total": {
                "$sum": "$customer_id"
            }
        }
    },
    {
        "$match": {
            "total": {
                "$gt": 1
            }
        }
    },
    {
        "$sort": {
            "total": -1
        }
    },
    {
        "$count": "CountValue"
    }
]

Project Stage:

POST /api/gen/user-path/instance/database/table/aggregate
[
    {
        "$project": {
            "full_name": {
                "$toLower": "$first_name"
            }
        }
    }
]

2. Schema-Based Aggregate API

For structured databases with defined schemas.

Basic Aggregation:

POST /api/schema/user-path/instance/database/table/aggregate
[
    {
        "$group": {
            "_id": "$_id",
            "total": {
                "$sum": "$customer_id"
            }
        }
    },
    {
        "$match": {
            "total": {
                "$gt": 1
            }
        }
    },
    {
        "$sort": {
            "total": -1
        }
    },
    {
        "$count": "CountValue"
    }
]

Documentation:


Count APIs (MongoDB Only)

Count records based on custom filters, ideal for dashboards and analytics.

1. Schemaless Count API

For flexible MongoDB collections.

Simple Count:

POST /api/gen/user-path/instance/database/table/count
{
    "find": {
        "customer_id": 1
    }
}

With $gt:

POST /api/gen/user-path/instance/database/table/count
{
    "find": {
        "isActive": {
            "$gt": 4
        }
    }
}

2. Schema-Based Count API

For structured databases.

Simple Count:

POST /api/schema/user-path/instance/database/table/count
{
    "find": {
        "customer_id": 1
    }
}

Documentation:


Comparison: API Maker vs. GraphQL, Supabase, Firebase

Feature API Maker GraphQL Supabase Firebase (Firestore)
Auto-Generated Distinct API ✅ Yes ❌ Custom resolver needed ✅ Limited (via RPC or filters) ❌ Manual query logic
Query Filters ✅ Full JSON-based filtering ✅ Via resolvers/queries ✅ Partial SQL-style filtering ⚠️ Limited to shallow filters
Multi-Field Distinct ✅ Supported ⚠️ Requires custom logic ⚠️ Requires raw SQL or RPC ❌ Not supported natively
Nested Field Support ✅ MongoDB & joins ⚠️ Complex nested schemas ⚠️ SQL JOIN logic needed ⚠️ Limited for deep fields
Low-Code Configuration ✅ 100% Low-Code UI ❌ Manual setup required ⚠️ Low-code with SQL ⚠️ Firestore rules & JS needed
Performance Optimization ✅ Built-in & query optimized ⚠️ Developer-dependent ✅ Good for SQL operations ⚠️ Manual pagination needed
Security & Access Control ✅ Built-in RBAC ⚠️ Add-ons required ✅ Integrated auth ✅ Firestore rules available
Real-Time Sync ✅ Optional w/ socket support ⚠️ Add-on with subscriptions ✅ Realtime support ✅ Native realtime

Conclusion

API Maker revolutionizes MongoDB API development by auto-generating a comprehensive set of APIs for data retrieval, manipulation, and aggregation. With support for both schemaless and schema-based workflows, it caters to rapid prototyping and production-grade applications. Features like deep population, streaming, and array operations make it a powerful tool for developers seeking efficiency and scalability without sacrificing flexibility.

FAQ's: Auto-Generated MongoDB APIs with API Maker

1. What is API Maker for MongoDB?

API Maker is a low-code platform that auto-generates 34 production-ready APIs for MongoDB. You simply connect your database using a MongoDB URI, and it instantly creates fully typed, TypeScript-ready APIs for CRUD operations, deep population, array handling, aggregations, and more—no backend coding needed.

2. How many APIs does API Maker auto-generate for MongoDB?

API Maker automatically generates 34 fully functional REST APIs for each MongoDB collection. These APIs cover core operations like fetch, insert, update, delete, aggregation, distinct queries, array manipulation, streaming, and deep joins.

3. Can I use API Maker with both schemaless and schema-based MongoDB collections?

Yes. API Maker supports both schemaless and schema-based modes. Schemaless is ideal for rapid prototyping, while schema-based APIs are suited for production with validation, type safety, and deep relationship mapping.

4. What is deep populate in API Maker’s MongoDB APIs?

Deep populate allows you to fetch related data from multiple collections in one API call—similar to MongoDB’s $lookup or Mongoose’s populate. It supports both manual (schemaless) and schema-driven (schema-based) configurations.

5. Does API Maker support pagination, filtering, and sorting in MongoDB APIs?

Yes. API Maker provides built-in support for pagination, filtering, and sorting using query parameters like skip, limit, and sort. You can also apply JSON-style filters using the find parameter.

6. Can I perform distinct queries in API Maker?

Absolutely. API Maker includes distinct APIs that let you retrieve unique values from one or more fields. You can even apply filters using distinct-with-query to get distinct values based on specific conditions.

7. How does API Maker handle large MongoDB datasets?

API Maker supports streaming APIs to process and deliver large datasets efficiently, without loading everything into memory. This is ideal for exports, big data analytics, and preventing memory overflow on limited servers.

8. What are array operations in API Maker’s MongoDB support?

Array operations allow you to modify array fields directly in MongoDB documents using auto-generated APIs. Supported operations include push, pull, addToSet, pullAll, pop, and set.

9. Can I replace or update documents using custom primary keys?

Yes. API Maker allows document replacement or updates not only by _id but also by custom unique fields like email or username. You just pass the custom key using the primaryKey parameter.

10. Does API Maker support MongoDB aggregation pipelines?

Yes. API Maker offers aggregate APIs for advanced querying and reporting. You can define full MongoDB aggregation pipelines using familiar operators like $group, $match, $project, $count, and more.

11. Is there any support for inserting or updating multiple records at once?

Yes. API Maker provides save and master-save APIs that support batch operations. You can insert or update single or multiple records in one call, even with nested data (e.g., City → State → Country).

12. Can I delete records by ID or custom queries?

Yes. You can delete a single document by ID or custom unique fields, and also perform bulk deletions using query conditions. Both schemaless and schema-based options are available.

13. Do I need to write any backend code with API Maker?

No. API Maker eliminates the need for backend coding. Once your MongoDB connection is established, all core APIs are generated automatically—ready to use with your frontend or third-party tools.

14. Where can I find the documentation for MongoDB APIs in API Maker?

You can find detailed guides and examples in the API Maker Documentation. Each endpoint is well-documented for both schema and schemaless variants.

For more details, visit the API Maker Documentation.