Package: exponea-python-sdk
Exponea Python SDKAn official Python client for Exponea Data APIInstallationpip install exponea-python-sdkUsagefromexponea_python_sdkimportExponeaexponea=Exponea("project_token",username="basic_auth_username",password="basic_auth_password")You can now fully utilize all four API, which are Analyses, Catalog, Customer and Tracking API described bellow.TestsTo run tests, run the following commandpython-mpytestLoggingTo configure logging, use the attributeexponea.loggerwhere a standard logger from Pythonloggingmodule is initalized. For example, to enableDEBUGmessages, you can configureexponea.logger.setLevel("DEBUG")Official documenationFor official Exponea documenation of Data API please seehttps://developers.exponea.com/v2/referenceTable of ContentsCustomer APIget_customerget_customer_consentsget_customer_attributesget_customersget_eventsanonymize_customerAnalyses APIget_reportget_funnelget_segmentationCatalog APIcreate_catalogget_catalog_nameget_catalog_itemsupdate_catalog_itemupdate_catalog_namecreate_catalog_itemdelete_catalog_itemdelete_catalog_itemsdelete_catalogTracking APIget_system_timeupdate_customer_propertiesadd_eventbatch_commandsCatalog APIcreate_catalogexponea.catalog.create_catalog("catalog_name",["field_one","field_two"])ParameterTypeRequiredcatalog_nameStringYesfieldsArray<String>YesIt returns ID of the catalog as a String.d2b69e7s987b0asa0137455f2get_catalog_nameexponea.catalog.get_catalog_name("catalog_id")ParameterTypeRequiredcatalog_idStringYesIt returns name of the catalog as a String.test_catalogget_catalog_itemsexponea.catalog.get_catalog_items("catalog_id",params={})ParameterTypeRequiredcatalog_idStringYesparamsDictionaryNoNote:paramsis a kwargs argument.It returns items of the catalog that match the query and filters specified in params Dictionary. Seeofficial documentationfor what kind of options you can give to params Dictionary.{"matched":2,"limit":20,"skip":0,"data":[{"item_id":"1","properties":{"field_one":"foo","field_two":"baz"}}],"matched_limited":False,"total":2}update_catalog_itemexponea.catalog.update_catalog_item("catalog_id","1",{"field_one":"new_value"})ParameterTypeRequiredcatalog_idStringYesitem_idStringYespropertiesStringYesIt returns Boolean of whether the operation was successful.Trueupdate_catalog_nameexponea.catalog.update_catalog_name("catalog_id","new_name",["fiel_one","field_two","field_three"])ParameterTypeRequiredcatalog_idStringYesnew_nameStringYesfieldsArray<String>YesNote:fieldsmust contain those fields that already exist.It returns Boolean of whether the operation was successful.Truecreate_catalog_itemexponea.catalog.create_catalog_item("catalog_id","item_id",{"field_one":"value_one"})ParameterTypeRequiredcatalog_idStringYesitem_idStringYespropertiesDictionaryYesNote: This operation replaces an already existing item if the IDs match.It returns Boolean of whether the operation was successful.Trueupdate_catalog_itemexponea.catalog.update_catalog_item("catalog_id","item_id",{"field_one":"value_one"})ParameterTypeRequiredcatalog_idStringYesitem_idStringYespropertiesDictionaryYesNote: Updates only those fields that are specified in properties Dictionary.It returns Boolean of whether the operation was successful.Truedelete_catalog_itemexponea.catalog.delete_catalog_item("catalog_id","item_id")ParameterTypeRequiredcatalog_idStringYesitem_idStringYesIt returns Boolean of whether the operation was successful.Truedelete_catalog_itemsexponea.catalog.delete_catalog_items("catalog_id")ParameterTypeRequiredcatalog_idStringYesIt returns Boolean of whether the operation was successful.Truedelete_catalogexponea.catalog.delete_catalog("catalog_id")ParameterTypeRequiredcatalog_idStringYesIt returns Boolean of whether the operation was successful.TrueTracking APIget_system_timeexponea.tracking.get_system_time(batch=False)ParameterTypeRequiredbatchBooleanNoNote: Thebatchkwarg specifies whether command is used in the batch mode. Seebatch_commands methodfor details.It returns a Float.1533663283.8943756update_customer_propertiesexponea.tracking.update_customer_properties({"registered":"test"},{"first_name":"Lukas"},batch=False)ParameterTypeRequiredcustomer_idsDictionaryYespropertiesDictionaryYesbatchBooleanNoNote: The Customer's properties will get updated with the values of the properties Dictionary.Note: Thebatchkwarg specifies whether command is used in the batch mode. Seebatch_commands methodfor details.It returns Boolean describing whether operation was successful or not.Trueadd_eventexponea.tracking.add_event({"registered":"test"},"event_type",properties={"property":"sample_property"},timestamp=1533663283,batch=False)ParameterTypeRequiredcustomer_idsDictionaryYesevent_typeStringYespropertiesDictionaryNotimestampFloatNobatchBooleanNoNote:properties,timestampandbatchparameters are kwargs.Note: Thebatchkwarg specifies whether command is used in the batch mode. Seebatch_commands methodfor details.It returns Boolean describing whether operation was successful or not.Truebatch_commandsexponea.tracking.batch_commands([exponea.tracking.add_event({"registered":"test"},"event_type",properties={"property":"test"},batch=True),exponea.tracking.update_customer_properties({"registered":"test"},{"first_name":"Lukas"},batch=True),exponea.tracking.get_system_time(batch=True)])ParameterTypeRequiredcommandsArray<Dictionary>YesSeeofficial documentationfor the available formats of different types of commands.
It returns an Array of Booleans describing whether each operation was successful or not.[True,True,1533833512.6860783]Customer APIget_customerexponea.customer.get_customer({"registered":"test","cookie":"123"})ParameterTypeRequiredcustomer_idsDictionaryYesNote: The keys of the Dictionary are the names of the ID type, and value is the value for a given customer.It returns a Dictionary.{"events":[{"type":"test","timestamp":1533495544.343536,"properties":{}}],"properties":{"first_name":"Lukas","last_nam":"Cerny"},"ids":{"registered":"test","cookie":"123"}}get_customer_consentsexponea.customer.get_customer_consents({"registered":"test"},["newsletter","other"])ParameterTypeRequiredcustomer_idsDictionaryYesconsent_typesArray<String>YesIt returns a Dictionary.{"newsletter":True,"other":False}get_customer_attributesexponea.customer.get_customer_attributes({"registered":"test"},ids=["cookie","ga"],properties=["first_name"],aggregations=["agg_id"],segmentations=["segm_id"],predictions=["pred_id"],expressions=["expr_id"])ParameterTypeRequiredcustomer_idsDictionaryYesidsArray<String>NopropertiesArray<String>NoaggregationsArray<String>NoexpressionsArray<String>NosegmentationsArray<String>NopredictionsArray<String>NoexpressionsArray<String>NoNote: All the arguments are kwargs and specify the attributes you want to recieve.It returns a Dictionary.{"ids":{"cookie":[],"ga":"sample_id"},"properties":{"first_name":"Lukas"},"aggregations":{"agg_id":"sample_aggregate"},"segmentations":{"segm_id":"sample_segment"},"predictions":{"pred_id":"sample_prediction"},"expressions":{"expr_id":"sample_expression"}}Note: If you do not specify one of the attribute types, it will not have a key in the resulting Dictionary.get_customersexponea.customer.get_customers()ParameterTypeRequiredIt returns an Array.[{"ids":{"cookie":[],"registered":"test"},"properties":{"first_name":"Lukas","last_name":"Cerny"}}]get_eventsexponea.customer.get_events({"registered":"test"},["event_type"])ParameterTypeRequiredcustomer_idsDictionaryYesevent_typesArray<String>YesNote: Elements ofevent_typesArray are names of Events.It returns an Array.[{"properties":{"foo":"baz"},"timestamp":1533495529.9268496,"type":"event_type"}]anonymize_customerexponea.customer.anonymize_customer({"registered":"test"})ParameterTypeRequiredcustomer_idsDictionaryYesIt returns a Boolean if operation was successful or not.TrueAnalyses APIget_reportexponea.analyses.get_report("report_id")ParameterTypeRequiredreport_idStringYesIt returns a Dictionary. The elements indatarepresent individual rows.{"name":"report_name","data":[{"column_name_1":"value_1","column_name_2":1}]}get_funnelexponea.analyses.get_funnel("funnel_id")ParameterTypeRequiredfunnel_idStringYesIt returns a Dictionary. The elements indatarepresent individual drill downs.{"name":"funnel_name","data":[{"serie":"serie_name","step 1 step_one_name count":2,"step 2 step_two_name count":1,"step 2 event_name duration from previous":435764.1615576744}]}get_segmentationexponea.analyses.get_segmentation("segmentation_id")ParameterTypeRequiredsegmentation_idStringYesIt returns a Dictionary. The elements indatarepresent individual segments.{"name":"segmentation_name","data":[{"segment":"segment_name_1","#":0}]}