Skip to content

Latest commit

 

History

History
70 lines (63 loc) · 2.66 KB

File metadata and controls

70 lines (63 loc) · 2.66 KB

Curl implementation

This Curl implementation can be translated to use for every kind of programming language that can do http requests.

Steps:

  1. Authorize with Authorization Code Grant. You'll be redirected to Cryptohopper.com if you are not logged in. Login and try again.
  2. Save the token received in the last step.
  3. Get an access token with Requesting an access token.
  4. Now you can use the access token to do requests.

Authorization Code Grant

Go to and login with Cryptohopper:

https://www.cryptohopper.com/oauth2/authorize?response_type=code&client_id=[CLIENT ID]&state=any&scope=[SCOPE]&redirect_uri=[REDIRECT URI]

Parameters:
response_type (required) value must be: code
client_id (required) can be found in the Cryptohopper app console
state (required) value doesn't matter, we use: any
scope (required) can be found in the Cryptohopper app console (example: read,notifications,manage,trade)
redirect_uri (required) example: http://localhost/

Response:
[REDIRECT URI]?code=[CODE]&state=[STATE]

Example response:

HTTP/1.1 302 Found
Location: http://localhost/?code=123456789&state=any

Requesting an access token

$ curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "grant_type=authorization_code&code=[CODE]&redirect_uri=[REDIRECT URI]&client_id=[CLIENT ID]&client_secret=[CLIENT SECRET]" https://www.cryptohopper.com/oauth2/token

Parameters:
grant_type (required) value must be: authorization_code
code (required) received in the last step
redirect_uri (required) example: http://localhost/
client_id (required) can be found in the Cryptohopper app console
client_secret (required) can be found in the Cryptohopper app console

Example response:

{
"access_token": [ACCESS TOKEN],
"expires_in": 31556952,
"token_type": "Bearer",
"scope": [SCOPE], 
"refresh_token": [REFRESH TOKEN]
}

Using the access token

This is an example for making a request to the Cryptohopper API. The /hopper endpoint can be replaced with other endpoints. To view all of the endpoints go to: https://api.cryptohopper.com/v1.

$ curl -i -H "access-token: [ACCESS TOKEN]" https://api.cryptohopper.com/v1/hopper

Parameters:
access-token (required)