Get the *name* of a forum through the API

Solved Technical Support
  • I'm trying to build a little wrapper around the API (the one you get at by prefixing a URL with api/). Is there any place in the API where I could find the title of a forum?

    By the "title" I mean the bit after the halfpipe in the page title. For this, it's "NodeBB", for this forum it would be "omz:forum," etc.

    I could search the HTML for a <title> tag and then find the bit after the |, but using a full-fledged HTML parser to find the title of the forum seems rather like cracking a nut with a sledgehammer, especially when I'm using a JSON parser everywhere else. I'd rather not add another huge requirement to my project for such a simple task.

    Does the JSON API expose the forum title anywhere? If not, where can I easily find this information? I'm just resistant to the idea of pulling out a huge HTML parser only to find the title of a forum...

    Also, an API documentation would not be unappreciated, even an auto-generated thing that describes the fields for each of the types of API pages.

  • I don't think it's provided in any api route.
    You could either write a small plugin (exposing response.locals.config.siteTitle thought), or use a regex like JSON.parse(/^\s*var config = JSON.parse\('({[^']+})'\);/.exec(response)[1]).siteTitle where response is the HTML string of any page.

  • Yeah. Thanks for that. I forgot to mention, though, it's not just parsing the HTML of a page that's sub-optimal, but also downloading it in the first place.

    This project isn't meant to only work on one site, otherwise I would just hard-code it, so a plugin won't work. Is there any public file that might expose response.locals.config.siteTitle without my writing a plugin?

  • Oh, I found out there is a route: /api/config 😉
    Pretty straight forward...

Suggested Topics

  • Question About Popular Searches API

    Moved Unsolved Technical Support
    0 Votes
    5 Posts

    @baris said in Question About Popular Searches API:

    Not on my immediate plans, maybe after 3.x release.

    Gotcha, thanks again!

  • 1 Votes
    6 Posts

    Finally getting back around to testing this, still not having much luck. After digging through a lot of the code, and reading through the unit tests for the /api/post/upload endpoint, a user is logged in first.

    I have been trying to do this with only an API token, as this process is loading data from another system. I really don't want to have to store a password in addition to an API token when doing my data load.

    I guess my next question is: Is /api/post/upload even usable without logging in with a username/password?

  • 1 Votes
    7 Posts

    It was rather trivial to add the error message, here is how:

    in uglify-js module, added a error reporting log to the file lib\parse.js in following method:

    function js_error(message, filename, line, col, pos) { console.log(message, filename, line, col, pos); throw new JS_Parse_Error(message, filename, line, col, pos); };

    Looks like the error handling of fault barrier doesn't do what it supposed to.

    @PitaJ Thank again for your help.

  • Getting Version Number

    Technical Support
    0 Votes
    3 Posts

    Thank you @baris . Your tip didn't get me precisely what I needed but it got me on the right path. This is what I was looking for: config.version

  • How to modify the TAGs' name?

    Unsolved Technical Support
    0 Votes
    4 Posts

    @pichalite because some topics i synchronized from GHOST's blog through nodebb-plugin-blog-comments, and the TAGs were synchronized too, but it would appear that some TAGs' symbol were escaped by the system, just like musician's equip was escaped to musician&X27S equi....