Trip Ninja SDK
The Trip Ninja Python SDK is used for interacting with the Trip Ninja API through a easy-to-use library and suite of tools.
Installing
Python 3.10 or higher is required
Linux/MacOS
python3 -m pip install -U tn_sdk
Windows
py -3 -m pip install -U tn_sdk
Quick Example
import json
import tn_sdk
# Client ID and Client Secret can be retrieved from the Admin Panel
tn_client = tn_sdk.TnApi(
client_id="...", # Can be set via TN_SDK_CLIENT_ID env variable
client_secret="...", # Can be set via TN_SDK_CLIENT_SECRET env variable
)
request_data = {
"trip_id": "",
"datasource_responses": {
"4b69b995e699534c1c644381b760c990795efff9": [
{
"pricing_solution_id": "e494c1f1d172380259a61b05990d61cbb68b35a9",
"total_price": 392.22,
"segment_source": "travelport",
"is_private_fare": False,
"refundable": False,
"segments": [
[
{
"departure_time": "2025-11-15T16:40:00.000-04:00",
"departure_timestamp": 1763239200,
"arrival_time": "2025-11-15T17:35:00.000-05:00",
"arrival_timestamp": 1763246100,
"flight_number": "667",
"operating_carrier": "AC",
"transportation_type": "flight",
"fare_type": "PublicFare",
"cabin_class": "E",
"from_iata": "YHZ",
"to_iata": "YUL"
},
{
"departure_time": "2025-11-15T18:20:00.000-05:00",
"departure_timestamp": 1763248800,
"arrival_time": "2025-11-15T20:50:00.000-08:00",
"arrival_timestamp": 1763268600,
"flight_number": "311",
"operating_carrier": "AC",
"transportation_type": "flight",
"fare_type": "PublicFare",
"cabin_class": "E",
"from_iata": "YUL",
"to_iata": "YVR"
}
]
],
"baggage": None
},
],
}
}
request_data_json = json.dumps(request_data)
# JSON encoded string representing the request data
compressed_data = tn_client.prepare_data_for_generate_solutions(request_data_json)
# Compresses the data and returns the compressed_data
Responses
# Compressed Data
eJztlEGL2zAQhe/7K4zPm0WSLdnSrZSWHnoopS20ZTEjW3KcKLaR5C1lyX8vclJnw7pxw9JbBbpI8968EZ/9eBNFURR72/RFU8UiisFVetxbs3HrSm83sDY/tnrjDFQaNmAqp+Pbg64CD64bbKkKq1zftU65WESP4+1YkUrGJedUMc5pkpa4ZGma5FhmDJWco4xTpbXmsYi+T6qwTh6TV2+bsmnrwnVm8E3XHhOrlKcl1rjCGUlyRCgHhiWinKOK4VJKlsuEAj+GPrP0nQdTBGMViyjh5I6QmTKn6p1qfXGYNTT1Fh6U6Tvr52wbFzwfwKtCgw0CDcapmUqr9NBWIM2lomN79+yRfq/50/lnPHOuVA/WD1YVvtmNgxFE6ArjFaafMBMpEgjdIYRWKBUIzcx6wc552PWxiHDGEpJwgtCCHGx4NDObJRMJnbLQv8jy1OwsScrwYhJtmnrti3bYSWVDFMaypYZdryz4AGgZeh90r14vybyF1gWQYGTa/+zH2Q8JlsSBrknyYZCmKd8G4BZkJcimLUoDLjAVv1lsY7td0YCHUP313bfFmbpT9ef38R+L97f/BtxcEHQVLBfATfP8JeASJOgpS/4ScFnOrgc3wfg/uH5C8Qpwv3y8AO7szf2z0/uZv7mEuoY6DN4OxpzdP/kejsr9zf4XgRWmhw==
Unsuccessful Response
InvalidDataException: [INVALID_DATA] Input must be a JSON-encoded string
Development
Setup
From an active virtual env, cd into the directory
pip install -e .
-einstalls it in editable mode. Meaning it will update as you modify the source code without having to re-run the installation command.
Metadata
Release files for tn-sdk 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tn_sdk-0.0.4.tar.gz | 20.6 kB | With provenance | Details for tn_sdk-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tn_sdk-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for tn_sdk-0.0.4-py3-none-any.whl |
Total release size: 43.0 kB
Release files / tn_sdk-0.0.4.tar.gz
| Download URL | tn_sdk-0.0.4.tar.gz |
|---|---|
| Size | 20.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e26e6de6a9e1a6f3e6167eccc5cd149f1133ab860f898b3ec08f1e358b0645f7
|
|
BLAKE2b-256 checksum How to use checksums |
8153bade99a305beab88a830b49949ec6f81bee4c75e94f5e19760648edee858
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logRelease files / tn_sdk-0.0.4-py3-none-any.whl
| Download URL | tn_sdk-0.0.4-py3-none-any.whl |
|---|---|
| Size | 22.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
715a02bbfb393d29c82271cea92cd29fd7944d3325b0fc3c444c66d2e806adb5
|
|
BLAKE2b-256 checksum How to use checksums |
a27d997b18988c3c27fd999182d0f029b2125800c5aaa383c3e26a596483c030
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logSecurity for tn-sdk 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for tn_sdk-0.0.4.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.