Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product

In this Discussion

Comments API endpoint help

Hi,

I've been wanting to try out the new API.

So, I can get a particular discussion given it's ID, like so:
https://open.vanillaforums.com/api/v2/discussions/35687

So what if I want to get the comments for this discussion? /api/v2/comments reports that "One of discussionID, insertUserID are required" - great. So I try this:
https://open.vanillaforums.com/api/v2/comments?discussionID=35687

But all I get back is an empty list.

Let's try insertUserID:
https://open.vanillaforums.com/api/v2/comments?insertUserID=10878

Still an empty list back.

Is this a permission thing? If not can someone please help me out and tell my what I'm doing wrong? Thanks!

Comments

  • You are better off using the basic read only api. there little documentation on the api endpoint

    All the information you need can be found with

    https://open.vanillaforums.com/discussion/35687.json

    grep is your friend.

    R_J
  • Note: be careful don't expect the data to be sanitised.

    grep is your friend.

  • Thanks @x00 for the information! I thought the v2 API was more fleshed out.

    Is there any docs at all for the read only API? Like limits, pagination, etc?

  • x00x00 MVP
    edited January 4

    not really.

    The read only API uses the same controller it is just retunring the data used rather than the page. You can also just return the view and not the whole page.

    You have CountComments and Pageand you can count the number of comment on that page. The rest you can work out.

    adding .jsonto the url Is a a quick way of adding ?DeliveryMethod=JSON&DeliveryType=DATA

    This is the best you will get in terms of documentation.

    // Delivery type enumerators:
    define('DELIVERY_TYPE_ALL', 'ALL'); // Deliver an entire page
    define('DELIVERY_TYPE_ASSET', 'ASSET'); // Deliver all content for the requested asset
    define('DELIVERY_TYPE_VIEW', 'VIEW'); // Deliver only the view
    define('DELIVERY_TYPE_BOOL', 'BOOL'); // Deliver only the success status (or error) of the request
    define('DELIVERY_TYPE_NONE', 'NONE'); // Deliver nothing
    define('DELIVERY_TYPE_MESSAGE', 'MESSAGE'); // Just deliver messages.
    define('DELIVERY_TYPE_DATA', 'DATA'); // Just deliver the data.
    
    // Delivery method enumerators
    define('DELIVERY_METHOD_XHTML', 'XHTML');
    define('DELIVERY_METHOD_JSON', 'JSON');
    define('DELIVERY_METHOD_XML', 'XML');
    /**
     * @since 2.1
     */
    define('DELIVERY_METHOD_TEXT', 'TXT');
    define('DELIVERY_METHOD_PLAIN', 'PLAIN');
    define('DELIVERY_METHOD_RSS', 'RSS');
    

    Also library/core/class.controller.php give you an idea of what is goign on

    if you wanted just the view you could do ?DeliveryMethod=JSON&DeliveryType=VIEW

    grep is your friend.

  • x00x00 MVP
    edited January 4

    Out of interest what are you trying to do what si this for?

    grep is your friend.

  • The goal is to essentially search a set of discussions for a few conditions, based on their content - Thanks again for the info, makes sense, I will give this a go.

Sign In or Register to comment.