def get_experiments(experiment_ids=None, user_id=None, client_id=None, bucket_if_necessary=True, user_data=None):
if not client_id:<EOL><INDENT>client_id = os.environ.get('<STR_LIT>')<EOL><DEDENT>if not client_id:<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>if type(experiment_ids) is dict:<EOL><INDENT>experiment_ids = '<STR_LIT:U+002C>'.join(experiment_ids)<EOL><DEDENT>params = {<EOL>'<STR_LIT>': client_id,<EOL>'<STR_LIT>': experiment_ids,<EOL>'<STR_LIT>': user_id,<EOL>'<STR_LIT>': bucket_if_necessary,<EOL>}<EOL>if user_data is None:<EOL><INDENT>user_data = {}<EOL><DEDENT>try:<EOL><INDENT>response = requests.get(BASE_URL, params=dict(params.items() + user_data.items()))<EOL><DEDENT>except requests.ConnectionError:<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>val = response.json()<EOL>if val['<STR_LIT:status>'] != '<STR_LIT>':<EOL><INDENT>raise Exception(val['<STR_LIT:message>'])<EOL><DEDENT>return val['<STR_LIT:value>']<EOL>
Retrieve the experiments the user is a part of
@param experiment_ids : Either a single or list of experiment ids to retreive
@param user_id : An identifier for the user
@param client_id : Bernoulli Client ID - will default to BERNOULLI_CLIENT_ID ENV variable
@param bucket_if_necessary : Choose a variant for the user if one has not been chosen
@param user_data : Dictionary of user information to be used by the segment filters