S&box Wiki

Revision Difference

Backend_API#529971

<cat>Dev.Backend</cat> All endpoints are on the `https://apix.facepunch.com/api/` domain. # Types NOTE: Nullable types are suffixed with `?`. This API is subject to change and probably will do so before release. ## PackageType An enum specifying the different package types. Starting at 1: ``` 1. Map 2. Gamemode ``` ## Find Result This is returned by `/sbox/asset/find` and is used to enumerate search results. |Name |Type |Description | |---------------|----------------|----------------------------------------------| | type | `PackageType` | The package types being returned | | assets | `Package[]` | A list of matching packages | ## Category This is returned by `/sbox/menu/index` and is used to describe a category displayed on the main menu. |Name |Type |Description | |---------------|-------------|----------------------------------------------| | title | `string` | This category's title | | description | `string?` | This category's description | | packages | `Package[]` | A list of packages within this category | ## Asset This is returned by `/sbox/asset/get`. |Name |Type |Description | |---------------|-----------|----------------------------------------------| | asset | `Package` | This asset's package info | ## Package These are used in various places and are used to describe assets like gamemodes and maps. |Name |Type |Description | |---------------|---------------|-------------------------------------------------------| | org | `Org` | The organisation owning this package | | ident | `string` | This package's identifier | | title | `string` | This package's human-friendly name | | summary | `string?` | A short description for this package | | thumb | `string?` | A URL to this package's thumbnail | | packageType | `PackageType` | The package's type | | updated | `long` | UNIX timestamp for when the package was last updated | | description | `string?` | A longer description for this package | | background | `string?` | A URL to this package's in-game background | | downloadUrl | `string?` | A download URL for this package | ## Org These are used in various places and are used to describe organisations. |Name |Type |Description | |---------------|----------|----------------------------------------------| | ident | `string` | This organisation's identifier | | title | `string` | This organisation's human-friendly name | | description | `string?`| This organisation's description | | thumb | `string?`| A URL to the organisation's chosen thumbnail | | socialTwitter | `string?`| A URL to the organisation's Twitter account | | socialWeb | `string?`| A URL to the organisation's website | # Endpoints ## /sbox/menu/index ### Params None ### Returns A list of `Category` objects. ### Example Response ``` [ { "title": "Newest Releases", "description": "The latest released games", "packages": [ { "org": { "ident": "facepunch", "title": "Facepunch" }, "ident": "pool", "title": "Pool", "summary": "A classic pub game where your skill is determined by...", "thumb": "https://files.facepunch.com/sbox/org/facepunch/pool/thumb.1.jpg", "packageType": 2, "updated": 1619706156 } ] }, { "title": "Most Ppular", "description": "Games that are being played the most", "packages": [ { "org": { "ident": "rtmstuff", "title": "rtm516's Stuff" }, "ident": "prophunt", "title": "Prophunt", "summary": "A Prophunt gamemode for S&box", "thumb": "https://files.facepunch.com/sbox/org/rtmstuff/prophunt/thumb.2.jpg", "packageType": 2, "updated": 1619100319 } ] } ] ``` [/sbox/menu/index](https://apix.facepunch.com/api/sbox/menu/index) --- ## /sbox/asset/get ### Params `id`: An identifier (`org`.`package`) for the asset you wish to retrive info about. ### Returns An `Asset` ### Example Response ``` { "asset": { "org": { "ident": "facepunch", "title": "Facepunch", "description": "", "thumb": "https://files.facepunch.com/sbox/org/facepunch/logo.1.png", "socialTwitter": "", "socialWeb": "" }, "ident": "pool", "title": "Pool", "summary": "A classic pub game where your skill is determined by your blood-alcohol content.\r\n", "description": "A classic pub game where your skill is determined by your blood-alcohol content.\r\n", "thumb": "https://files.facepunch.com/sbox/org/facepunch/pool/thumb.1.jpg", "background": "https://files.facepunch.com/sbox/org/facepunch/pool/background.1.jpg", "packageType": 2, "downloadUrl": "https://github.com/Facepunch/sbox-pool", "updated": 1619706156 } } ``` [/sbox/asset/get?id=facepunch.pool](https://apix.facepunch.com/api/sbox/asset/get?id=facepunch.pool) --- ## /sbox/asset/find ### Params `type`: `map` or `gamemode`. ### Returns A `FindResult` object. ### Example Response ``` { "type": 1, "assets": [ { "org": { "ident": "baks", "title": "bakscratch" }, "ident": "office", "title": "Workplace", "summary": "Remake of popular map; WIP just the interior.", "thumb": "https://files.facepunch.com/sbox/org/baks/office/thumb.4.jpg", "packageType": 1, "updated": 1619045983 }, { "org": { "ident": "exeros", "title": "Exeros" }, "ident": "floodgate", "title": "Flood Gate", "summary": "Flood map", "thumb": "https://files.facepunch.com/sbox/org/exeros/floodgate/thumb.2.jpg", "packageType": 1, "updated": 1619037397 } ] } ``` [/sbox/asset/find?type=map](http://apix.facepunch.com/api/sbox/asset/find?type=map) # Other ## Finding an Org There's no known endpoint for organisations. This is the closest you can get: 1. Visit several endpoints (`/asset/find?type={map}|{gamemode}`, `/menu/index`) and collect a list of orgs with their gamemode idents 2. Search that list for an org that matches the ident we're looking for 3. Visit `/asset/get?id={org}.{ident}` 4. Get the title & description for the org from this