Add endpoint for querying systems by Discord snowflake
This commit is contained in:
parent
1c48cb2fc7
commit
e28ed585ce
27
PluralKit.API/Controllers/AccountController.cs
Normal file
27
PluralKit.API/Controllers/AccountController.cs
Normal file
@ -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<ActionResult<PKSystem>> GetSystemByAccount(ulong aid)
|
||||
{
|
||||
var system = await _systems.GetByAccount(aid);
|
||||
if (system == null) return NotFound("Account not found.");
|
||||
|
||||
return Ok(system);
|
||||
}
|
||||
}
|
||||
}
|
@ -279,7 +279,28 @@ Edits a member's information. Missing fields will be set to `null`. Will return
|
||||
}
|
||||
```
|
||||
|
||||
### GET /a/\<id>
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user