This library provides basic functionality for building Python apps that use Heroku AppLink to secure communication and credential sharing with a Salesforce org.
Though the interaction with AppLink is simple and easy to hand code, using the SDK will quickstart your project experience.
Use of this project with Salesforce is subject to the TERMS_OF_USE.md document.
Documentation for the SDK is available and is generated from the source code.
Install the doc dependency group.
$ uv sync --group docs
Generate the documentation.
$ uv run pdoc3 --template-dir templates/python heroku_applink -o docs --force
-
Clone the repository:
git clone https://github.com/heroku/heroku-applink-python.git cd heroku-applink-python
-
Install Dependencies:
Install the
uv
package manager:curl -LsSf https://astral.sh/uv/install.sh | sh
Sync all dependencies:
uv sync --all-extras --dev
-
Install Development Dependencies:
pip install -e ".[dev]"
-
Run the full test suite:
# Run all tests pytest # Run all tests with coverage pytest --cov=heroku_applink.data_api --cov-report=term-missing -v
-
Run a single test:
# Run a specific test file pytest <path_to_test_file>/test_specific_file.py # Run a specific test file with coverage pytest tests/data_api/test_data_api_record.py::test_some_specific_case \ --cov=heroku_applink.data_api
-
Run tests with a specific Python version:
pyenv shell 3.12.2 # Or any installed version uv venv source .venv/bin/activate uv sync --all-extras --dev pytest
-
Run tests across multiple Python versions with Tox:
pip install tox tox-uv tox
-
Run the Ruff linter:
# Check the code for issues ruff check . # Automatically fix issues ruff check . --fix # Check a specific directory (e.g., heroku_applink) ruff check heroku_applink/ # Format the codebase ruff format .
-
Install the package:
pip install heroku_applink
-
Add the middleware to your web framework:
# FastAPI example import asyncio import heroku_applink as sdk from fastapi import FastAPI app = FastAPI() app.add_middleware(sdk.IntegrationAsgiMiddleware) @app.get("/") def get_root(): return {"root": "page"} @app.get("/accounts") def get_accounts(): dataapi = sdk.context.get() asyncio.run(query_accounts(dataapi)) return {"Some": "Accounts"} async def query_accounts(dataapi): query = "SELECT Id, Name FROM Account" result = await dataapi.query(query) for record in result.records: print("===== account record", record)
For more detailed information about the SDK's capabilities, please refer to the full documentation.