October 9th, 2019 23:09

API Questions?

Jaime Zinn
Jaime Zinn Public Seen by 427

Howdy folks! I have a few questions about the Loomio API - if this isn't the right place, please let me know and I'll move it!

I'm a member of another group that uses Loomio to make decisions. Currently our leadership is manually text messaging members reminders to vote on proposals, and I was hoping to use Python, Twilio, and the Loomio API to automate this.

I've taken a look at the API documentation (https://help.loomio.org/en/dev_manual/using_the_api) and the rake routes (https://hackmd.loomio.io/s/HJmuX5IWl#), and see the proposals has a non_voters_count property. Is there any way I can access a list of members that have voted?

As a side note, I've also registered my python script (as described here 'https://github.com/loomio/loomio/pull/2980', 'https://github.com/loomio/loomio-oauth-sample'), but can only communicate with the API when I add my cookies to the pyoauth module.

Thank you!

Rob Guthrie

Rob Guthrie October 10th, 2019 01:13

Hi @Jaime Zinn

Wow, this is quite timely, the idea of text messaging proposal reminders has come up in other places too.

I think this should be a core feature, admins/members should be able to enter their phone numbers into the group members directory, and members may be asked for their number when they join a group.

then you'd be able to send text reminders from the "send notification" screen.

Back to your question:

The Loomio API currently exists to support the main web client. We've actually just taken out the oauth stuff you mention because it was not being used by anyone and it's a security risk and app bloat if it's not being maintained.

However using the client API you can retrieve a list of people who have not voted on a poll via the announcements_controller#audience

end point.

You'd need to make the request passing your session cookie though.

I'm sorry, it's not documented and not setup for building external apps against. We tried that years ago but had no productive interest so we've been prioritising user experience over developer experience since then.

Jaime Zinn

Jaime Zinn October 14th, 2019 04:21

Thanks @Rob Guthrie! This is very helpful to know.

Passing cookies works for now, glad to know I'm using the right method.

It doesn't look like the announcements_controller endpoint is exposed through the web API (https://www.loomio.org/api/v1/), so I may have to dive a bit more into ruby to create a plugin. Definitely link me in to the other conversations if you are able!

Rob Guthrie

Rob Guthrie October 14th, 2019 18:19

Oh, it's exposed, all our functions are available via the client api.


Have you got a development environment setup

here's the output of rails routes, if that helps

Jaime Zinn

Jaime Zinn October 21st, 2019 14:55

I haven't gotten the dev environment setup yet, having trouble with the rake step (FATAL: database "loomio_development" does not exist). I'll give a shot once I have a working dev environment.

Rob Guthrie

Rob Guthrie October 21st, 2019 18:45

createdb loomio_development

should sort that for you

Jaime Zinn

Jaime Zinn October 22nd, 2019 22:03

Thanks Rob! I actually just needed a restart. :thinking: Now the real fun begins...

Hugi Ásgeirsson

Hugi Ásgeirsson October 25th, 2019 09:54

it was not being used by anyone and it's a security risk and app bloat if it's not being maintained.

Ah. I think we are using it though, for our integration with Dreams @robertguthrie. I just think we haven’t noticed it because Dreams is currently disabled. We have a bot that creates threads and posts on about events from the Dreams event log. Do you it is affected by this? @krav our integration between Dreams and Talk uses OAuth to post on behalf of the bot, right?

Rob Guthrie

Rob Guthrie October 25th, 2019 19:22

We can bring it back. The commit is not hard to reverse. We just need to be sure to fix all the warnings it was throwing.

Hugi Ásgeirsson

Hugi Ásgeirsson January 27th, 2020 23:09

Checking in about this. We are about to start Dreams for Borderland 2020. Will this Loomio bot that posts to the API still work?

Rob Guthrie

Rob Guthrie January 27th, 2020 23:12

The oauth stuff stuff is gone.. can you include a cookie with your api requests? If so then you can just include your session cookie with the api requests

Hugi Ásgeirsson

Hugi Ásgeirsson January 27th, 2020 23:28

Hmmm, okay. Not sure how to do that off the bat. If you have any leads for what to do exactly I'd be grateful. Otherwise, we will have a crack at it with the guys who are taking over this weekend.

Rob Guthrie

Rob Guthrie January 27th, 2020 23:41

Now that I'm home, I've read the code, it already uses normal user auth + setting cookies. So I expect it will just work. Happy to help if it does not, but I really expect it will be fine.

Thank goodness!

Hugi Ásgeirsson

Hugi Ásgeirsson January 27th, 2020 23:47

Ah, relief! That's great news. Thank you for your help, yet again. 🤗

Rob Guthrie

Rob Guthrie January 27th, 2020 23:52

It's a pleasure to see Loomio being used and support the users!
Great that removing the other auth stuff was the right move/had no cost, also cool to see an API client in the wild, I'll link to it from Loomio Help