Forum Discussion

hroppanen's avatar
10 years ago

How to get a list of categories that has tkb articles using REST API call?

Hi,

 

I am going to build a list of five latest tkb articles under each board and category. So in the top I would like to have a category name and link, under it would be a board name and link and under that five latest tkb articles. Like this:

 

TKB category name

TKB board name

1. TKB article

2. TKB article

3. TKB article

4. TKB article

5. TKB article

 

TKB board name 2

1. TKB article

2. TKB article

...

 

I can get all categories using REST API call /restapi/vc/categories/ but how would I be able to get ONLY the categories that has TKB articles within?

 

If that is not possible is there some other way I could do it?

  • I think you'll need to get all the categories first, then go through each and ignore any that don't contain knowledge bases.

     

    Alternatively, if the categories never change, you could just hard code them into your component.

    • Do you mean looping through boards inside every category and see if API call

      /restapi/vc/boards/id/board_name@tkb

      success? That could be a way to do it. Although it seems a little inefficient. 

      I wonder why there isn't a call like

      /restapi/vc/categories/style/tkb/

      or

      /restapi/vc/categories@tkb/

      that could do this?

      • OlivierS's avatar
        OlivierS
        Lithium Alumni (Retired)

        hroppanen I wonder if you shouldn't wait a bit until the Rest API v2 is public (hopefuly end of this month). You would be able to run select queries with where clause using LiQL.

        Unfortunately, to begin with, the categorie object won't be available, but I don't think you would have to wait long until it's available in LiQL ...