How to get a list of questions from stackoverflow API based on search query?

后端 未结 2 1642
栀梦
栀梦 2021-01-04 22:19

I am interested in the getting a list of the question based on a tag or a search query. I will give you an example.

So If I use the search keyword as \"ipv4\", it sh

2条回答
  •  醉话见心
    2021-01-04 22:58

    You can get this information utilizing the questions/ route. In this call, you will pass the tag(s) you are interested in to the tagged parameter (separated by a semicolon (;)).

    To constrain questions returned to those with a set of tags, use the tagged parameter with a semi-colon delimited list of tags. This is an and constraint, passing tagged=c;java will return only those questions with both tags. As such, passing more than 5 tags will always return zero results.

    For your specific question (searching for ipv4), you can utilize this as a starting point:

    http://api.stackexchange.com/docs/questions#order=desc&sort=activity&tagged=ipv4&filter=!BHMIbze0EPheMk572h0ktETsgnphhU&site=stackoverflow&run=true
    

    The filter is optional, but I've stripped out some of the default fields to present a smaller example. The link above returns entries that look like this:

    "items": [
    {
      "tags": [
        "ruby-on-rails",
        "ipv4",
        "geokit"
      ],
      "link": "http://stackoverflow.com/questions/29460004/rails-geokit-incorrectly-converting-ipv4-address-to-latitude-and-longitude",
      "title": "Rails: Geokit incorrectly converting IPv4 address to latitude and longitude"
    },
    {
      "tags": [
        "networking",
        "ip",
        "ipv4",
        "maxmind",
        "cidr"
      ],
      "link": "http://stackoverflow.com/questions/28358851/merging-of-multiple-ipv4-address-blocks-on-the-basis-of-their-country-region",
      "title": "merging of multiple IPv4 address blocks on the basis of their country region"
    },
    ...
    }
    

提交回复
热议问题