Module deriv_api.deriv_api
Classes
class DerivAPI (**options)
-
The minimum functionality provided by DerivAPI, provides direct calls to the API.
api.cache
is available if you want to use the cached dataExamples
- 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)
Parameters
options : dict with following keys connection : websockets.WebSocketClientProtocol A ready to use connection endpoint : String API server to connect to app_id : String Application ID of the API user lang : String Language of the API communication brand : String Brand name middleware : MiddleWares middlewares to call on certain API actions. Now two middlewares are supported: sendWillBeCalled and sendIsCalled
Properties
cache: Cache Temporary cache default to InMemory storage : Cache If specified, uses a more persistent cache (local storage, etc.) events: Observable An Observable object that will send data when events like 'connect', 'send', 'message' happen
Ancestors
Methods
async def subscribe(self, request)
-
Subscribe to a given request
Parameters
request : dict Subscribe request
Example
>>> proposal_subscription = api.subscribe({"proposal_open_contract": 1, "contract_id": 11111111, "subscribe": 1})
Returns
Observable
async def forget(self, subs_id)
-
Forget / unsubscribe the specific subscription.
Parameters
subs_id : str subscription id
Returns
Returns dict
async def forget_all(self, *types)
-
Forget / unsubscribe the subscriptions of given types.
Possible values are: 'ticks', 'candles', 'proposal', 'proposal_open_contract', 'balance', 'transaction'
Parameter
*types : Any number of non-keyword arguments
Example
api.forget_all("ticks", "candles")
Returns
Returns the dict
def expect_response(self, *msg_types)
-
Expect specific message types
Parameters
*msg_types : variable number of non-key string argument Expect these types to be received by the API
Returns
Resolves to a single response or an array
async def clear(self)
-
Disconnect and cancel all the tasks
Inherited members
DerivAPICalls
:account_closure
account_security
account_statistics
active_symbols
affiliate_account_add
api_token
app_delete
app_get
app_list
app_markup_details
app_register
app_update
asset_index
authorize
balance
buy
buy_contract_for_multiple_accounts
cancel
cashier
cashier_payments
cashier_withdrawal_cancel
change_email
change_password
contract_update
contract_update_history
contracts_for
copy_start
copy_stop
copytrading_list
copytrading_statistics
crypto_config
document_upload
economic_calendar
exchange_rates
get_account_status
get_account_types
get_available_accounts_to_transfer
get_financial_assessment
get_limits
get_self_exclusion
get_settings
identity_verification_document_add
landing_company
landing_company_details
link_wallet
login_history
logout
mt5_deposit
mt5_get_settings
mt5_login_list
mt5_new_account
mt5_password_change
mt5_password_check
mt5_password_reset
mt5_withdrawal
new_account_maltainvest
new_account_real
new_account_virtual
new_account_wallet
notification_event
oauth_apps
p2p_advert_create
p2p_advert_info
p2p_advert_list
p2p_advert_update
p2p_advertiser_adverts
p2p_advertiser_create
p2p_advertiser_info
p2p_advertiser_payment_methods
p2p_advertiser_relations
p2p_advertiser_update
p2p_chat_create
p2p_order_cancel
p2p_order_confirm
p2p_order_create
p2p_order_dispute
p2p_order_info
p2p_order_list
p2p_order_review
p2p_payment_methods
p2p_ping
payment_methods
paymentagent_create
paymentagent_details
paymentagent_list
paymentagent_transfer
paymentagent_withdraw
payout_currencies
ping
portfolio
profit_table
proposal
proposal_open_contract
reality_check
request_report
reset_password
residence_list
revoke_oauth_app
sell
sell_contract_for_multiple_accounts
sell_expired
service_token
set_account_currency
set_financial_assessment
set_self_exclusion
set_settings
statement
states_list
ticks
ticks_history
time
tnc_approval
topup_virtual
trading_durations
trading_platform_accounts
trading_platform_deposit
trading_platform_investor_password_change
trading_platform_investor_password_reset
trading_platform_new_account
trading_platform_password_change
trading_platform_password_reset
trading_platform_product_listing
trading_platform_withdrawal
trading_servers
trading_times
transaction
transfer_between_accounts
verify_email
website_status