Cryfi API

Cryfi API allows any trading automation strategy to share signals automatically. If you want to connect your trading bot to Cryfi you need to: 1) If you channel/group is paid - Create a private Channel, if free - Create a public channel

2) Add @CryfiBot to the channel (you can press « start » —> « I’m a signal provider » on @CryfiBot and it will guide you through this step or check our step-by-step guide)

3) If your channel is paid - You should setup your subscription price, wallet address & free trial period on the app (/app command on @CryfiBot)

4) Then we’ll need to properly identify you in the backend so we’ll need to know the quoted data given by the /init_data command on @CryfiBot

5) Integrate our API:

import requests

def assert_response_success(response, url):
	if response.status_code != 200:
		print(f"[-] An error occurred while reaching {url}")
		print(response)
		print(response.text)
		exit()

"""
Returns the list of pairs listed on Cryfi
These are all the binance future pairs

Response format:
[{
	'symbol': 'BTCUSDT',
	'base_asset': 'BTC',
	'quote_asset': 'USDT',
	'leverages': [125, 100, 50, 20, 10, 5, 4, 3, 2, 1] # The maximum of this list is the maximum allowed leverage
}]
"""
def get_pairs():
	url = "https://api.cryfi.app/api/pairs/getPairs"
	response = requests.get(url)
	assert_response_success(response, url)
	return response.json()

pairs = get_pairs()
print(f"[+] {len(pairs)} pairs available")

def create_signal(pair_symbol, leverage, portfolio_size, sl, sl_size, entries, entries_size, targets, targets_size, description, screenshot = None):
	# The length of the positions should equal the length of the sizes
	assert len(sl) == len(sl_size) and len(entries) == len(entries_size) and len(targets) == len(targets_size)
	# The sizes should add up to 100%
	assert sum(sl_size) == 100 and sum(entries_size) == 100 and sum(targets_size) == 100
	# The pair_symbol should be in the result of get_pairs()
	pair = next((pair for pair in pairs if pair["symbol"] == pair_symbol), None)
	assert pair
	# The leverage should not be more than the maximum allowed
	assert leverage <= max(pair["leverages"])

	json_data = {
		# To get your init_data send the /init_data command to the Cryfi Telegram Bot (https://t.me/CryfiBot)
		"init_data": "<your init_data goes here>",
		"signal": {
			"pair": pair_symbol,
			"leverage": leverage,
			"portfolio_size": portfolio_size,
			"sl": sl,
			"sl_size": sl_size,
			"entries": entries,
			"entries_size": entries_size,
			"targets": targets,
			"targets_size": targets_size,
			"description": description,
			"screenshot": screenshot,
		},
	}
	url = "https://telegram.cryfi.app/create-signal"
	response = requests.post(url, json=json_data)
	assert_response_success(response, url)
	print(f"[+] {response.json()['message']}")


pair_symbol = "ETHUSDT"
leverage = 5
portfolio_size = 10 # Optional position size of portfolio (here 10 is 10%). If not specified, default value is 100%
sl = [3050] # Prices of the stop losses
sl_size = [100] # Position size of each stop loss in %
entries = [3100, 3150] # Prices of the entries
entries_size = [50, 50] # Position size of each entry in %
targets = [3200, 3250] # Prices of the targets
targets_size = [35, 65] # Position size of each targets in %
description = "This signal makes sense because..." # Optional signal description
screenshot = "https://www.tradingview.com/x/9ql06UmW/" # Optional image URL

create_signal(pair_symbol, leverage, portfolio_size, sl, sl_size, entries, entries_size, targets, targets_size, description, screenshot)

6) If you have any troubles with the integration or want to ask questions feel free to tag the Admin in the Cryfi Chat or write in the chat about your desire to integrate Cryfi API. Our team members will contact you shortly.

Last updated