Skip to main content

Python bindings for deriv.com websocket API

Project description

python-deriv-api

A python implementation of deriv api library.

PyPI Python 3.9.6 Test status

Go through api.deriv.com to know simple easy steps on how to register and get access. Use this all-in-one python library to set up and make your app running or you can extend it.

Requirement

Python (3.9.6 or higher is recommended) and pip3

Note: There is bug in 'websockets' package with python 3.9.7, hope that will be fixed in 3.9.8 as mentioned in https://github.com/aaugustin/websockets/issues/1051. Please exclude python 3.9.7.

Installation

python3 -m pip install python_deriv_api

Usage

This is basic deriv-api python library which helps to make websockets connection and deal the API calls (including subscription).

Import the module

from deriv_api import DerivAPI

Access

api = DerivAPI(endpoint='ws://...', app_id=1234);
response = await api.ping({'ping': 1})
print(response) 

Creating a websockets connection and API instantiation

You can either create an instance of websockets and pass it as connection or pass the endpoint and app_id to the constructor to create the connection for you.

If you pass the connection it's up to you to reconnect in case the connection drops (cause API doesn't know how to create the same connection).

  • Pass the arguments needed to create a connection:
   api = DerivAPI(endpoint='ws://...', app_id=1234);
  • create and use a previously opened connection:
   connection = await websockets.connect('ws://...')
   api = DerivAPI(connection=connection)

Documentation

API reference

The complete API reference is hosted here

Examples here

Development

git clone https://github.com/binary-com/python-deriv-api
cd python-deriv-api

Setup environment

make setup

Setup environment and run test

make all

Run test

python setup.py pytest

or

pytest

or

make test

Generate documentations

Generate html version of the docs and publish it to gh-pages

make gh-pages

Build the package

make build

Run examples

set token and run example

export DERIV_TOKEN=xxxTokenxxx
PYTHONPATH=. python3 examples/simple_bot1.py

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

python_deriv_api-0.1.1.tar.gz (39.4 kB view details)

Uploaded Source

Built Distribution

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

python_deriv_api-0.1.1-py3-none-any.whl (40.4 kB view details)

Uploaded Python 3

File details

Details for the file python_deriv_api-0.1.1.tar.gz.

File metadata

  • Download URL: python_deriv_api-0.1.1.tar.gz
  • Upload date:
  • Size: 39.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for python_deriv_api-0.1.1.tar.gz
Algorithm Hash digest
SHA256 553bdac88d3702b207e6253d74d79cc52ebdca87670fb3e7465bdd96bb37975d
MD5 b8c19c668c22319c00ddc12d86ea5a37
BLAKE2b-256 4632f4602b452c53d104f085d0a58334e0fab943c17e7e3e91f7dcc8c71678c9

See more details on using hashes here.

File details

Details for the file python_deriv_api-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for python_deriv_api-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 110848f47cf2a83dd2a6d41eb86619571af726d28a8d6a7b3ae0f5468d462089
MD5 37371f250a72596ecd1d8550e962c0b6
BLAKE2b-256 507ec2855383a12d91a484dec74dec34e4539020994919e18c50974450e8271a

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