-
Notifications
You must be signed in to change notification settings - Fork 12
Using Type4Py Rest API
Amir M. Mir edited this page Feb 19, 2022
·
4 revisions
Type4Py's Rest API provides a predict
endpoint, which accepts a Python source file via a POST
request.
A minimal example is given below in Python.
import requests
# Replace `example.py` with your desired Python source file.
with open('example.py') as f:
r = requests.post("https://type4py.com/api/predict?tc=0", f.read())
print(r.json())
The response contains type information in JSON format. See here for the description of the response format. For other programming languages, it should be possible to write a similar code like the above example.
Note 1: The sent Python file should have valid syntax.
Note 2: Above example uses
type4py.com
, our public API. Uselocalhost:5001
instead oftype4py.com
if Type4Py's Docker image is running.