Health Status

Check the status and availability of Cosmos server.

Health Status

Welcome to the CosmosPlatform.

As part of the basic set-up of our services, you can test the availability of the API server, as well as the validity of your API key.

This key can be retrieved or created in your API Keys Management dashboard. You can find a detailed step-by-step Quickstart Guide.

Setup Cosmos Python Client

Using Python Cosmos client you can perform the API requests in a convenient way.

In order to install the Python client, you can add it to your project by doing:

poetry add delos-cosmos

Or install it in your virtual environment with:

pip install delos-cosmos

Now you can initialize the client by importing the module and iitializing the module in Python and providing your API key:

from cosmos import CosmosClient

cosmos_client = CosmosClient(apikey=your-cosmos-api-key)

You can now access all Cosmos API services through the client instance. Let's start by checking the validity of your API key and the availability of the client services:

response = cosmos_client.status_health_request()
print(response)

If your request is correct, your key is valid, and the service is available, you will receive a welcome message. Successful requests have a status_code:200. Here is an example of a successful request towards health status service:

{
  "request_id": "4fe65f4c-018f-4eb5-a53c-0d65d2e3edcc",
  "response_id": "ad51c782-e8d3-4f05-81d9-cb3b123b6fff",
  "status_code": 200,
  "status": "ok",
  "message": "Welcome to CosmosPlatform",
  "data": null,
  "error": null,
  "timestamp": "2024-11-19T09:34:36.158868Z"
}

Understanding Errors

When the client is not correctly initialized or the key is not valid, you will receive a 403 Not Authorized error. Let's see an example for this endpoint:

from cosmos import CosmosClient

cosmos_client = CosmosClient(apikey="")
response = cosmos_client.status_health_request()
print(response)

This request is incomplete: the apikey is missing and therefore requests cannot be validated. The server will return an error Field required:

{
  "detail": [
    {
      "type": "missing",
      "loc": ["header", "apikey"],
      "msg": "Field required",
      "input": null
    }
  ]
}

API keys need to be created in the Cosmos Platform Dashboard. They may be activated or deactivated, renamed or regenerated.

In case of performing requests with an invalid API key, the server will return a 403 Unauthorized error. Let's see an example for this endpoint:

from cosmos import CosmosClient

cosmos_client = CosmosClient(apikey="false-api-key")
response = cosmos_client.status_health_request()
print(response)

The response will show that problem. In that case, go to the Cosmos Platform Dashboard and create a new API key or activate an existing one.

{
  "detail": "Invalid API key."
}

Common Errors

Status CodeDescription
403Missing or invalid API key. Ensure your key is provided in the client initialization.
422Incorrect request format. Verify the structure and content of your request. Every endpoint has its required own parameters
500Server error. Contact CosmosPlatform support if the issue persists.

References: