|
| 1 | +# API Reference |
| 2 | + |
| 3 | +RomM provides a comprehensive REST API that allows you to programmatically interact with your RomM instance. Most API endpoints are authenticated and follow RESTful conventions. |
| 4 | + |
| 5 | +## Interactive Documentation |
| 6 | + |
| 7 | +RomM automatically generates interactive API documentation using OpenAPI (Swagger). You can access the interactive API docs directly from your running instance: |
| 8 | + |
| 9 | +- **Swagger UI**: Available at `http://your-instance:3000/api/docs` |
| 10 | +- **ReDoc**: Available at `http://your-instance:3000/api/redoc` |
| 11 | + |
| 12 | +These interactive docs allow you to: |
| 13 | + |
| 14 | +- Browse all available endpoints |
| 15 | +- View request/response schemas |
| 16 | +- Test API calls directly from your browser |
| 17 | +- Understand authentication requirements |
| 18 | +- Download the OpenAPI specification |
| 19 | + |
| 20 | +## Base URL |
| 21 | + |
| 22 | +The API base URL is typically: |
| 23 | + |
| 24 | +```text |
| 25 | +http://your-instance:3000/api |
| 26 | +``` |
| 27 | + |
| 28 | +Replace `your-instance` with your actual RomM instance URL or IP address. |
| 29 | + |
| 30 | +## Authentication |
| 31 | + |
| 32 | +All API endpoints require authentication. RomM supports: |
| 33 | + |
| 34 | +- **Basic HTTP Authentication** - Username and password |
| 35 | +- **OAuth2 Password Bearer** - Token-based authentication (recommended for API usage) |
| 36 | + |
| 37 | +When using OAuth2, you'll need to obtain a token from `/api/token` endpoint and include it in the `Authorization` header as `Bearer <token>`. |
| 38 | + |
| 39 | +### OAuth2 Scopes |
| 40 | + |
| 41 | +The API uses OAuth2 scopes to control access to different resources: |
| 42 | + |
| 43 | +**Read Scopes:** |
| 44 | + |
| 45 | +- `me.read` - View your profile |
| 46 | +- `roms.read` - View ROMs |
| 47 | +- `platforms.read` - View platforms |
| 48 | +- `assets.read` - View assets |
| 49 | +- `firmware.read` - View firmware |
| 50 | +- `roms.user.read` - View user-rom properties |
| 51 | +- `collections.read` - View collections |
| 52 | +- `users.read` - View users |
| 53 | + |
| 54 | +**Write Scopes:** |
| 55 | + |
| 56 | +- `me.write` - Modify your profile |
| 57 | +- `assets.write` - Modify assets |
| 58 | +- `roms.user.write` - Modify user-rom properties |
| 59 | +- `collections.write` - Modify collections |
| 60 | +- `roms.write` - Modify ROMs |
| 61 | +- `platforms.write` - Modify platforms |
| 62 | +- `firmware.write` - Modify firmware |
| 63 | +- `users.write` - Modify users |
| 64 | +- `tasks.run` - Run tasks |
| 65 | + |
| 66 | +## API Endpoints Overview |
| 67 | + |
| 68 | +The RomM API provides comprehensive endpoints for managing all aspects of your ROM collection: |
| 69 | + |
| 70 | +### Core Resources |
| 71 | + |
| 72 | +- **Platforms** - Manage and configure gaming platforms |
| 73 | +- **ROMs** - Full CRUD operations for ROM files with extensive filtering, searching, and metadata matching |
| 74 | +- **Collections** - Create and manage ROM collections, smart collections, and virtual collections |
| 75 | +- **Users** - User management, authentication, invite links, and profiles |
| 76 | + |
| 77 | +### Supporting Features |
| 78 | + |
| 79 | +- **Authentication** - OAuth2 token management, OIDC login, password resets |
| 80 | +- **Search** - Metadata provider search for ROMs and covers |
| 81 | +- **Tasks** - Background task management and execution |
| 82 | +- **Assets** - Save files, states, screenshots management |
| 83 | +- **Firmware** - Upload and manage firmware files for emulation |
| 84 | +- **Configuration** - System configuration, platform bindings, and exclusions |
| 85 | +- **Feeds** - Integration feeds for WebRcade and Tinfoil |
| 86 | +- **Statistics** - System statistics and resource tracking |
| 87 | + |
| 88 | +For complete endpoint documentation including request/response schemas, query parameters, and authentication requirements, visit the interactive API documentation at `/api/docs` or `/api/redoc` on your RomM instance. |
| 89 | + |
| 90 | +## Example Usage |
| 91 | + |
| 92 | +### Using cURL |
| 93 | + |
| 94 | +```bash |
| 95 | +# Get all libraries |
| 96 | +curl -u username:password http://your-instance:3000/api/libraries |
| 97 | + |
| 98 | +# Get a specific ROM |
| 99 | +curl -u username:password http://your-instance:3000/api/roms/123 |
| 100 | + |
| 101 | +# Create a new ROM entry |
| 102 | +curl -X POST -u username:password \ |
| 103 | + -H "Content-Type: application/json" \ |
| 104 | + -d '{"name": "New ROM", "platform_id": 1}' \ |
| 105 | + http://your-instance:3000/api/roms |
| 106 | +``` |
| 107 | + |
| 108 | +### Using Python |
| 109 | + |
| 110 | +```python |
| 111 | +import requests |
| 112 | +from requests.auth import HTTPBasicAuth |
| 113 | + |
| 114 | +# Setup authentication |
| 115 | +auth = HTTPBasicAuth('username', 'password') |
| 116 | +base_url = 'http://your-instance:3000/api' |
| 117 | + |
| 118 | +# Get all libraries |
| 119 | +response = requests.get(f'{base_url}/libraries', auth=auth) |
| 120 | +libraries = response.json() |
| 121 | + |
| 122 | +# Get a specific ROM |
| 123 | +response = requests.get(f'{base_url}/roms/123', auth=auth) |
| 124 | +rom = response.json() |
| 125 | +``` |
| 126 | + |
| 127 | +### Using JavaScript/Node.js |
| 128 | + |
| 129 | +```javascript |
| 130 | +const axios = require("axios"); |
| 131 | + |
| 132 | +// Setup authentication |
| 133 | +const api = axios.create({ |
| 134 | + baseURL: "http://your-instance:3000/api", |
| 135 | + auth: { |
| 136 | + username: "username", |
| 137 | + password: "password", |
| 138 | + }, |
| 139 | +}); |
| 140 | + |
| 141 | +// Get all libraries |
| 142 | +const libraries = await api.get("/libraries"); |
| 143 | + |
| 144 | +// Get a specific ROM |
| 145 | +const rom = await api.get("/roms/123"); |
| 146 | +``` |
| 147 | + |
| 148 | +## OpenAPI Specification |
| 149 | + |
| 150 | +You can download the complete OpenAPI specification from your RomM instance: |
| 151 | + |
| 152 | +```text |
| 153 | +http://your-instance:3000/api/openapi.json |
| 154 | +``` |
| 155 | + |
| 156 | +This specification can be imported into API testing tools like Postman, used to generate client libraries, or used for API mocking. |
| 157 | + |
| 158 | +## Getting Help |
| 159 | + |
| 160 | +For API-specific questions or issues: |
| 161 | + |
| 162 | +1. Check the interactive documentation at `/api/docs` or `/api/redoc` on your instance |
| 163 | +2. Review the code in the [RomM repository](https://github.com/rommapp/romm) |
| 164 | +3. Open an issue on [GitHub](https://github.com/rommapp/romm/issues) |
| 165 | +4. Join the [Discord community](https://discord.com/invite/romm) |
0 commit comments