API Key¶
How to get an API Key¶
A SimScale API Key is tied to a platform account. In order to generate one for your account, please follow these steps:
Sign in to the SimScale platform in www.simscale.com
Open the account menu by hovering over your user name at the top right
Go to ‘Manage Account’ or ‘User Preferences’ on the menu, depending on wether you are in the SimScale Workbench or the website.
Open the ‘API Keys’ tab
Use the ‘Generate Key’ button
Enter a description for this new key
Copy the key to a safe location, for instance to your
.env
file
If doing so, your .env
file should contain a line such as:
SIMSCALE_API_KEY="your_api_key"
API Client¶
User authentication in the SimScale API is performed using the X-API-KEY
request header.
In your code, you must first initialize and configure a simscale_sdk.ApiClient
object, which
holds the data for the host, identification header and API Key. This object is later used to
setup the different Api clients specific to each platform action.
The following snippet shows an example of the creation and setup of the ApiClient
object:
# Python
import os
import simscale_sdk as sim
API_KEY = "your_api_key"
API_HOST_URL = "https://api.simscale.com/v0"
configuration = sim.Configuration()
configuration.host = API_HOST_URL
configuration.api_key = {
"X-API-KEY": API_KEY
}
api_client = sim.ApiClient(configuration)
// C#
using System;
using SimScale.Sdk.Api;
using SimScale.Sdk.Client;
using SimScale.Sdk.Model;
var API_KEY = "your_api_key"
var API_HOST_URL = "https://api.simscale.com/v0"
Configuration configuration = new Configuration();
configuration.BasePath = API_HOST_URL
configuration.ApiKey.Add("X-API-KEY", API_KEY)