API endpoint for voting

That would open the vote feature to mobile user, external app’, …

The API seems to lack a “votes” definition
The Poll::vote and add_anonymous_votes function is already there, but lack a controller but since votes are a plugin, the issue may have to be that plugins get the ability open API endpoints

Everything in Discourse has API support:

Vote:

curl 'https://meta.discourse.org/voting/vote' -X POST --data 'topic_id=51247'

Unvote:

curl 'https://meta.discourse.org/voting/unvote' -X POST --data 'topic_id=51247'
4 Likes

how, thanks! (I couldn’t find it inside http://docs.discourse.org/ [which does not work with FF btw])
How does is apply/not apply to anonymous users?
Will that call require user’s token if anonymous voting is not allowed?

Vote is a plugin, docs are only for core.

OMG, just saw this now. You created a post on the #plugin:voting category and are asking questions linking the poll plugin code. My last reply was about the #plugin:voting plugin, please elucidate me.

I’m able to load http://docs.discourse.org in firefox 54.0 on Windows just fine and I know it worked on earlier versions too. Is it really not working for you in firefox?

The controller is inside of plugin.rb here:

https://github.com/discourse/discourse/blob/master/plugins/poll/plugin.rb#L181

And the routes for it are here:

https://github.com/discourse/discourse/blob/master/plugins/poll/plugin.rb#L272

If anonymous voting is not allowed it should require a users token.

I’m thinking about adding the api endpoints for plugins as well to the api docs. I can just create a tag in the docs for each plugin that is added.

I’ll work on adding the poll endpoints to the docs. In the meantime though you can just open up the chrome inspector and go the networks xhr tab and view the requests as you make them.

3 Likes