C#

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

Importing API-Client as NuGet package will be coming soon

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.

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 Program.cs

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

using Newtonsoft.Json;
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client;
using System;
using System.Diagnostics;

namespace Org.OpenAPITools
{
    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