Discord · Channels

Channel messages

One channel history page, using native message ID boundaries. Costs 4 credits a message.

01

Request

POST /discord/channels/messages with your Loci API key to fetch one page of messages.

channel_idrequired channel ID or Discord channel/message URL, as a string; url and channel_url are also accepted
limitmessages per page; integer, default 100
before / after / aroundmessage ID for older messages, newer messages or a surrounding window

For example, fetch recent messages from this channel:

curl --request POST 'https://scraping.loci.lat/discord/channels/messages' \
  --header 'Authorization: Bearer YOUR_LOCI_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
  "channel_id": "302987265229979649",
  "limit": 100
}'

The default page contains recent messages, newest first. Use before for older messages, after for newer messages, or around for a window around a message.

02

Next page example

Take the oldest returned message ID—1564317995990519851 in the example below—and send it as before to read older messages.

For newer messages, use after with the newest returned ID instead. An empty page contains messages: [].

{
  "channel_id": "302987265229979649",
  "limit": 100,
  "before": "1564317995990519851"
}
▸ ▾ Next page response example (illustrative)
{
  "cost": 8,
  "request_duration": 340,
  "parse_duration": 0,
  "created_at": 1793440802,
  "data": {
    "channel_id": "302987265229979649",
    "messages": [
      {
        "id": "1564317995990519850",
        "channel_id": "302987265229979649",
        "type": 0,
        "content": "Release notes are ready.",
        "author": {
          "id": "123456789012345678",
          "username": "example-bot",
          "global_name": null,
          "avatar": null,
          "bot": true
        },
        "timestamp": "2026-10-31T09:59:00+00:00",
        "edited_timestamp": null,
        "mentions": [],
        "mention_roles": [],
        "attachments": [],
        "embeds": [],
        "pinned": false,
        "mention_everyone": false,
        "tts": false,
        "flags": 0,
        "components": []
      },
      {
        "id": "1564317995990519849",
        "channel_id": "302987265229979649",
        "type": 0,
        "content": "The release build passed testing.",
        "author": {
          "id": "123456789012345678",
          "username": "example-bot",
          "global_name": null,
          "avatar": null,
          "bot": true
        },
        "timestamp": "2026-10-31T09:58:00+00:00",
        "edited_timestamp": null,
        "mentions": [],
        "mention_roles": [],
        "attachments": [],
        "embeds": [],
        "pinned": false,
        "mention_everyone": false,
        "tts": false,
        "flags": 0,
        "components": []
      }
    ]
  }
}

03

Response example

This illustrative response contains two messages and costs 8 credits. IDs are strings, flags and counts are numbers, and timestamps retain Discord’s ISO format. The reply includes its referenced message.

▸ ▾ Full response example
{
  "cost": 8,
  "request_duration": 340,
  "parse_duration": 0,
  "created_at": 1793440802,
  "data": {
    "channel_id": "302987265229979649",
    "messages": [
      {
        "id": "1564317995990519852",
        "channel_id": "302987265229979649",
        "type": 19,
        "content": "Release testing starts today. Reply here with feedback.",
        "author": {
          "id": "123456789012345678",
          "username": "example-bot",
          "global_name": null,
          "avatar": null,
          "bot": true
        },
        "timestamp": "2026-10-31T10:00:01+00:00",
        "edited_timestamp": null,
        "mentions": [],
        "mention_roles": [],
        "attachments": [],
        "embeds": [],
        "pinned": false,
        "mention_everyone": false,
        "tts": false,
        "flags": 0,
        "components": [],
        "message_reference": {
          "type": 0,
          "guild_id": "302094807046684672",
          "channel_id": "302987265229979649",
          "message_id": "1564317995990519851"
        },
        "referenced_message": {
          "id": "1564317995990519851",
          "channel_id": "302987265229979649",
          "type": 0,
          "content": "The next release is ready for testing.",
          "author": {
            "id": "123456789012345678",
            "username": "example-bot",
            "global_name": null,
            "avatar": null,
            "bot": true
          },
          "timestamp": "2026-10-31T10:00:00+00:00",
          "edited_timestamp": null,
          "mentions": [],
          "mention_roles": [],
          "attachments": [],
          "embeds": [],
          "pinned": false,
          "mention_everyone": false,
          "tts": false,
          "flags": 0,
          "components": []
        }
      },
      {
        "id": "1564317995990519851",
        "channel_id": "302987265229979649",
        "type": 0,
        "content": "The next release is ready for testing.",
        "author": {
          "id": "123456789012345678",
          "username": "example-bot",
          "global_name": null,
          "avatar": null,
          "bot": true
        },
        "timestamp": "2026-10-31T10:00:00+00:00",
        "edited_timestamp": null,
        "mentions": [],
        "mention_roles": [],
        "attachments": [],
        "embeds": [],
        "pinned": false,
        "mention_everyone": false,
        "tts": false,
        "flags": 0,
        "components": []
      }
    ]
  }
}

04

Fields

response {}

costnumberCredits deducted for this page, capped at the remaining balance. Listed cost: 4 credits per message.
created_atnumberCapture creation time as Unix seconds.
request_durationnumberCapture duration in milliseconds.
parse_durationnumberParsing duration in milliseconds.

data {}

channel_idtextRequested channel ID.
messagesobject[]One history page, newest first; fields are listed below.

data.messages []

