# Setting up the environment

### Getting started

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.

### Requirements

* 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.

### Prerequisites

* You have generated an API key within your Struct PIM. If not, [see how to set it up here](/tutorials/guides/how-to-use-struct-pims-api/how-to-set-up-and-edit-api-configurations.md).

***

### Setting the environment up

{% stepper %}
{% step %}

### Create console application

<figure><img src="/files/1IXaS2fX7tGbmGgJBZop" alt=""><figcaption></figcaption></figure>

Open Visual Studio 2022, and click 'Create a new project'. Search for Console, and select the Console app project with C# as the main programming language.
{% endstep %}

{% step %}

### Install client nuget package

In your new project, install the `Struct.App.Api.Client` NuGet package.

Use the terminal command:

```csharp
dotnet add package Struct.App.Api.Client --version 4.0.7
```

Or 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.

<figure><img src="/files/7FG1SIzcIqQ5B2o0R7Pt" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Ensure you select the correct project on the right before installing the package.
{% endhint %}
{% endstep %}

{% step %}

### Install model nuget 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:

```csharp
dotnet add package Struct.App.Api.Models --version 4.0.7
```

Or by installing it via the Nuget Package manager just like in step 2.

<figure><img src="/files/fGnFdnXZcO0hBmmyAqQG" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Create a class that contain the StructApiClient field

Create a new class called `ApiService`. Inside this class, create a private field of type `StructApiClient`. Make the constructor instantiate the field.

```csharp
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.

{% hint style="danger" %} <mark style="color:$warning;">**Warning!**</mark> <mark style="color:$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).</mark>
{% endhint %}
{% endstep %}

{% step %}

### Create instance of ApiService inside Program.cs

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`.

{% code overflow="wrap" %}

```csharp
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.
        }
    }
}
```

{% endcode %}
{% endstep %}
{% endstepper %}

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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.struct.com/tutorials/guides/how-to-use-struct-pims-api/setting-up-the-environment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
