### Get All Libraries using Python Source: https://docs.romm.app/latest/API-and-Development/API-Reference Example using the Python 'requests' library to fetch all libraries. Demonstrates setting up basic HTTP authentication and making a GET request. ```python import requests from requests.auth import HTTPBasicAuth # Setup authentication auth = HTTPBasicAuth('username', 'password') base_url = 'http://your-instance:3000/api' # Get all libraries response = requests.get(f'{base_url}/libraries', auth=auth) libraries = response.json() ``` -------------------------------- ### Get All Libraries using JavaScript/Node.js Source: https://docs.romm.app/latest/API-and-Development/API-Reference Example using the 'axios' library in JavaScript/Node.js to fetch all libraries. Demonstrates setting up the base URL and authentication for the axios instance. ```javascript const axios = require("axios"); // Setup authentication const api = axios.create({ baseURL: "http://your-instance:3000/api", auth: { username: "username", password: "password", }, }); // Get all libraries const libraries = await api.get("/libraries"); ``` -------------------------------- ### Get All Libraries using cURL Source: https://docs.romm.app/latest/API-and-Development/API-Reference Example using cURL to fetch all libraries from the API. Requires basic HTTP authentication with username and password. ```bash # Get all libraries curl -u username:password http://your-instance:3000/api/libraries ``` -------------------------------- ### Install uv and Python dependencies Source: https://docs.romm.app/latest/API-and-Development/Development-Setup Installs the `uv` package manager and then uses it to create a virtual environment and install project dependencies, including development extras. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh uv venv source .venv/bin/activate uv sync --all-extras --dev ``` -------------------------------- ### Run the backend Source: https://docs.romm.app/latest/API-and-Development/Development-Setup Starts the RomM backend server using `uv` to manage the Python environment. Database migrations are automatically handled. ```bash cd backend uv run python3 main.py ``` -------------------------------- ### Install Trunk CLI Source: https://docs.romm.app/latest/API-and-Development/Development-Setup Installs the Trunk CLI, a tool for managing linters and formatters, using a curl command. Alternative installation methods are available in the official documentation. ```bash curl https://get.trunk.io -fsSL | bash ``` -------------------------------- ### Get Specific ROM using cURL Source: https://docs.romm.app/latest/API-and-Development/API-Reference Example using cURL to retrieve a specific ROM by its ID. Requires basic HTTP authentication. ```bash # Get a specific ROM curl -u username:password http://your-instance:3000/api/roms/123 ``` -------------------------------- ### Get Specific ROM using JavaScript/Node.js Source: https://docs.romm.app/latest/API-and-Development/API-Reference Example using the 'axios' library in JavaScript/Node.js to retrieve a specific ROM by its ID. Assumes the axios instance with authentication is already set up. ```javascript // Get a specific ROM const rom = await api.get("/roms/123"); ``` -------------------------------- ### Install Node.js dependencies Source: https://docs.romm.app/latest/API-and-Development/Development-Setup Navigates to the frontend directory and installs Node.js dependencies using npm. Ensure npm version 9 or higher is installed. ```bash cd frontend # npm version >= 9 needed npm install ``` -------------------------------- ### Get Specific ROM using Python Source: https://docs.romm.app/latest/API-and-Development/API-Reference Example using the Python 'requests' library to retrieve a specific ROM by its ID. Shows how to include authentication in the request. ```python # Get a specific ROM response = requests.get(f'{base_url}/roms/123', auth=auth) rom = response.json() ``` -------------------------------- ### Install system dependencies Source: https://docs.romm.app/latest/API-and-Development/Development-Setup Installs necessary system libraries for database connectivity (MariaDB, PostgreSQL) and prepares for building RAHasher. Users on macOS can skip RAHasher compilation. ```bash # https://mariadb.com/docs/skysql-previous-release/connect/programming-languages/c/install/#Installation_via_Package_Repository_(Linux): sudo apt install libmariadb3 libmariadb-dev libpq-dev # Build and configure RAHasher (optional) # This is only required to calculate RA hashes # Users on macOS can skip this step as RAHasher is not supported git clone --recursive https://github.com/RetroAchievements/RALibretro.git cd ./RALibretro git checkout 1.8.0 git submodule update --init --recursive sed -i '22a #include ' ./src/Util.h make HAVE_CHD=1 -f ./Makefile.RAHasher cp ./bin64/RAHasher /usr/bin/RAHasher ``` -------------------------------- ### Run the frontend Source: https://docs.romm.app/latest/API-and-Development/Development-Setup Starts the RomM frontend development server using npm. This command will typically launch the application in a browser. ```bash npm run dev ``` -------------------------------- ### Create New ROM Entry using cURL Source: https://docs.romm.app/latest/API-and-Development/API-Reference Example using cURL to create a new ROM entry. This POST request includes a JSON payload and requires basic HTTP authentication and setting the Content-Type header. ```bash # Create a new ROM entry curl -X POST -u username:password \ -H "Content-Type: application/json" \ -d '{"name": "New ROM", "platform_id": 1}' \ http://your-instance:3000/api/roms ``` -------------------------------- ### Get All Libraries Source: https://docs.romm.app/latest/API-and-Development/API-Reference Retrieves a list of all libraries available in the RomM instance. ```APIDOC ## GET /libraries ### Description Retrieves a list of all libraries. ### Method GET ### Endpoint /libraries ### Request Example ```bash curl -u username:password http://your-instance:3000/api/libraries ``` ### Response #### Success Response (200) - **libraries** (array) - A list of library objects. ``` -------------------------------- ### Spin up Docker containers Source: https://docs.romm.app/latest/API-and-Development/Development-Setup Starts the RomM application and its dependencies in detached mode using Docker Compose. The app will be accessible at http://localhost:3000. ```bash docker compose up -d ``` ```bash docker compose up -d ``` -------------------------------- ### Get Specific ROM Source: https://docs.romm.app/latest/API-and-Development/API-Reference Retrieves details for a specific ROM by its ID. ```APIDOC ## GET /roms/{id} ### Description Retrieves details for a specific ROM. ### Method GET ### Endpoint /roms/{id} ### Parameters #### Path Parameters - **id** (integer) - Required - The unique identifier of the ROM. ### Request Example ```bash curl -u username:password http://your-instance:3000/api/roms/123 ``` ### Response #### Success Response (200) - **rom** (object) - The ROM object with its details. ``` -------------------------------- ### Create test user and database Source: https://docs.romm.app/latest/API-and-Development/Development-Setup Executes a SQL script to set up the test user and database within the MariaDB instance, using the root user credentials. ```bash docker exec -i romm-db-dev mariadb -uroot -p < backend/romm_test/setup.sql ``` -------------------------------- ### Create symlinks for assets Source: https://docs.romm.app/latest/API-and-Development/Development-Setup Creates symbolic links from the frontend's assets directory to the mock library and resources directories, ensuring assets are correctly referenced. ```bash mkdir assets/romm ln -s ../romm_mock/resources assets/romm/resources ln -s ../romm_mock/assets assets/romm/assets ``` -------------------------------- ### Create mock structure for RomM Source: https://docs.romm.app/latest/API-and-Development/Development-Setup Creates the necessary directory structure and placeholder files for RomM's mock data, ROMs, resources, assets, and configuration. This is a prerequisite for manual testing. ```bash mkdir -p romm_mock/library/roms/switch touch romm_mock/library/roms/switch/metroid.xci mkdir -p romm_mock/resources mkdir -p romm_mock/assets mkdir -p romm_mock/config touch romm_mock/config/config.yml ``` ```bash mkdir -p romm_mock/library/roms/switch touch romm_mock/library/roms/switch/metroid.xci mkdir -p romm_mock/resources mkdir -p romm_mock/assets mkdir -p romm_mock/config touch romm_mock/config/config.yml ``` -------------------------------- ### Copy environment template Source: https://docs.romm.app/latest/API-and-Development/Development-Setup Copies the environment template file to `.env`, which is used to configure application settings. This should be done before filling in the variables. ```bash cp env.template .env ``` ```bash cp env.template .env ``` -------------------------------- ### Checkout Master Branch Source: https://docs.romm.app/latest/API-and-Development/Contributing Switch to the 'master' branch of your local repository. ```bash git checkout master ``` -------------------------------- ### Build Docker image Source: https://docs.romm.app/latest/API-and-Development/Development-Setup Builds the Docker image for the RomM application using Docker Compose. Use `--no-cache` to ensure a clean rebuild from scratch. ```bash docker compose build # or `docker compose build --no-cache` to rebuild from scratch ``` -------------------------------- ### Create New ROM Entry Source: https://docs.romm.app/latest/API-and-Development/API-Reference Creates a new ROM entry in the RomM instance. ```APIDOC ## POST /roms ### Description Creates a new ROM entry. ### Method POST ### Endpoint /roms ### Parameters #### Request Body - **name** (string) - Required - The name of the ROM. - **platform_id** (integer) - Required - The ID of the platform the ROM belongs to. ### Request Example ```bash curl -X POST -u username:password \ -H "Content-Type: application/json" \ -d '{"name": "New ROM", "platform_id": 1}' \ http://your-instance:3000/api/roms ``` ### Response #### Success Response (200) - **rom** (object) - The newly created ROM object. ``` -------------------------------- ### Run backend tests Source: https://docs.romm.app/latest/API-and-Development/Development-Setup Executes backend tests using pytest within the virtual environment managed by `uv`. You can specify a path or file to test a subset, or run all tests with increased verbosity using `-vv`. ```bash cd backend # path or test file can be passed as argument to test only a subset uv run pytest [path/file] # or run the following command to run all tests # the -vv switch increases the verbosity of the output, providing more detailed information during test execution. uv run pytest -vv ``` -------------------------------- ### Download OpenAPI Specification Source: https://docs.romm.app/latest/API-and-Development/API-Reference URL to download the complete OpenAPI specification file for your RomM instance. This file can be used for API testing tools, client library generation, and API mocking. ```text http://your-instance:3000/openapi.json ``` -------------------------------- ### Clone RomM Repository Source: https://docs.romm.app/latest/API-and-Development/Contributing Clone your forked repository to your local machine. Replace 'your-username' with your GitHub username. ```bash git clone https://github.com/your-username/romm.git ``` -------------------------------- ### Create New Feature Branch Source: https://docs.romm.app/latest/API-and-Development/Contributing Create a new branch for your feature or bug fix. Replace 'feature-or-fix-name' with a descriptive name for your changes. ```bash git checkout -b feature-or-fix-name ``` -------------------------------- ### Configure environment variables Source: https://docs.romm.app/latest/API-and-Development/Development-Setup Sets essential environment variables for the RomM development environment, including the base path and development mode. ```bash ROMM_BASE_PATH=/app/romm DEV_MODE=true ``` -------------------------------- ### API Base URL Source: https://docs.romm.app/latest/API-and-Development/API-Reference The standard base URL for all API requests. Replace 'your-instance' with your RomM instance's URL or IP address. ```text http://your-instance:3000/api ``` -------------------------------- ### Run linter manually Source: https://docs.romm.app/latest/API-and-Development/Development-Setup Manually runs the Trunk formatter and checker to ensure code quality and style compliance. These commands are essential for passing CI checks. ```bash trunk fmt trunk check ``` -------------------------------- ### Commit Changes Source: https://docs.romm.app/latest/API-and-Development/Contributing Stage and commit your changes with a descriptive message. The '-am' flag stages all modified tracked files and commits them. ```bash git commit -am 'Add feature XYZ' ``` -------------------------------- ### Push Changes to Fork Source: https://docs.romm.app/latest/API-and-Development/Contributing Push your committed changes to your forked repository on GitHub. Replace 'feature-or-fix-name' with the name of your branch. ```bash git push origin feature-or-fix-name ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.