oTree Forum >

Additional REST endpoints

#1 by somas

The REST API otree offers is convenient but somewhat limited.

An example of an endpoint I'm currely lacking is GET / participant_vars (only a POST endpoint is available). I would need it for accessing participant information from another webpage.

Custom admin reports are nice but not enough for some usecases. For example, the experiment I'm developing is an online one, so at the end we generate a receipt we mail to participants. Since otree is not django anymore (it was useful for this kind of things) I developed an external app to handle payments, but without proper API endpoints I cannot retrieve the data I need. 

I can create a MR if needed, but I'm afraid the published code is not updated

#2 by Chris_oTree

Thanks for the suggestions.

What data do you need about participants, in order to generate your receipt? The session data endpoint returns data about all participants in a session such as payoff, participant label, etc.: https://otree.readthedocs.io/en/latest/misc/rest_api.html#get-session-data-endpoint

One reason I haven't implemented GET for participant_vars is that participant vars may not be JSON serializable (can be any python data type). So first I want to understand people's use cases and try to come up with a more tailored solution.

#3 by somas

I need three variables related to payments

>One reason I haven't implemented GET for participant_vars is that participant vars may not be JSON serializable (can be any python data type)

Maybe you can resort to a default value (empty string/error string) when some variable is not serializable (that's easily doable). In most usecases all variables will be, and in anycase the docs can specify that the dev is responsible to make serializable anything that goes in there.

Write a reply

Set forum username