JSON API with MarketPress and other plugins

I have been trying to get products and categories in the marketpress plugin via the JSON API plugin. However, I cannot seem to access them with any of the api methods (eg, get_category_posts and so on). Have you any advice on how I can get MarketPress products to output in JSON? I have same need for other plugins too (Appointments+ and Events+ for example). Thanks

  • synergy3c

    Hi Patrick, thanks for your reply. I've scoured the docs and tried several query methods, but none with real success.

    For instance, I can navigate to any url and add '?json=1 and I get the json data of the product page or category.

    However, if I add ?json=1 to the home page url (assuming I'd get all the posts and data from the site), I only get the posts that are actual posts - I don't get the products.

    I wonder if it is because the JSON API does not recognise 'product' as a post_type?

    Also, It does not 'see' any categories at all. Here are some examples:

    <domainname>/blog/?json=1 results in showing only the default blog entry (I have not added any other posts)

    When using the default 'api' as my API base URL:

    <domainname>/blog/api/get_recent_posts/ - gives me only the default blog entry

    <domainname>/blog/api/get_recent_posts&post_type=product - gives me {"status":"error","error":"Uknown method 'get_recent_posts&post_type=product'."}

    <domainname>/blog/api/get_post&id=279 (279 is an ID of a product) - gives me {"status":"error","error":"Uknown method 'get_post&id=279'."}

    Alternatively, <domainname>/blog/api/get_post&post_id=279 - gives me {"status":"error","error":"Uknown method 'get_post&post_id=279'."}

    If I try with the post slug I get similar errors as I do with using the post id

    For categories, I have tried:

    <domainname>/blog/api/get_category_posts&id=12 (12 is an id of a product_category) - gives me {"status":"error","error":"Uknown method 'get_category_posts&id=12'."}

    same issue if I use '&category_id' instead of '&id'

    I've also tried 'product_category' and 'get_category_index' with similar results

    Finally, after seeing in the backend when I look at product categories that the url is constructed as 'taxonomy=product_category&tag_ID=13&post_type=product' I thought that I should try using the tag method, like so:

    <domainname>/blog/api/get_tag_posts&tag_id=13 - this gives me {"status":"error","error":"Uknown method 'get_tag_posts&tag_id=13'."}

    I tried with &id and also tag_slug with same results.

    Its as if JSON API does not recognise the product type.

    I'm thinking this will be a smilar matter with other custom posts types made by Appointments+ and Events+

    So I think that it is necessary to 'register' the custom post type with the JSON API, somehow, so it is parsed by the plug in.

    What are your thoughts? Have you got any advice to make JSON API 'see' these post types?


  • Patrick

    I wish I could help you more, but the sum total of my JSON knowledge is very close to absolute zero. :wink:

    However, I do believe I can scan docs, and it would seem to me that your syntax is a little off. In the following examples taken from the docs page, note the separators used between controllers and methods.

    http://www.example.org/?json=respond.submit_comment (respond controller, submit_comment method)

    Widget-style JSONP output: http://www.example.org/api/get_recent_posts/?callback=show_posts_widget&read_more=More&count=3

    Of particular interest is the 2nd example by which we can infer that your call should be something more like this:


    Hope this helps!