Skip to main content

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

tn_client = tn_sdk.TnApi()
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 .

-e installs 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

tn_sdk-0.0.2.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tn_sdk-0.0.2-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file tn_sdk-0.0.2.tar.gz.

File metadata

  • Download URL: tn_sdk-0.0.2.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tn_sdk-0.0.2.tar.gz
Algorithm Hash digest
SHA256 4d5c39b7ce6771691636b3a514e7c70a4aa703103f7752816fbd48e9a1f41a17
MD5 345c6162861cb82e5bf3ec6cbbd60878
BLAKE2b-256 aeefe1ebaaee368f83cf002a8cab60fcc72948825d4bd3cbca218dc4e6ecdd2d

See more details on using hashes here.

Provenance

The following attestation bundles were made for tn_sdk-0.0.2.tar.gz:

Publisher: publish.yml on trip-ninja-inc/tn-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tn_sdk-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: tn_sdk-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tn_sdk-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 38e63209b4ef46558dd70b36eb3dc7996c8f0e1d42ed3cca76505846e0bd98d5
MD5 19c2ac36c49bcb75561a877890fa6b9b
BLAKE2b-256 e0c0a7ff5a8717402fdc5a9904432ea14cd473074660e54dc21613de6dbd4f13

See more details on using hashes here.

Provenance

The following attestation bundles were made for tn_sdk-0.0.2-py3-none-any.whl:

Publisher: publish.yml on trip-ninja-inc/tn-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page