idtextMessage snowflake ID. Use the oldest returned ID as before to fetch older history.
channel_idtextChannel containing the message.
typenumberDiscord message type, such as a normal message or reply.
contenttextNative message text, including emoji and Discord mention markup.
▸ ▾ authorobjectAuthor account details.
idtextDiscord user ID, kept as a string.
usernametextAccount username.
global_nametext|nullDisplay name, or null.
discriminatortextNative discriminator when supplied.
avatartext|nullAvatar asset hash; this is not a complete image URL.
botbooleanWhether the author is a bot, when Discord supplies this flag.
public_flagsnumberPublic account flag bitfield, when present.
flagsnumberAccount flags returned by Discord.
bannertext|nullBanner asset hash, when supplied.
banner_colortext|nullProfile banner colour, when supplied.
accent_colornumber|nullNative profile accent colour.
avatar_decoration_dataobject|nullNative avatar-decoration metadata.
primary_guildobject|nullPrimary guild tag and badge details.
clanobject|nullLegacy guild-tag details, when returned.
collectiblesobject|nullNative collectible profile items.
display_name_stylesobject|nullDisplay-name styling metadata.
timestamptextCreation time as an ISO 8601 timestamp.
edited_timestamptext|nullLast edit time, or null if not edited.
▸ ▾ mentionsobject[]Mentioned users.
idtextDiscord user ID, kept as a string.
usernametextAccount username.
global_nametext|nullDisplay name, or null.
discriminatortextNative discriminator when supplied.
avatartext|nullAvatar asset hash; this is not a complete image URL.
botbooleanWhether the author is a bot, when Discord supplies this flag.
public_flagsnumberPublic account flag bitfield, when present.
flagsnumberAccount flags returned by Discord.
bannertext|nullBanner asset hash, when supplied.
banner_colortext|nullProfile banner colour, when supplied.
accent_colornumber|nullNative profile accent colour.
avatar_decoration_dataobject|nullNative avatar-decoration metadata.
primary_guildobject|nullPrimary guild tag and badge details.
clanobject|nullLegacy guild-tag details, when returned.
collectiblesobject|nullNative collectible profile items.
display_name_stylesobject|nullDisplay-name styling metadata.
mention_rolestext[]Mentioned role IDs, kept as strings.
mention_everyonebooleanWhether the message mentions everyone.
▸ ▾ attachmentsobject[]Native file, image, audio or video attachments.
idtextAttachment ID as a string.
filenametextUploaded filename.
titletextDisplayed attachment title, when supplied.
content_typetextMIME content type, when supplied.
original_content_typetextOriginal MIME type, when returned.
sizenumberFile size in bytes.
urltextDownload URL; signed attachment URLs may expire.
proxy_urltextDiscord's proxied media URL.
widthnumber|nullImage or video width in pixels.
heightnumber|nullImage or video height in pixels.
duration_secsnumberAudio or video duration, when supplied.
placeholdertextNative encoded media preview.
placeholder_versionnumberPreview format version.
content_scan_versionnumberNative content-scan metadata.
▸ ▾ embedsobject[]Native embedded cards and media.
typetextNative embed type, such as rich, image, video or link.
titletextEmbed title, when present.
descriptiontextEmbed body text.
urltextLinked URL.
colornumberNative embed colour.
▸ ▾ fieldsobject[]Named text fields.
nametextField heading.
valuetextField content.
inlinebooleanWhether the field is displayed inline.
▸ ▾ imageobjectEmbedded image.
urltextSource media URL.
proxy_urltextProxied media URL, when supplied.
widthnumberMedia width in pixels.
heightnumberMedia height in pixels.
▸ ▾ thumbnailobjectThumbnail image.
urltextSource media URL.
proxy_urltextProxied media URL, when supplied.
widthnumberMedia width in pixels.
heightnumberMedia height in pixels.
▸ ▾ videoobjectEmbedded video.
urltextSource media URL.
proxy_urltextProxied media URL, when supplied.
widthnumberMedia width in pixels.
heightnumberMedia height in pixels.
providerobjectProvider name and URL, when supplied.
authorobjectEmbed author name, URL and icon details.
footerobjectFooter text and icon details.
timestamptextISO timestamp, when supplied.
reference_idtextNative embed reference ID, when present.
content_scan_versionnumberNative content-scan metadata.
▸ ▾ reactionsobject[]Reaction details when present.
countnumberTotal reaction count.
▸ ▾ emojiobjectReaction emoji.
idtext|nullCustom emoji ID, or null for Unicode emoji.
nametext|nullUnicode character or custom emoji name.
animatedbooleanWhether a custom emoji is animated, when supplied.
▸ ▾ count_detailsobjectNormal and burst reaction counts.
normalnumberNormal reactions.
burstnumberBurst reactions.
mebooleanSelf-reaction indicator.
me_burstbooleanSelf burst-reaction indicator.
burst_mebooleanAlternative native burst-reaction flag, when returned.
burst_countnumberNative burst count, when returned.
burst_colorstext[]Burst reaction colours.
▸ ▾ message_referenceobjectReply or forward target, when present.
typenumberDiscord reference type, when present.
message_idtextReferenced message ID.
channel_idtextReferenced channel ID.
guild_idtextReferenced server ID, when supplied.
referenced_messageobject|nullReferenced message returned by Discord, using the same message fields. Null can mean the reference is unavailable.
componentsobject[]Native interactive message components.
pinnedbooleanWhether this message is pinned.
ttsbooleanWhether text-to-speech was requested.
flagsnumberNative message flag bitfield.
webhook_idtextWebhook ID, when the message was sent by a webhook.
hitbooleanNative search-match flag, when returned.

Message fields keep Discord’s names and types, including authors, attachments, embeds, reactions and referenced messages when present.

The full native resource is described in Discord’s message API reference.

05

Credits

The listed cost is 4 credits per returned message: 100 credits for 25 messages or 400 credits for 100. cost shows the actual deduction, capped at your remaining balance. Empty results cost zero; failed calls return the credits deducted.

Try this in the console →