Discord · Search

Search messages

One server search page, with native filters and offset paging. Costs 4 credits a message.

01

Request

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

guild_idrequired server (guild) ID, as a string
limitmessages per page; integer, default 25
offsetpage starting position; integer, default 0

For example, search for release messages in this server:

curl --request POST 'https://scraping.loci.lat/discord/messages/search' \
  --header 'Authorization: Bearer YOUR_LOCI_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
  "guild_id": "302094807046684672",
  "content": "release",
  "limit": 25,
  "offset": 0
}'

Search the server by sending guild_id. To select a channel, add "channel_id": ["302987265229979649"].

contentstring. Text to search for.
channel_idarray of strings. Search selected channels. Leave blank to search the server.
author_idarray of strings. Match messages by these authors.
author_typearray of strings. user, bot or webhook. Prefix a value with - to exclude it.
mentionsarray of strings. Match messages mentioning these users.
mentions_role_idarray of strings. Match messages mentioning these roles.
mention_everyoneboolean. Filter messages that mention everyone.
replied_to_user_idarray of strings. Match replies to these users.
replied_to_message_idarray of strings. Match replies to these messages.
min_idstring. Start of the message ID range.
max_idstring. End of the message ID range.
pinnedboolean. Filter by whether messages are pinned.
hasarray of strings. image, sound, video, file, sticker, embed, link, poll, snapshot. Prefix - to exclude.
embed_typearray of strings. image, video, gif, sound or article.
embed_providerarray of strings. Match embeds by provider name.
link_hostnamearray of strings. Match links by hostname.
attachment_filenamearray of strings. Match attachments by filename.
attachment_extensionarray of strings. Match attachments by file extension.
sort_bystring. Defaults to timestamp. Values: timestamp, relevance.
sort_orderstring. Defaults to desc. Values: desc, asc.
include_nsfwboolean. Include NSFW results. Defaults to false.
slopinteger. Word proximity for text matching. Defaults to 2.

Send filter lists as JSON arrays and IDs as strings.

02

Next page example

The first page uses offset: 0. With limit: 25, the next page uses offset: 25, then 50, 75 and so on. Keep the same guild and filters.

Add the requested limit to offset for each following page.

{
  "guild_id": "302094807046684672",
  "content": "release",
  "limit": 25,
  "offset": 25
}
▸ ▾ Next page response example (illustrative)
{
  "cost": 8,
  "request_duration": 340,
  "parse_duration": 0,
  "created_at": 1793440802,
  "data": {
    "guild_id": "302094807046684672",
    "total_results": 57,
    "doing_deep_historical_index": false,
    "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": {
    "guild_id": "302094807046684672",
    "total_results": 57,
    "doing_deep_historical_index": false,
    "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": []
      }
    ]
  }
}

Matching messages are returned in data.messages. data.total_results contains the reported match count.

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 {}

guild_idtextRequested server ID.
messagesobject[]Matching messages from one search page; fields are listed below.
total_resultsnumberDiscord's estimated total matches. It can change while paging.
doing_deep_historical_indexbooleanWhether Discord reports deep historical indexing.
documents_indexednumberIndexing progress, when returned.
threadsobject[]Native thread channel objects associated with results, when returned.
membersobject[]Native thread-member objects, when returned.

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 →