0

I want to retrieve top tagged questions per day using the Stack Exchange API.

This API call works for "oracle":

      https://api.stackexchange.com/2.2/tags?inname=oracle&site=stackoverflow

Now I want to pass an array of parameters to this API in a single call.

I want to get the number of questions posted per tag.

Can I pass an array of tags to the API?

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
Srini Sydney
  • 564
  • 8
  • 17
  • An array of *what* parameters, for what purpose? Some API routes allow arrays, some don't. More importantly, forget about "how"; what is the desired end result? – Brock Adams Apr 12 '18 at 17:21
  • I want to ger the number of questions posted per tag. If the parameter is an array the i can pass all the tags in one call..hope its clear – Srini Sydney Apr 12 '18 at 19:11

1 Answers1

1

The question is not clear. Many API routes do allow arrays for inputs where such would make sense and is not too "expensive".

The plain /tags route does not take arrays in its main parameter (inname) because inname performs a wildcard-ish search, and mixing the two would be too "costly", server-side.

But you can send an array of tags to the /tags/{tags}/info route.

For example to get the number of questions for the oracle, mysql, and sql-server tags you could call:

    /2.2/tags/oracle;mysql;sql-server/info?site=stackoverflow&filter=!bNKX0pggz90UuM

which returns:

{
  "count": 514139,
  "name": "mysql"
}, {
  "count": 229607,
  "name": "sql-server"
}, {
  "count": 96037,
  "name": "oracle"
}

Important:

  1. Almost all array parameters to the API are separated by semicolons (;)
  2. Although you should be able to pass up to 100 tags in at a time, there is currently a bug that limits this. To be safe, pass in no more than 45 tags at a time for now.
Brock Adams
  • 90,639
  • 22
  • 233
  • 295
  • I do not understand having a bug on searching more than 45 tags in a call !! May be i am missing something – Srini Sydney Apr 18 '18 at 11:10
  • Elaborate on what's unclear. The API does not function as it should. Until they fix it, [if the `tags` parameter exceeds 909 characters, the API instance will crash instead of responding properly to your request](https://meta.stackexchange.com/questions/309002/the-api-crashes-when-trying-to-retrieve-multiple-tags). To avoid that, I suggested not requesting more the 45 tags at a time. That number is a bit of a SWAG for convenience/ease-of-implementation. It's really the total parameter length that triggers the bug. – Brock Adams Apr 18 '18 at 17:48