The Kyte API Python Library is designed to facilitate communication between a Python client and the Kyte API endpoint. It simplifies the process of authentication, request signing, and making API calls.
You can install the Kyte API Python Library using pip:
pip install kyteTo install on AWS Lambda you will need to use layers. Run the following code and make sure the folder you install the modules is called python:
mkdir python
pip install kyte -t python
zip -r9 kyte_python_layer.zip pythonUpload the zip file to your AWS lambda as a new layer. You can find details on how to add a layer to your lambda function here.
To initialize, import Kyte from the kyte module and call Api(). For application, you can supply an optional kyte_app_id to connect to the application that is hosted on Kyte.
from kyte import Kyte
# Initialize the Kyte API client
client = Kyte.Api(public_key, private_key, kyte_account, kyte_identifier, kyte_endpoint, kyte_app_id)# Creating a session
client.createSession(username, password)# Making a GET request
result = client.get(model, field, value, headers)# Making a POST request
result = client.post(model, data, headers)# Making a PUT request
result = client.put(model, field, value, data, headers)# Making a DELETE request
result = client.delete(model, field, value, headers)model: The specific model for the API endpoint.fieldandvalue: Optional parameters for filtering.data: Payload for POST and PUT requests.headers: Additional headers to be included in the request.
# Example usage
client = api(public_key, private_key, kyte_account, kyte_identifier, kyte_endpoint)
client.createSession(username, password)
result = client.get("example_model", "example_field", "example_value", {'Custom-Header': 'Value'})You can install the package locally by:
pip install .If you have an existing install, you can update the package and depenencies by:
pip install --upgrade .Lastly, to uninstall the package, use the package name
pip uninstall kyteFor all Python projects, it's advisable to offer a source distribution.
PyPI mandates specific metadata that should be included in your setup.py file. To ensure your project meets these requirements, run:
python setup.py checkIf no issues are reported, your package is considered compliant.
To create a source distribution, execute the following command from your root directory:
python setup.py sdistYou have the option to generate a wheel distribution, which is a pre-built distribution tailored for the current platform.
If you don't have the wheel package, you can install it via pip:
pip install wheelThere are various types of wheels available. For a project that's purely Python and compatible with both Python 2 and 3, you can create a universal wheel:
python setup.py bdist_wheel --universalFor projects that aren't Python 2/3 compatible or contain compiled extensions, use the following command:
python setup.py bdist_wheelThe installable wheel will be generated within the dist/ directory, and a separate build directory will contain the compiled code.
Install twine if not already available:
pip install twineBefore making the package available publicly, it is best to test the upload and install using testpypi. To upload to testpypi, run
twine upload --repository-url https://test.pypi.org/legacy/ dist/*You can alternatively specify the source distribution instead of uploading all generated distributions in the dist/ directory.
To test install from testpypi, run:
pip install --index-url https://test.pypi.org/simple/ kyte --userOnce you've completed the test above, you can upload the package to PyPI using:
twine upload dist/*And test the install using:
pip install kyte --userFeel free to contribute to this project by opening issues or submitting pull requests in the GitHub repository.
This project is licensed under the MIT License - see the LICENSE file for details.