Use API to get topics for a period using js

AI-generated summary

A user asks for a simple JavaScript example to retrieve topics from a specific category within a timeframe using the Discourse API, aiming to pull data into Google Sheets. pfaffman suggests using the Data Explorer plugin and its API, but per_coh notes they can’t use it due to their plan. They managed to get the search API working, but the data is incomplete—topics and posts don’t include all needed fields like post titles or author info. They seek a single endpoint that returns a complete dataset with fields like topic ID, title, body, author username, author ID, post date, and category. They provide a basic working example using the search API.

I was wondering if anyone has a simple javascript get example, to get topics from a certain category within a certain timeframe? I’m looking to pull data into Google sheets and I’m a bit rusty (and new to the Discourse reports API).

I think your best bet is the data explorer plugin and Run Data Explorer queries with the Discourse API

Thanks. I’ll try that when/if we upgrade our plan. In the mean time I did get something to work using the search API.
Only strange thing is I can get topics and posts, but neither dataset is complete, and I really don’t want to start manually joining sets by topic id.
(For example, the posts dataset doesn’t give me the post title. The topics dataset doesn’t show author info)

Is there anyone who knows of an endpoint that will give me, with ONE query, a list of topics with this data? <topic id, topic title, topic body, topic author username, topic author id, post date, category>

FWIW, the basics work:

var url = 'https://community.coherence.io/search.json?q=%23suggestions%20after%3A2023-02-01&page=1';
  var options = {
    'method' : 'get',
    'contentType': 'application/json',  
    'muteHttpExceptions' : true,
      'headers': {
      'Api-Key': '<key>',
      'Api-Username' : '<username>'
    }
  }