Skip to main content

Authentication

To access the Bitpulse API, you must include an API Key in the request header. The API uses a custom header for authentication, ensuring secure and controlled access to all endpoints.

Request Headers

Header NameDescriptionRequiredExample Value
Content-TypeSpecifies the media type of the request body.Yesapplication/json
x-api-keyContains the API Key required for authentication.Yes<your_api_key>

Authentication Example

Here's an example of how to authenticate with the API using Python:

import requests
import json

uri = "https://api.bitpulse.io"
endpoint = "/loan_risk"

# Request payload
rq = {
'type': 'GBM',
'params': {
'collateral_weights': {'PEPE': 1.0},
'loan_weights': {'USDC': 1.0},
'volatility_shock': 2.0,
'N': 1.5,
'M': 1.4,
'L': 1.3,
'R': 1.35,
'model_lookback': 90.0,
'loan_duration': 30.0,
'mc_top_up': 24.0,
'loan_value': 1000,
'mc_iter': 1000
}
}

# Make the API request with authentication
response = requests.post(
uri + endpoint,
data = json.dumps(rq),
headers = {
"Content-type": "application/json",
"x-api-key": "<your_api_key>",
}
)

print(response.text)

Obtaining an API Key

To obtain an API key for the Risk API:

  1. Visit our Access Permissions page to fill out the access request form
  2. Specify that you need access to the Risk API in your request
  3. Our team will review your request and provide you with an API key via email

API Key Security

To ensure the security of your API key:

  • Never share your API key in public repositories or client-side code
  • Store your API key securely using environment variables or a secure vault
  • Rotate your API key periodically
  • Use different API keys for development and production environments

Error Responses

If authentication fails, you'll receive a 401 Unauthorized response. Make sure your API key is valid and correctly included in the request header.