C#
Create API Key from metacopier.ioβ
You can use two types of API keys:
- Project-level API key: Navigate to Your Projects > (Choose a project) > API Keys (provides access to all accounts in the project)
- Account API key: Automatically generated when an account is created (provides access only to that specific account). Retrieve using the getAccountApiKeys endpoint.
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:
πhttps://api.metacopier.io/rest/api/documentation/v3/api-docsapi.metacopier.ioOption 1: Install with NuGetβ
Execute the following command to install the api package to your project:
dotnet add package MetaCopier.Api --version 1.2.6
You can also visit the package on the offical NuGet site:
πhttps://www.nuget.org/packages/MetaCopier.Api/1.2.6nuget.orghttps://www.nuget.org/packages/MetaCopier.Api/1.2.6
Option 2: Generate package with OpenAPI Generator CLIβ
Install OpenAPI Generator CLIβ
See instructions under generation.md
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 (versions may differ depending on .net 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 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 either of the two pages:
πReadme.ioReadme.io offers a UI similar to Swagger UI for testing the REST API. πSwaggerSwagger UI is a web-based tool that allows developers to interact with and explore RESTful APIs visually. It dynamically generatesβ¦