### Development Setup for json-api-builder Source: https://github.com/rato-tokyo/json-api-builder/blob/main/README.md Instructions for setting up the development environment, including cloning the repository and installing development dependencies for local contribution and testing. ```bash git clone https://github.com/yourusername/json-api-builder.git cd json-api-builder pip install -e .[dev] ``` -------------------------------- ### Install json-api-builder Source: https://github.com/rato-tokyo/json-api-builder/blob/main/README.md Installs the json-api-builder library using pip, the Python package installer. ```bash pip install json-api-builder ``` -------------------------------- ### Quickstart: Build a REST API with json-api-builder Source: https://github.com/rato-tokyo/json-api-builder/blob/main/README.md Demonstrates how to quickly set up a REST API server using `json-api-builder`. It defines a Pydantic model for an 'Item' resource, initializes `APIBuilder`, registers the resource, and runs the server. Access the API documentation at http://127.0.0.1:8000/docs after running the script. ```python from json_api_builder import APIBuilder from pydantic import BaseModel, Field class Item(BaseModel): id: int | None = None name: str = Field(description="アイテム名") description: str = Field(description="説明") price: float = Field(description="価格", ge=0) # APIBuilder作成 builder = APIBuilder( title="My API", description="シンプルなAPI", version="1.0.0", db_path="data.db" ) # リソース登録 builder.resource("items", Item) # サーバー起動 # ターミナルで `python your_script_name.py` を実行し、 # ブラウザで http://127.0.0.1:8000/docs を開くとAPIドキュメントが確認できます。 if __name__ == "__main__": builder.run(host="127.0.0.1", port=8000) ``` -------------------------------- ### Run Tests for json-api-builder Source: https://github.com/rato-tokyo/json-api-builder/blob/main/README.md Command to execute the test suite for the json-api-builder project using pytest, ensuring the library's functionality and stability. ```bash pytest ``` -------------------------------- ### Export Database Content to JSON using APIBuilder Source: https://github.com/rato-tokyo/json-api-builder/blob/main/README.md Shows how to export all resources or a specific resource from the database to JSON files using methods of the `APIBuilder` instance. This allows for easy backup or migration of data. ```python # 全リソースをディレクトリにエクスポート builder.export_to_json(output_dir="exported_data") # 特定のリソースをファイルにエクスポート builder.export_resource_to_json(resource_type="items", output_file="items.json") ``` -------------------------------- ### API Endpoints for Database Information and Download Source: https://github.com/rato-tokyo/json-api-builder/blob/main/README.md Documents the API endpoints available for retrieving database information and downloading the SQLite database file directly from the running server. These endpoints provide programmatic access to database management. ```APIDOC GET /download/info: Description: Returns database file path, size, and last modified time in JSON format. GET /download/database: Description: Directly downloads the SQLite database file. ``` -------------------------------- ### Export Database Content to JSON using Direct Function Source: https://github.com/rato-tokyo/json-api-builder/blob/main/README.md Illustrates how to export database content to JSON files using the standalone `export_database_to_json` function, which can be used independently of an `APIBuilder` instance. ```python from json_api_builder import export_database_to_json export_database_to_json(db_path="data.db", output_dir="exported_data") ``` -------------------------------- ### Import JSON Data into Database Source: https://github.com/rato-tokyo/json-api-builder/blob/main/README.md Demonstrates how to import JSON files from a directory into a new or existing database using the `import_database_from_json` function. The `overwrite=True` option clears the existing database before importing. ```python from json_api_builder import import_database_from_json # ディレクトリ内の全JSONファイルをインポート # overwrite=True にすると、既存のデータベースはクリアされます import_database_from_json( db_path="new_data.db", input_dir="exported_data", overwrite=True ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.