2

I'm expecting the answer to this is an unfortunate "no," but I've been unable to find it discussed anywhere, so here I go asking:

I'd love to use this API, but the site I'm considering would need the ability to restrict which users are allowed to answer any given question based on some arbitrary variables in the user profile. Are things customizable to this extent, or is this too far outside the come-one, come-all ethos of StackApps (which I love)?

1 Answer 1

2

No. Well, maybe ;) And an interesting idea, I think I can picture the use cases ...

First let's get one thing straight:

[...] would need the ability to restrict which users are allowed to answer any given question [...]

The API as of version 1.0 is strictly read only (see this answer), so users will never be able to provide an answer on your site, rather they'll have to submit answers on the original Stack Exchange sites and will see all answerers outside of your restricted pool there anyway. So if this is what you had in mind, the answer is definitely no.

Assuming you rather meant which users answers are going to be visible on my mashup site the answer is it depends:

  1. The API in itself doesn't provide advanced query filtering capabilities like you desire, basically you are restricted to querying for entities with specific ids, potentially filtered by a standard set of query parameters that help you shape the result set, like fromdate and todate and possibly some include/exclude flags, see e.g. the following routes:
  2. You should be able to achieve what you desire to some extent yourself though, algorithm:
    • /questions/{id}/answers <= get all answers of a question you are interested in
    • /users/{id} <= get user details for all answerers fetched above
    • filter the user details fetched above according to your criteria
      • this will obviously only work for information exposed in the profile of course, but I assume this is a limitation you already considered
    • display only those users answers

At this point it looks like this might work, but as usual there are quite some edge cases and messy real world problems involved, e.g.:

  • What do you do if the accepted answer is filtered out?
  • What do you do if users are referring to filtered answers from others and/or comments?
  • ... you get the picture.

So it all depends on your particular use case and on how much time you are willing to invest in potentially required workarounds.

Good luck!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .