Use Modules From Any Technology
Goal
Use a module from any supported technology directly in a .NET service with Graftcode - no REST wrapper, no rewrite, no custom interop. In this tutorial we use a Python module as the example.
What You'll See
- Install a module from another technology as a strongly-typed Graft using
NuGet- just like any other package. - Configure the generated client to point at the in-memory host.
- Import and call it from your C# code as if it were a native NuGet library.
Prerequisites
- .NET SDK installed locally
- Python installed locally with
python3.dllonPATH— the classic installer or embeddable distribution is preferred. The Microsoft Store /WindowsAppsPython build may not be detected by the Hypertube launcher.
Step 1. Create a project folder
Create a new .NET console application:
dotnet new console -n CurrencyDemo cd CurrencyDemo
Step 2. Install a module from another technology
For this example we'll use a Python currency converter from PyPI (sdncenter-currency-converter), but the same approach works with any module from a supported repository - npm, PyPI, Maven or NuGet.
dotnet add package -s https://grft.dev/ graft.pypi.sdncenter-currency-converter python -m pip install sdncenter-currency-converter --target ./
Hypertube resolves the Python package using the dotted module path as a directory under the current working directory. After pip install --target ./, create a directory junction (Windows) or symlink so currency_converter.converter points at the installed currency_converter folder:
PowerShell:
cmd /c mklink /J currency_converter.converter currency_converter
Bash (macOS / Linux):
ln -s currency_converter currency_converter.converter
On .NET SDK 10+, the Graft NuGet package may inject literal **/*.cs / **/*.resx globs that break dotnet build (CS2001 / MSB3552). If that happens, disable default items and compile only your entry file, for example in the .csproj:
<PropertyGroup> <EnableDefaultCompileItems>false</EnableDefaultCompileItems> <EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems> </PropertyGroup> <ItemGroup> <Compile Include="Program.cs" /> </ItemGroup>
This installs a Graft - a strongly-typed C# client generated from the module. You import and call it like any other NuGet package, regardless of which technology the module was originally written in.
Step 3. Set the SDK key
Set the HYPERTUBE_KEY environment variable in your terminal before running the project:
PowerShell:
$env:HYPERTUBE_KEY="Fe2w-p2GK-Mn26-j8ZY-Xe25"
Bash (macOS / Linux):
export HYPERTUBE_KEY="Fe2w-p2GK-Mn26-j8ZY-Xe25"
Windows CMD:
set HYPERTUBE_KEY=Fe2w-p2GK-Mn26-j8ZY-Xe25
The first successful activation creates a hypertube.lic file. Later runs (and other local projects) can reuse that license. Activating the same key again in a clean environment may return ERROR:Key already used.
Step 4. Call the cross-language module and run it
Replace the contents of Program.cs:
using graft.pypi.sdncenter_currency_converter; using graft.pypi.currency_converter.converter; GraftConfig.Host = "inMemory"; var result = SimpleCurrencyConverter.Convert(100, "USD", "EUR"); Console.WriteLine($"Converted amount: {result}");
Run it:
dotnet run
You should see the converted amount printed in your terminal. SimpleCurrencyConverter.Convert(...) comes from a Python package, but your code reads like a regular method call - no HTTP request, no response parsing, no serialization. GraftConfig.Host = "inMemory" tells Graftcode to load and execute the Python module inside the same process.
Step 5. Run with a Project Key (recommended for real-world usage)
Everything above works without any account - perfect for learning and local development. When you're ready for real-world usage, create a free account at portal.graftcode.com, set up a project, and copy its Project Key.
With a Project Key, point GraftConfig.Host at your project's stable registry URL instead of a raw WebSocket address. A Project Key gives you:
- Stable registry URL - the address for your Grafts stays permanent, so install commands don't change when you redeploy.
- Portal visibility - see all your gateways and services in one place at gateways.graftcode.com.
- Access control - decide who can download your Grafts using package manager authentication and permissions.