Generar tu firma

General#

X-ORIONX-SIGNATURE es un header que debe tener un c贸digo HMAC-SHA512.

Generaci贸n#

Para generar la firma debemos juntar nuestro timestamp con el body de nuestra llamada, y generar un c贸digo HMAC-SHA512. Para hacerlo debemos utilizar esta formula, RFC 2104. Te recomiendamos crear una funci贸n donde centralices todas las llamadas a la API.

Para mayor informaci贸n ver HMAC Wikipedia.

Ejemplo de llamada#

timestamp = Date.now()
apiKey = 'your-api-key-code'
body = {
query: `
query getLastPrice($marketCode: ID!) {
market(code: $marketCode) {
lastTrade {
price
}
}
}
`,
variables: {
'marketCode': 'CHACLP'
}
}
body = stringify(body)
signature = HMAC-SHA512('apiSecretKey', timestamp + body)
request = {
method: 'POST',
headers: {
X-ORIONX-TIMESTAMP: timestamp,
X-ORIONX-APIKEY: apiKey,
X-ORIONX-SIGNATURE: signature
}
body: body
}
// Enviar Request
sendRequest(request)

Librer铆as#

Existen distintas librer铆as que te pueden ayudar a generar tu request. Algunas de ellas son:

LenguajeLibrer铆aLink
JavascriptjsSHAhttps://github.com/Caligatio/jsSHA
Python2hmachttps://docs.python.org/2/library/hmac.html
Python3hmachttps://docs.python.org/3/library/hmac.html