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?

2
  • 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? Commented Apr 12, 2018 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 Commented Apr 12, 2018 at 19:11

1 Answer 1

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.
Sign up to request clarification or add additional context in comments.

2 Comments

I do not understand having a bug on searching more than 45 tags in a call !! May be i am missing something
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. 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.