C#

Instructions on how to install and use the MetaCopier API Client package

Install OpenAPI Generator CLI

See instructions under Generation

Create API Key from metacopier.io

To generate yourself an API Key please navigate to metacopier.io > Your Projects > (Choose a project) > API Keys

Note: Please do not share your API Key to people whom you don't trust.

Package Information

Both packages from option 1 or option 2 are based on the following OpenAPI configuration:

Option 1: Install with NuGet

Execute the following command to install the api package to your project:

dotnet add package MetaCopier.Api --version 0.9.1

Option 2: Generate package with OpenAPI Generator CLI

Execute CLI command

Execute the following command to generate the SDK package:

openapi-generator-cli generate -i https://api.metacopier.io/rest/api/documentation/v3/api-docs -g csharp

Change Output Type

Open up generated project file Org.OpenAPITools.csproj and value of output type to the following:

<OutputType>Exe</OutputType>

Install and Update NuGet Packages

First, run the following dotnet CLI command inside the generated project to restore the NuGet packages:

dotnet restore

Then use the following command to list all installed NuGet Packages:

dotnet list package

The following should be listed:

Project 'Org.OpenAPITools' has the following package references
   [net8.0]:
   Top-level Package      Requested   Resolved
   > JsonSubTypes         2.0.1       2.0.1
   > Newtonsoft.Json      13.0.3      13.0.3
   > Polly                8.1.0       8.1.0
   > RestSharp            110.2.0     110.2.0

Project 'Org.OpenAPITools.Test' has the following package references
   [net8.0]:
   Top-level Package                Requested   Resolved
   > Microsoft.NET.Test.Sdk         17.9.0      17.9.0
   > xunit                          2.7.0       2.7.0
   > xunit.runner.visualstudio      2.5.7       2.5.7 

Now navigate into the following directory "src\Org.OpenAPITools" and execute the following commands to install and update the necessary NuGet packages:

dotnet add package JsonSubTypes --version 2.0.1
dotnet add package Newtonsoft.Json --version 13.0.3
dotnet add package RestSharp --version 112.0.0
dotnet add package System.ComponentModel.Annotations --version 5.0.0

After installing and updating the necessary NuGet packages assure your packages have at least the following version:

Project 'Org.OpenAPITools' has the following package references
   [net8.0]:
   Top-level Package                        Requested   Resolved
   > JsonSubTypes                           2.0.1       2.0.1
   > Newtonsoft.Json                        13.0.3      13.0.3
   > Polly                                  8.1.0       8.1.0
   > RestSharp                              112.0.0     112.0.0
   > System.ComponentModel.Annotations      5.0.0       5.0.0

Run the following code

Create a program.cs file and insert the following code, then replace the "YOUR-API-KEY" with your own and run the code:

internal class Program
{
    public static void Main(string[] args)
    {
        Configuration config = new Configuration();
        config.BasePath = "https://api.metacopier.io";

        // Configure API key authorization: ApiKeyAuth
        config.ApiKey.Add("X-API-KEY", "YOUR-API-KEY");
        
        // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
        // config.ApiKeyPrefix.Add("X-API-KEY", "Bearer");

        var apiInstance = new AccountAPIApi(config);

        try
        {
            var accounts = apiInstance.GetAccounts();
            Console.WriteLine(JsonConvert.SerializeObject(accounts));
        }
        catch (ApiException e)
        {
            Debug.Print("Exception when calling AccountAPIApi: " + e.Message);
            Debug.Print("Status Code: " + e.ErrorCode);
        }
    }
}

What endpoints can I call?

To check all available endpoints see REST API

Need more help?

Check the README.md for further information

Last updated