Skip to main content

Python Software Developement Kit for GTN Fintech API

Project description

Python SDK for GTN API

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

installing packages

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

    pip install gtnapi

API Authentication

The GTN API uses the notion of Institutions, which represent customers that build their platform upon the GTN API. 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 API. 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 GT API 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.8.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.8-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gtn_embed_sdk-0.0.8.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.8.tar.gz
Algorithm Hash digest
SHA256 89c528aab72a0368addf67ea0b08594b4ab6d1eacb9af7c0956d257b5506214d
MD5 a0731ef7a5ab0d59f65af04af38dad48
BLAKE2b-256 2f9c1a003490916259d6f1d5f483ec23e00c2954e56ceb5526510c9cc315c500

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gtn_embed_sdk-0.0.8-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.8-py3-none-any.whl
Algorithm Hash digest
SHA256 9fac633b481e0bee8310e99dec0864b9acaf78fe4cff6ade0b5dd64205fb8577
MD5 b56c748ac7ce00ed6177cad911b78c38
BLAKE2b-256 0ff9b74b98de8a21026f0c80b7c491a24ff24ccef67ca5ad9b9cc50985be0fb3

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