diff --git a/PluralKit.API/Controllers/AccountController.cs b/PluralKit.API/Controllers/AccountController.cs new file mode 100644 index 00000000..f99f565e --- /dev/null +++ b/PluralKit.API/Controllers/AccountController.cs @@ -0,0 +1,27 @@ +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; + +namespace PluralKit.API.Controllers +{ + [ApiController] + [Route("a")] + [Route("v1/a")] + public class AccountController: ControllerBase + { + private SystemStore _systems; + + public AccountController(SystemStore systems) + { + _systems = systems; + } + + [HttpGet("{aid}")] + public async Task> GetSystemByAccount(ulong aid) + { + var system = await _systems.GetByAccount(aid); + if (system == null) return NotFound("Account not found."); + + return Ok(system); + } + } +} \ No newline at end of file diff --git a/docs/3-api-documentation.md b/docs/3-api-documentation.md index a2700f3a..b17ec545 100644 --- a/docs/3-api-documentation.md +++ b/docs/3-api-documentation.md @@ -279,7 +279,28 @@ Edits a member's information. Missing fields will be set to `null`. Will return } ``` +### GET /a/\ +Queries a system by its linked Discord account ID (17/18-digit numeric snowflake). Returns `404 Not Found` if the account doesn't have a system linked. + +#### Example request + GET https://api.pluralkit.me/v1/a/466378653216014359 + +#### Example response +```json +{ + "id": "abcde", + "name": "My System", + "description": "This is my system description. Yay.", + "tag": "[MySys]", + "avatar_url": "https://path/to/avatar/image.png", + "tz": "Europe/Copenhagen", + "created": "2019-01-01T14:30:00.987654Z" +} +``` + ## Version history +* 2019-07-17 + * Add endpoint for querying system by account * 2019-07-10 **(v1)** * First specified version * (prehistory)