csv-server


Namecsv-server JSON
Version 0.1.2 PyPI version JSON
download
home_pageNone
SummaryA FastAPI-based REST API server for CSV files
upload_time2025-08-20 04:56:23
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT
keywords csv api rest fastapi server
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # CSV Server

[![PyPI version](https://badge.fury.io/py/csv-server.svg)](https://pypi.org/project/csv-server/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
[![CI](https://github.com/rxhxt/csv-server/actions/workflows/ci.yml/badge.svg)](https://github.com/rxhxt/csv-server/actions)

**CSV Server** is a robust Python library and CLI tool that instantly turns your CSV files into a fully-featured REST API. Inspired by [json-server](https://github.com/typicode/json-server), it is designed for rapid prototyping, data exploration, and lightweight data servicesβ€”no database required.

---

## Features

- πŸš€ **Instant REST API**: Serve any folder of CSV files as RESTful endpoints.
- πŸ”’ **Read-Only by Default**: Safe, non-destructive access; enable writes as needed.
- πŸ†” **Auto-ID Management**: Automatic primary key synthesis and incrementing.
- πŸ”Ž **Advanced Querying**: Search, filter, sort, and paginate results.
- πŸ›‘οΈ **Safe Writes**: Atomic file operations with file locking.
- πŸ“– **Interactive API Docs**: Swagger/OpenAPI documentation at `/docs`.
- ⚑ **CLI & Python API**: Use as a command-line tool or integrate as a library.
- πŸ§ͺ **Comprehensive Testing**: Includes pytest-based test suite.
- 🐍 **Modern Python**: Type hints, linting, and optional pandas support for large datasets.

---

## Installation

```bash
pip install csv-server
```

---

## Quick Start

### CLI Usage

```bash
csv-server serve ./data --port 8000
```

- Instantly exposes all CSV files in `./data` as REST endpoints.
- Visit [http://localhost:8000/docs](http://localhost:8000/docs) for interactive API documentation.

### Python Library Usage

```python
from csv_server import serve_csv_directory

serve_csv_directory("./data", port=8000, readonly=True)
```

---

## Directory Structure

```
csv_server/
  __init__.py
  cli.py
  app.py
  resources.py
  config.py
  storage/
    base.py
    csv_store.py
    sqlite_store.py
  query.py
  utils_csv_ids.py
  version.py
tests/
examples/
  data/users.csv
  data/orders.csv
  config.yaml
pyproject.toml
README.md
LICENSE
```

---

## API Overview

For each CSV file (e.g., `users.csv`), the following endpoints are generated:

| Method | Endpoint            | Description                        |
|--------|---------------------|------------------------------------|
| GET    | `/users`            | List rows with query support       |
| GET    | `/users/{id}`       | Fetch a single row by ID           |
| POST   | `/users`            | Add a new row (if not read-only)   |
| PUT    | `/users/{id}`       | Replace a row (if not read-only)   |
| PATCH  | `/users/{id}`       | Update a row (if not read-only)    |
| DELETE | `/users/{id}`       | Delete a row (if not read-only)    |
| GET    | `/users/schema`     | Get inferred column schema         |

### Query Parameters

- `q`: Full-text search
- `filter`: Field-based filtering (e.g., `filter=age:gt:30`)
- `sort`: Sorting (e.g., `sort=name:asc`)
- `limit` & `offset`: Pagination

---

## Configuration

You can use a YAML config file for advanced setup:

```yaml
resources:
  users:
    file: "users.csv"
    primary_key: "id"
    readonly: false
  orders:
    file: "orders.csv"
    primary_key: "order_id"
    readonly: true
```

Run with:

```bash
csv-server serve ./data --config config.yaml
```

---

## Example Data

Sample CSV files are provided in `examples/data/` for demonstration and testing.

---

## Testing

Run the test suite with:

```bash
pytest
```

---

## Roadmap

- [ ] SQLite backend for large datasets
- [ ] Hot reload for CSV file changes
- [ ] Resource relationships (foreign keys)
- [ ] Docker image for easy deployment

---

## Contributing

Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.

---

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

---

## Acknowledgments

- Built with [FastAPI](https://fastapi.tiangolo.com/)
- Inspired by [json-server](https://github.com/typicode/json-server)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "csv-server",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "csv, api, rest, fastapi, server",
    "author": null,
    "author_email": "Rohit Nagotkar <rohitajaynagotkar@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/e2/20/170f049dcdb34058746566b4cd89576b13f75a908387e5b0bed22412dbed/csv_server-0.1.2.tar.gz",
    "platform": null,
    "description": "# CSV Server\n\n[![PyPI version](https://badge.fury.io/py/csv-server.svg)](https://pypi.org/project/csv-server/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n[![CI](https://github.com/rxhxt/csv-server/actions/workflows/ci.yml/badge.svg)](https://github.com/rxhxt/csv-server/actions)\n\n**CSV Server** is a robust Python library and CLI tool that instantly turns your CSV files into a fully-featured REST API. Inspired by [json-server](https://github.com/typicode/json-server), it is designed for rapid prototyping, data exploration, and lightweight data services\u2014no database required.\n\n---\n\n## Features\n\n- \ud83d\ude80 **Instant REST API**: Serve any folder of CSV files as RESTful endpoints.\n- \ud83d\udd12 **Read-Only by Default**: Safe, non-destructive access; enable writes as needed.\n- \ud83c\udd94 **Auto-ID Management**: Automatic primary key synthesis and incrementing.\n- \ud83d\udd0e **Advanced Querying**: Search, filter, sort, and paginate results.\n- \ud83d\udee1\ufe0f **Safe Writes**: Atomic file operations with file locking.\n- \ud83d\udcd6 **Interactive API Docs**: Swagger/OpenAPI documentation at `/docs`.\n- \u26a1 **CLI & Python API**: Use as a command-line tool or integrate as a library.\n- \ud83e\uddea **Comprehensive Testing**: Includes pytest-based test suite.\n- \ud83d\udc0d **Modern Python**: Type hints, linting, and optional pandas support for large datasets.\n\n---\n\n## Installation\n\n```bash\npip install csv-server\n```\n\n---\n\n## Quick Start\n\n### CLI Usage\n\n```bash\ncsv-server serve ./data --port 8000\n```\n\n- Instantly exposes all CSV files in `./data` as REST endpoints.\n- Visit [http://localhost:8000/docs](http://localhost:8000/docs) for interactive API documentation.\n\n### Python Library Usage\n\n```python\nfrom csv_server import serve_csv_directory\n\nserve_csv_directory(\"./data\", port=8000, readonly=True)\n```\n\n---\n\n## Directory Structure\n\n```\ncsv_server/\n  __init__.py\n  cli.py\n  app.py\n  resources.py\n  config.py\n  storage/\n    base.py\n    csv_store.py\n    sqlite_store.py\n  query.py\n  utils_csv_ids.py\n  version.py\ntests/\nexamples/\n  data/users.csv\n  data/orders.csv\n  config.yaml\npyproject.toml\nREADME.md\nLICENSE\n```\n\n---\n\n## API Overview\n\nFor each CSV file (e.g., `users.csv`), the following endpoints are generated:\n\n| Method | Endpoint            | Description                        |\n|--------|---------------------|------------------------------------|\n| GET    | `/users`            | List rows with query support       |\n| GET    | `/users/{id}`       | Fetch a single row by ID           |\n| POST   | `/users`            | Add a new row (if not read-only)   |\n| PUT    | `/users/{id}`       | Replace a row (if not read-only)   |\n| PATCH  | `/users/{id}`       | Update a row (if not read-only)    |\n| DELETE | `/users/{id}`       | Delete a row (if not read-only)    |\n| GET    | `/users/schema`     | Get inferred column schema         |\n\n### Query Parameters\n\n- `q`: Full-text search\n- `filter`: Field-based filtering (e.g., `filter=age:gt:30`)\n- `sort`: Sorting (e.g., `sort=name:asc`)\n- `limit` & `offset`: Pagination\n\n---\n\n## Configuration\n\nYou can use a YAML config file for advanced setup:\n\n```yaml\nresources:\n  users:\n    file: \"users.csv\"\n    primary_key: \"id\"\n    readonly: false\n  orders:\n    file: \"orders.csv\"\n    primary_key: \"order_id\"\n    readonly: true\n```\n\nRun with:\n\n```bash\ncsv-server serve ./data --config config.yaml\n```\n\n---\n\n## Example Data\n\nSample CSV files are provided in `examples/data/` for demonstration and testing.\n\n---\n\n## Testing\n\nRun the test suite with:\n\n```bash\npytest\n```\n\n---\n\n## Roadmap\n\n- [ ] SQLite backend for large datasets\n- [ ] Hot reload for CSV file changes\n- [ ] Resource relationships (foreign keys)\n- [ ] Docker image for easy deployment\n\n---\n\n## Contributing\n\nContributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.\n\n---\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n---\n\n## Acknowledgments\n\n- Built with [FastAPI](https://fastapi.tiangolo.com/)\n- Inspired by [json-server](https://github.com/typicode/json-server)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A FastAPI-based REST API server for CSV files",
    "version": "0.1.2",
    "project_urls": {
        "Homepage": "https://github.com/rxhxt/csv-server",
        "Issues": "https://github.com/rxhxt/csv-server/issues",
        "Repository": "https://github.com/rxhxt/csv-server"
    },
    "split_keywords": [
        "csv",
        " api",
        " rest",
        " fastapi",
        " server"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "bd59e016cf4ee2b622127522eb170748c3d1f4c48be3afab41e2bf1c3c88b614",
                "md5": "a36b9ebf278e8370f25ca95d60ab450a",
                "sha256": "b117fed5ecefbeb16048c88d84f46203aa815d48f72c14ba725488c4ab742a69"
            },
            "downloads": -1,
            "filename": "csv_server-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a36b9ebf278e8370f25ca95d60ab450a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 16368,
            "upload_time": "2025-08-20T04:56:21",
            "upload_time_iso_8601": "2025-08-20T04:56:21.954587Z",
            "url": "https://files.pythonhosted.org/packages/bd/59/e016cf4ee2b622127522eb170748c3d1f4c48be3afab41e2bf1c3c88b614/csv_server-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e220170f049dcdb34058746566b4cd89576b13f75a908387e5b0bed22412dbed",
                "md5": "54808009c21179d3a8021071e9cb109f",
                "sha256": "00493a49bd00ec76abfa8b67b94a5ba6cd4e87f6974fd5f65500d08138d1d40a"
            },
            "downloads": -1,
            "filename": "csv_server-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "54808009c21179d3a8021071e9cb109f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 16053,
            "upload_time": "2025-08-20T04:56:23",
            "upload_time_iso_8601": "2025-08-20T04:56:23.070967Z",
            "url": "https://files.pythonhosted.org/packages/e2/20/170f049dcdb34058746566b4cd89576b13f75a908387e5b0bed22412dbed/csv_server-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-20 04:56:23",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rxhxt",
    "github_project": "csv-server",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "csv-server"
}
        
Elapsed time: 0.67385s