How Do Requests Work?
The API takes and returns JSON. Every endpoint lives under one base URL:
Requests that send data, such as creating a log, need a Content-Type: application/json header. Bodies can be up to 64 KB.
Responses
A single item comes back under data:
Lists come back under data too, along with where you are in the list. See Lists.
When something goes wrong, you get an error instead. See Errors.
Lists
Endpoints that return many items, such as List Logs, return them a page at a time:
| Field | Description |
|---|---|
data | The items on this page |
page | The page you asked for |
pageSize | How many items each page holds |
total | How many items there are across every page |
totalPages | How many pages there are. 0 when there are no items. |
Paging
Add these to the URL to choose a page and its order.
| Parameter | Default | Description |
|---|---|---|
page | 1 | Which page to get. Pages start at 1. |
pageSize | 10 | How many items per page, from 1 to 100. |
orderBy | Depends on the list | Which field to order by. Each list endpoint says which fields it allows. |
sort | desc | desc for newest or highest first, asc for oldest or lowest first. |
For example, the 50 oldest logs:
To get everything, keep asking for the next page until you reach totalPages:
IDs and Times
| What | Format |
|---|---|
| IDs | Strings, even when they look like numbers. Keep them as strings, because many are too long for a JavaScript number. |
| Times | Whole numbers of milliseconds since 1 January 1970 (Unix time in milliseconds). new Date(1794776859830) in JavaScript. |
| Permissions | Bitfields sent as strings of digits. |
| Missing values | Fields with no value are left out, rather than sent as null. |
Member IDs
Endpoints that ask for a member, such as createdBy on a log, want a member ID. A member ID is the person's Melonly user ID, not their Discord ID.
To get it from a Discord ID, use Get a Member by Discord ID:
The member's ID is in data.id.
Where to Go Next
Need help?
Still have questions? Join our Discord server for support from the Melonly Team.