how to get json responses for all the tags used by stackexchange API

122 Views Asked by At

https://stackoverflow.com/tags/synonyms?page=1&tab=newest&filter=allgetbootstrap.com

This is returning me html page, so how can I convert the tags into json array which can be populated into my autocomplete search box.

https://i.stack.imgur.com/j9Wvy.jpg "tags_image_return_html"

1

There are 1 best solutions below

0
On

Have you tried looking at the Stack Overflow APIs. There is an endpoint that provides a JSON formatted response, check out the tags API here: https://api.stackexchange.com/docs/tags#order=desc&sort=popular&filter=default&site=stackoverflow&run=true

It is discouraged to scrape HTML from a page as you cannot guarantee the formatting of the page will stay constant, it also means you would need to do much more processing to get the data you're after.

Also by using a JSON resource you can use libraries such as Select2 to make your life a lot easier.