Setting up the environment
Getting started
Requirements
Prerequisites
Setting the environment up
4
Last updated
Before you can dive into working with the API, you first need to set up your development environment inside your code editor / IDE of choice.
For this guide, we will use Visual Studio 2022 and C# as the programming language of choice.
Install the NuGet package Struct.App.Api.Client into your project.
Install the NuGet package Struct.App.Api.Models into your project.
Code editor / IDE.
You have generated an API key within your Struct PIM. If not, see how to set it up here.
In your new project, install the Struct.App.Api.Client NuGet package.
Use the terminal command:
dotnet add package Struct.App.Api.Client --version 4.0.7Or go to 'Tools' > 'NuGet Package Manager' > 'Manage NuGet Packages for Solution'. In the NuGet Package Manager, click on 'Browse', search for Struct.App.Api.Client, and install the latest version.

Ensure you select the correct project on the right before installing the package.
To finalize the installation process, you need to install the Struct.App.Api.Models. You can do this by entering the following command in a terminal window within Visual Studio 2022:
dotnet add package Struct.App.Api.Models --version 4.0.7Or by installing it via the Nuget Package manager just like in step 2.

Create a new class called ApiService. Inside this class, create a private field of type StructApiClient. Make the constructor instantiate the field.
using Struct.App.Api.Client;
namespace Struct.App.Api.Demo
{
public class ApiService
{
private StructApiClient _apiClient;
public ApiService()
{
_apiClient = new("your-pim-url-here", "your-api-key-here");
}
}
}You will need to provide the URL to your PIM and the API key you created earlier.
Warning! Your API key should be kept secret. Do not push any of the code you create in this guide to any public version control providers (eg Github, GitLab etc).
Lastly, create an instance of ApiService inside the Main(string[] args) method inside the Program class. You will gain access to invoke methods within the ApiService.
using Struct.App.Api.Client;
namespace Struct.App.Api.Demo
{
public class Program
{
static void Main(string[] args)
{
ApiService service = new ApiService();
// You can now invoke methods inside the ApiService instance.
}
}
}You're now ready to begin experimenting with the API through your ApiService instance. We recommend that you create methods inside the ApiService class which you then invoke through the Main(string[] args) method, inside the Program class.
Last updated