melonly logomelonly logo
melonly logo
Dashboard
Log in

Making Requests

How responses are shaped, how to page through lists and how IDs and times work.

How Do Requests Work?

The API takes and returns JSON. Every endpoint lives under one base URL:

https://api.melonly.com/api/v1

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:

{
  "data": {
    "id": "7527833441069436928",
    "text": "vdm at gas station (again)"
  }
}

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:

{
  "data": [
    { "id": "7527833441069436928", "text": "vdm at gas station (again)" }
  ],
  "page": 1,
  "pageSize": 10,
  "total": 42,
  "totalPages": 5
}
FieldDescription
dataThe items on this page
pageThe page you asked for
pageSizeHow many items each page holds
totalHow many items there are across every page
totalPagesHow many pages there are. 0 when there are no items.

Paging

Add these to the URL to choose a page and its order.

ParameterDefaultDescription
page1Which page to get. Pages start at 1.
pageSize10How many items per page, from 1 to 100.
orderByDepends on the listWhich field to order by. Each list endpoint says which fields it allows.
sortdescdesc for newest or highest first, asc for oldest or lowest first.

For example, the 50 oldest logs:

GET /api/v1/server/logs?pageSize=50&sort=asc

To get everything, keep asking for the next page until you reach totalPages:

const members = [];

for (let page = 1, totalPages = 1; page <= totalPages; page++) {
  const response = await fetch(`https://api.melonly.com/api/v1/server/members?page=${page}&pageSize=100`, {
    headers: { Authorization: `Bearer ${process.env.MELONLY_TOKEN}` },
  });
  const json = await response.json();
  members.push(...json.data);
  totalPages = json.totalPages;
}

IDs and Times

WhatFormat
IDsStrings, even when they look like numbers. Keep them as strings, because many are too long for a JavaScript number.
TimesWhole numbers of milliseconds since 1 January 1970 (Unix time in milliseconds). new Date(1794776859830) in JavaScript.
PermissionsBitfields sent as strings of digits.
Missing valuesFields 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:

GET /api/v1/server/members/discord/1043254628961792060

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.