Skip to main content

Python Software Developement Kit for GTN Fintech API

Project description

Python SDK for GTN Embed

This is a lightweight SDK which wraps the REST APIs of the GTN Embed set as documented in the API Portal

installing packages

The GTN Embed SDK is available on PYPI. Install with pip:

    pip install gtn-embed-sdk

API Authentication

The GTN Embed uses the notion of Institutions, which represent customers that build their platform upon the GTN Embed. The end-users of the institution, are referred to as customers. An institution is able to manage their customers directly and is also able to initiate actions on the user's behalf.

As describe in the API Portal you are required to authenticate first to the Institution and then as a customer. And resulting keys expire in a certain period, which require renewing using authentication APIs. However when using the SDK, key renewing is not required since it is handled by the SDK in background.

The api_url is the API hub where customers are connected to access the GTN Embed. This URL can change depending on customer's registered country.

Initiating API connection

For a connection to be establish, it is required to have following information

  • API URL, provided by GTN. Can vary depending on the environment (Sandbox, UAT, Production)
  • App Key, provided by GTN
  • App Secret, provided by GTN
  • Institution Code, provided by GTN
  • Customer Number of the customer initiating the connection. (Optional: only in the customer mode)
  • Private Key of the institution, provided by GTN
    import gtnapi

    api_data = {
        "api_url": "https://api-mena-uat.globaltradingnetwork.com",
        "app_key": "my-app-key",
        "app_secret": "my-app-secret",
        "institution": "MY-INST-CODE",
        "customer_number": "12345678",
        "private_key": "RTRGDBCNKVGJTURI49857YURIEOLFMKJTU5I4O847YRHFJDKDKVFLKTUEJFHRU"
    }

    status = gtnapi.init(**api_data)

authentication status is in the format

    {
        "http_status": 200, 
        "auth_status": "SUCCESS"
    }

Once the gtnapi.init() is success (i.e. http_code == 200), it is possible to access any REST endpoint (authorised to the customer) by using the SDK

Getting customer details

    response = gtnapi.Requests.get('/trade/bo/v1.2.1/customer/account', customerNumber="12345678")
    print(json.dumps(response, indent=4))

Response is in the format

    {
        "http_status" : 200,  # http status of the api call as per the API documentation
        "response" : {data dict}  # response data of the api as per the API documentation
    }

Getting market data

    search_params = {
        "source-id": 'DFM',
        "keys": "DFM~EMAAR"
    }
    response = gtnapi.Requests.get('/market-data/realtime/keys/data', **search_params)
    print(json.dumps(response, indent=4))

Initiate the market data websocket connection

Can initiate the WS session by passing call-back method references

    gtnapi.Streaming.MarketData.connect(on_open, on_message, on_error, on_close)

close the websocket connection

can close the WS session by calling

    gtnapi.Streaming.MarketData.disconnect()

terminate the session

The while GTN Embed session will be terminated by calling the following

    gtnapi.stop()

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

gtn_embed_sdk-0.0.9.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

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

gtn_embed_sdk-0.0.9-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file gtn_embed_sdk-0.0.9.tar.gz.

File metadata

  • Download URL: gtn_embed_sdk-0.0.9.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for gtn_embed_sdk-0.0.9.tar.gz
Algorithm Hash digest
SHA256 611730a3ad956943637101d6738a58e4370353978b32dd518eadc650961df89f
MD5 b5dd11b26ff5e865a4d418fd51eda124
BLAKE2b-256 f66c6036454396e66501446c3b67fe9b9568dbb42525b0be54a4ee08d732a2e1

See more details on using hashes here.

File details

Details for the file gtn_embed_sdk-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: gtn_embed_sdk-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for gtn_embed_sdk-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 b7a324b4674895ebbdd4c85d5b3544376fc0976475d0b771493f4c160b58ea14
MD5 5783a2129f51d795448a2b061adc48e2
BLAKE2b-256 5e60ef7f90bccd08ffdb01916f5ddcf3e2e519b0af6fd39032493481d8fe2353

See more details on using hashes here.

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