Execute microservice endpoint using HTTP REST
Project description
4logik python rest client
Utility package to call an enpoint generated by 4Logik
Installation
Use pip
pip install 4logik-python-rest-client
How to call a CSV endpoint
- Locate the input CSV file
- Identify the URL of the enpoint
- Identify the name of the data set of the response that contains the results
Example of using the package:
from py4logik_python_rest_client.endpoint_caller import call_csv_endpoint
# input parameters
input_csv_file = "/home/user1/incomingData.csv"
endpoint_url = "http://localhost:8080/RiskCalulationProcess"
dataset_name = "riskResult"
# call the endpoint
received_json_data = call_csv_endpoint(ms_url, input_csv_file, dataset_name)
print(received_json_data)
Example of using the package inside Jupyter and converting the result to a data frame:
import json
import pandas as pd
import tempfile
from py4logik_python_rest_client.endpoint_caller import call_csv_endpoint
# input parameters
input_csv_file = "/home/user1/incomingData.csv"
endpoint_url = "http://localhost:8080/RiskCalulationProcess"
dataset_name = "riskResult"
# call the endpoint
received_json_data = call_csv_endpoint(ms_url, input_csv_file, dataset_name)
# now convert the received json to panda
temp_file = tempfile.NamedTemporaryFile(delete=False)
output_json = temp_file.name
with open(output_json,'w', encoding='UTF_8') as f:
f.write(json.dumps(received_json_data))
f.close()
final_data_frame = pd.read_json(output_json)
final_data_frame
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for 4logik-python-rest-client-1.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2bee19f6efefff836eae42e419e8d60deff209492f263f627fb0a1d003d968d |
|
MD5 | 7982f187859d88d0a782aef16e9e9985 |
|
BLAKE2b-256 | d9392eef32d04eb115a530589cafa91d4d1939e9e4176eabf42e3bcc0f126dae |