MCPcopy Create free account
hub / github.com/sammchardy/python-binance / check_function

Function check_function

code-generator.py:325–368  ·  view source on GitHub ↗

Check if the function is signed based on the endpoint. If not found or deprecated, return None. For GET requests, call the endpoint and check if it returns an error indicating a signature is required.

(method, request_function, cleaned_endpoint, version_arg, params={})

Source from the content-addressed store, hash-verified

323
324
325def check_function(method, request_function, cleaned_endpoint, version_arg, params={}):
326 """
327 Check if the function is signed based on the endpoint. If not found or deprecated, return None.
328 For GET requests, call the endpoint and check if it returns an error indicating a signature is required.
329 """
330 if method != "GET":
331 return True
332 else:
333 try:
334 client = Client("", "")
335 client_function = getattr(client, request_function)
336 version = {"version": version_arg} if version_arg else {}
337 client_function(
338 method.lower(), cleaned_endpoint, signed=False, **version, **params
339 )
340 return False
341 except BinanceAPIException as e:
342 if e.status_code == 400 and "symbol" in e.message:
343 return check_function(
344 method,
345 request_function,
346 cleaned_endpoint,
347 version_arg,
348 {"data": {"symbol": "BTCUSDT"}},
349 )
350 if "signature" in e.message or "API-key" in e.message:
351 return True
352 if (
353 "The endpoint has been out of maintenance" in e.message
354 or "This endpoint has been deprecated, please remove as soon as possible."
355 in e.message
356 or e.status_code == 404
357 ):
358 return None
359 else:
360 print(
361 f"Error calling endpoint {request_function} - {cleaned_endpoint} - {version_arg} - {params}"
362 )
363 return None
364 except Exception as e:
365 print(
366 f"Error calling endpoint {request_function} - {cleaned_endpoint} - {version_arg} - {params}"
367 )
368 return None
369
370
371def generate_function_code(

Callers 1

generate_function_codeFunction · 0.85

Calls 1

ClientClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…