Search API doesn't work

I am trying to use the Discourse API for a discord bot. I want to pass a search query via my bot and return the results back to discord after utilizing the Discourse API.

The problem is I can’t get the API to work. It just returns a HTML snippet. Here is the CURL request -

curl --location --request GET '' \
--header 'Api-Key: xxxx2901589946b34f0e81bfc39xxx633deef202b6f004af878fa62xxxxxxxxx' \
--header 'Api-Username: xxxx' 

[The API key and username are correct because they do work for other things].

Here’s the response I get

<!DOCTYPE html>
<html lang="en-US" class="desktop-view not-mobile-device text-size-normal">

    <meta charset="utf-8">
    <title>Andronix Community</title>
    <meta name="description" content="A place for everything Linux and Andronix">
    <meta name="discourse_theme_ids" content="3">
    <meta name="discourse_current_homepage" content="categories">
    <meta name="generator" content="Discourse 2.5.0.beta3 - version 5285cbee62ad7b0cee5b3bf0b6449174fb4f4491">
    <link rel="icon" type="image/png" href="">
    <link rel="apple-touch-icon" type="image/png" href="">
    <meta name="theme-color" content="#36393e">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, user-scalable=yes, viewport-fit=cover">

    <script type="application/ld+json">
            "@context": "",
            "@type": "WebSite",
            "url": "",
            "potentialAction": {
                "@type": "SearchAction",
                "target": "{search_term_string}",
                "query-input": "required name=search_term_string"
    <link rel="search" type="application/opensearchdescription+xml" href="" title="Andronix Community Search">

    <meta name="csrf-param" content="authenticity_token" />
    <meta name="csrf-token" content="3uVup/2b5g9JbWa3bJN0KA8RxeGi64VUXPBO6I58jsvja3QBTtPDeJtvyjlqnL4bSVQ77VuGmc665ukh7ir6aQ==" />

    <meta name="fragment" content="!">

    <link rel="preload" href="/assets/browser-update-331af91e0f999788d03c2128d366d5d0df480718b9e80914bfb0505cbb97af13.js" as="script">
    <script src="/assets/browser-update-331af91e0f999788d03c2128d366d5d0df480718b9e80914bfb0505cbb97af13.js"></script>



I have made the response shorter so it doesn’t look like spam

Would be grateful if anyone can point out what I am doing wrong. Thank you!

1 Like

Try using .json at the end:


(or you can use the Accept header to request JSON formatting)