Trip Ninja SDK
Project description
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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tn_sdk-0.0.3.tar.gz.
File metadata
- Download URL: tn_sdk-0.0.3.tar.gz
- Upload date:
- Size: 20.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8f45dcf30a53236adf7cf66d2521790449944687d48293376c4e8a3721044e7
|
|
| MD5 |
fe55766b75e2ef28623ed9482ae35b4f
|
|
| BLAKE2b-256 |
c63614575eff1ac0f6af75d0ec4541e2530bfaf0930370fcfba0b6767761a0ce
|
Provenance
The following attestation bundles were made for tn_sdk-0.0.3.tar.gz:
Publisher:
publish.yml on trip-ninja-inc/tn-sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tn_sdk-0.0.3.tar.gz -
Subject digest:
f8f45dcf30a53236adf7cf66d2521790449944687d48293376c4e8a3721044e7 - Sigstore transparency entry: 844844553
- Sigstore integration time:
-
Permalink:
trip-ninja-inc/tn-sdk-python@e0b4f10fea22effdcc87ea1e905c94686f4d38ff -
Branch / Tag:
refs/heads/master - Owner: https://github.com/trip-ninja-inc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e0b4f10fea22effdcc87ea1e905c94686f4d38ff -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file tn_sdk-0.0.3-py3-none-any.whl.
File metadata
- Download URL: tn_sdk-0.0.3-py3-none-any.whl
- Upload date:
- Size: 22.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6deffc5c11d0f03da84e7215796e8a249f0b7a9f768a24c20f476dddf810bb5b
|
|
| MD5 |
4fb110b83d6a3360e6a770041ef9c396
|
|
| BLAKE2b-256 |
a14ac887a2d1437a3b08b86d80ebc3db50559361ea41532787bee33790b714a1
|
Provenance
The following attestation bundles were made for tn_sdk-0.0.3-py3-none-any.whl:
Publisher:
publish.yml on trip-ninja-inc/tn-sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tn_sdk-0.0.3-py3-none-any.whl -
Subject digest:
6deffc5c11d0f03da84e7215796e8a249f0b7a9f768a24c20f476dddf810bb5b - Sigstore transparency entry: 844844554
- Sigstore integration time:
-
Permalink:
trip-ninja-inc/tn-sdk-python@e0b4f10fea22effdcc87ea1e905c94686f4d38ff -
Branch / Tag:
refs/heads/master - Owner: https://github.com/trip-ninja-inc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e0b4f10fea22effdcc87ea1e905c94686f4d38ff -
Trigger Event:
workflow_dispatch
-
Statement type: