MCPcopy Create free account
hub / github.com/ccxt/ccxt / sign

Method sign

python/ccxt/extended.py:3335–3355  ·  view source on GitHub ↗
(self, path, api: Any = 'public', method='GET', params={}, headers: dict = None, body: Str = None)

Source from the content-addressed store, hash-verified

3333 return None
3334
3335 def sign(self, path, api: Any = 'public', method='GET', params={}, headers: dict = None, body: Str = None):
3336 version = self.safe_string(api, 0)
3337 accessibility = self.safe_string(api, 1)
3338 endpoint = '/' + self.implode_params(path, params)
3339 query = self.omit(params, self.extract_params(path))
3340 queryPost = (path == 'user/deadmanswitch')
3341 url = self.implode_hostname(self.urls['api']['rest'])
3342 if accessibility == 'private':
3343 # self.check_required_credentials()
3344 if self.apiKey is None:
3345 raise AuthenticationError(self.id + ' sign() requires an apiKey for private endpoints')
3346 headers = {
3347 'X-Api-Key': self.apiKey,
3348 }
3349 if ((method == 'POST') or (method == 'PATCH')) and not queryPost:
3350 body = self.json(query)
3351 headers['Content-Type'] = 'application/json'
3352 url = url + '/api/' + version + endpoint
3353 if (method == 'GET' or method == 'DELETE' or queryPost) and query:
3354 url += '?' + self.urlencode_with_array_repeat(query)
3355 return {'url': url, 'method': method, 'body': body, 'headers': headers}

Callers

nothing calls this directly

Calls 8

AuthenticationErrorClass · 0.90
safe_stringMethod · 0.80
implode_paramsMethod · 0.80
extract_paramsMethod · 0.80
implode_hostnameMethod · 0.80
omitMethod · 0.45
jsonMethod · 0.45

Tested by

no test coverage detected