Skip to main content

Fast Point API

Fast Point API is a framework for building APIs using FastAPI. It provides dynamic collection management and currently integrates with CouchDB. Future updates may include support for additional databases. This package is designed to simplify the creation of APIs for managing collections and CRUD operations.


Features

  • Automatically generates CRUD endpoints for collections.
  • Manages collections in a CouchDB instance, with potential future updates to support other databases.
  • Defines data structures using Pydantic schemas.

Installation

Install the package via pip:

pip install fast-point-api

Getting Started

Here's a quick example to set up your API:

Example Code

from fast_point_api.app_factory import create_app
from fast_point_api.schemas import PizzaModel, DrinkModel

# Define custom models
class MyModel(PizzaModel):
    extra_field: str

# CouchDB connection URL
connection_url = "http://admin:admin@localhost:5984"

# Define collections and models
collections = {
    "pizzas": PizzaModel,
    "bebidas": DrinkModel,
}

# Create the FastAPI app
app = create_app(connection_url=connection_url, models_dict=collections)

Run your app:

uvicorn main:app --reload

Visit the interactive API docs at http://127.0.0.1:8000/docs.


CouchDB Manager Example

The CouchDBManager class simplifies database management. Here's how to use it:

from fast_point_api.config import CouchDBManager

# Initialize CouchDBManager
manager = CouchDBManager(connection_url="http://admin:admin@localhost:5984")

# Get existing collections
collections = manager.get_existing_collections()
print(f"Existing collections: {collections}")

# Create or get a database
db = manager.get_db("example_db")

# Delete a specific collection
manager.delete_collection("example_db")

# Delete all collections (excluding system databases)
manager.delete_all_collections(exclude_system_dbs=True)

CRUD Operations Example

This package includes generic CRUD operations that you can use directly:

from fast_point_api.schemas import PizzaModel
from fast_point_api.crud import create_item, get_items, update_item

# Example Pizza data
pizza = PizzaModel(
    name="Pepperoni",
    description="Classic Pepperoni Pizza",
    ingredients="Tomato, Cheese, Pepperoni",
    size="Large",
    price=15.99,
    is_vegetarian=False,
)

# Create a new item
new_item = create_item(manager, "pizzas", pizza)
print(f"Created item: {new_item}")

# Retrieve all items
items = get_items(manager, "pizzas")
print(f"Items: {items}")

# Update an item
updated_data = {"price": 12.99}
updated_item = update_item(manager, "pizzas", new_item["_id"], updated_data)
print(f"Updated item: {updated_item}")

Configuration

CouchDB Setup

Ensure you have CouchDB running. You can use Docker to start an instance:

docker run -d -p 5984:5984 -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=admin couchdb

API Endpoints

The package automatically generates CRUD endpoints for each collection. For example, for a collection named pizzas:

  • POST /pizzas/ - Create a new item.
  • GET /pizzas/ - Get all items.
  • GET /pizzas/{item_id} - Get a single item by ID.
  • PUT /pizzas/{item_id} - Update an item by ID.
  • DELETE /pizzas/{item_id} - Deactivate an item by ID.

Additionally, generic endpoints are available at /generic/{collection_name}/.


Dependencies

This package requires:

  • FastAPI
  • CouchDB
  • Uvicorn
  • Pydantic

Refer to requirements.txt for the full list of dependencies.


License

This project is licensed under the MIT License. See the LICENSE file for details.


Contributing

Contributions are welcome! Feel free to fork the repository and submit pull requests.


Contact

Author: MaynerAC
Email: mayneranahuacoaquira@gmail.com
GitHub: maynerac

Metadata

Release files for fast-point-api 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fast-point-api 1.0.0
File Size Uploaded
fast_point_api-1.0.0.tar.gz 10.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fast-point-api 1.0.0
File Interpreter ABI Platform
fast_point_api-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.6 kB

Release files / fast_point_api-1.0.0.tar.gz

Download URL fast_point_api-1.0.0.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ea24343ba7288a9339b987a46f74e02ac3d555d2fa681f2e7954387b4fcbd2a4
BLAKE2b-256 checksum
How to use checksums
51bf55e40cf784a31871923f3db33050a99807ff1705e2723ef80f14075929c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release files / fast_point_api-1.0.0-py3-none-any.whl

Download URL fast_point_api-1.0.0-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bd631dda5ed6749326b5ddf6b9ce7ef8df44f82256d191ba900ba020fb688975
BLAKE2b-256 checksum
How to use checksums
33f7b3828341845b092a8bc89fa154a309dfca16e7d4f8ee1b02d981f3231825
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page