Authentication
Once you have created an API key, you can use it to authenticate requests to the CrowdSec Service API by including it in the x-api-key
header of your HTTP requests.
info
- We're assuming your API key is set in the environment variable
$KEY
- cURL
- Python
curl -i -H "x-api-key: ${KEY}" -X GET -H "Content-Type: application/json" \
https://admin.api.crowdsec.net/v1/info
import os
from crowdsec_service_api import (
Server,
ApiKeyAuth,
Info,
)
KEY = os.getenv('KEY')
auth = ApiKeyAuth(api_key=KEY)
client = Info(base_url=Server.production_server.value, auth=auth)
# Get info about the user
response = client.get_info()
print(response)
answer on success
{
"organization_id": "MY-ORG-ID-abcdef1234",
"subscription_type": "ENTERPRISE",
"api_key_name": "my test api key"
}