OpenApiPy
A Python package for interacting with cTrader Open API.
This package uses Twisted and it works asynchronously.
- Free software: MIT
- Documentation: https://spotware.github.io/OpenApiPy/.
Features
-
Works asynchronously by using Twisted
-
Methods return Twisted deferreds
-
It contains the Open API messages files so you don't have to do the compilation
-
Makes handling request responses easy by using Twisted deferreds
Insallation
pip install ctrader-open-api
Usage
from ctrader_open_api import Client, Protobuf, TcpProtocol, Auth, EndPoints
from ctrader_open_api.messages.OpenApiCommonMessages_pb2 import *
from ctrader_open_api.messages.OpenApiCommonMessages_pb2 import *
from ctrader_open_api.messages.OpenApiMessages_pb2 import *
from ctrader_open_api.messages.OpenApiModelMessages_pb2 import *
from twisted.internet import reactor
hostType = input("Host (Live/Demo): ")
host = EndPoints.PROTOBUF_LIVE_HOST if hostType.lower() == "live" else EndPoints.PROTOBUF_DEMO_HOST
client = Client(host, EndPoints.PROTOBUF_PORT, TcpProtocol)
def onError(failure): # Call back for errors
print("Message Error: ", failure)
def connected(client): # Callback for client connection
print("\nConnected")
# Now we send a ProtoOAApplicationAuthReq
request = ProtoOAApplicationAuthReq()
request.clientId = "Your application Client ID"
request.clientSecret = "Your application Client secret"
# Client send method returns a Twisted deferred
deferred = client.send(request)
# You can use the returned Twisted deferred to attach callbacks
# for getting message response or error backs for getting error if something went wrong
# deferred.addCallbacks(onProtoOAApplicationAuthRes, onError)
deferred.addErrback(onError)
def disconnected(client, reason): # Callback for client disconnection
print("\nDisconnected: ", reason)
def onMessageReceived(client, message): # Callback for receiving all messages
print("Message received: \n", Protobuf.extract(message))
# Setting optional client callbacks
client.setConnectedCallback(connected)
client.setDisconnectedCallback(disconnected)
client.setMessageReceivedCallback(onMessageReceived)
# Starting the client service
client.startService()
# Run Twisted reactor
reactor.run()
Please check documentation or samples for a complete example.
Dependencies
Metadata
Release files for ctrader_open_api 0.7.0
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 |
|---|---|---|---|---|
| ctrader_open_api-0.7.0.tar.gz | 25.8 kB | Without provenance | Details for ctrader_open_api-0.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ctrader_open_api-0.7.0-py3-none-any.whl | Python 3 | none | any | Details for ctrader_open_api-0.7.0-py3-none-any.whl |
Total release size: 54.7 kB
Release files / ctrader_open_api-0.7.0.tar.gz
| Download URL | ctrader_open_api-0.7.0.tar.gz |
|---|---|
| Size | 25.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c28af0238d913ee457ad17a7ca173654f9c2ccbb3f86a9ca764db774becc54d0
|
|
BLAKE2b-256 checksum How to use checksums |
900da9869d7a3e20b0a3489956166ae769f11064bfa09568bd01cb71149cfbcb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.12 CPython/3.9.9 Linux/5.11.0-1022-azure
|
Release files / ctrader_open_api-0.7.0-py3-none-any.whl
| Download URL | ctrader_open_api-0.7.0-py3-none-any.whl |
|---|---|
| Size | 28.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
41b26e2922336fa2d0f554a2dc4151f0e6cda2a6b4667abb62bf84d129db374f
|
|
BLAKE2b-256 checksum How to use checksums |
c1ee103149b3555bf10c612018df7bff17701e23a1fa966cab07e49dd4bc5a60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.12 CPython/3.9.9 Linux/5.11.0-1022-azure
|
Security for ctrader_open_api 0.7.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.