Production is the most frequently updated data category. The database accept daily production data and hourly production data as long as the date follows the format YYYY-MM-DD hh:mm.
fromtypingimportOptional,DictimportosimportrequestsACCESS_TOKEN=os.environ["WHITSON_API_TOKEN"]CLIENT_NAME=os.environ["CLIENT_NAME"]defget_well(project_id:Optional[int]=None,name:Optional[str]=None,uwi_api:Optional[str]=None,):""" Get a list of wells. """base_url=f"http://{CLIENT_NAME}.whitson.com/api-external/v1/wells"response=requests.get(base_url,headers={"content-type":"application/json","Authorization":f"Bearer {ACCESS_TOKEN}",},params={"project_id":project_id,"name":name,"uwi_api":uwi_api},)res=response.json()ifnotres:raiseException("no existing wells")returnresdefupload_production_to_well(well_id:int,payload:Dict[str,list]):""" Upload production to well. """response=requests.post(f"http://{CLIENT_NAME}.whitson.com/api-external/v1/wells/{well_id}/production_data",headers={"content-type":"application/json","Authorization":f"Bearer {ACCESS_TOKEN}",},json=payload,)ifresponse.status_code>=200andresponse.status_code<300:print(f"success on well_id {well_id}")else:print(response.text)if__name__=="__main__":well_json=get_well(project_id=1,name="SPE-DATA-REPOSITORY-DATASET-1-WELL-1-OSPREY")[0]well_id=well_json["id"]well_name=well_json["name"]print("uploading production to well: ",well_id,", well name",well_name)payload={"production_data":[{"date":"2015-01-01 00:00","p_wf_measured":5050,"p_casing":2065,"p_tubing":15,"qg_sc":145.0,"qw_sc":718,"qo_sc":504.39,},{"date":"2015-01-02 00:00","p_wf_measured":5010,"p_casing":1990,"p_tubing":15,"qg_sc":186.0,"qw_sc":922,"qo_sc":564.76,},]}upload_production_to_well(well_id,payload)