Skip to main content

Go

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

Option 1: Install with Go modules (pkg.go.dev)​

Execute install command​

Execute the following command to install the SDK package:

go get github.com/metacopier/go-package@v1.2.9

You can also visit the package on the official pkg.go.dev site:

πŸ”—https://pkg.go.dev/github.com/metacopier/go-packagepkg.go.dev

Options 2: Install with 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 go -o ./ --additional-properties packageName=metacopier,packageVersion=1.2.9,isGoSubmodule=false,withGoMod=true,structPrefix=false,useDefaultValuesForRequiredVars=false,disallowAdditionalPropertiesIfNotPresent=false

Example​

In the following Go program I will use the metacopier package to fetch all accounts of my MetaCopier project.

package main

import (
"context"
"fmt"
"log"

metacopier "github.com/metacopier/go-package"
)

func main() {
// Api Key from metacopier.io
apiKey := "YOUR_API_KEY"

// Create a new configuration
cfg := metacopier.NewConfiguration()
cfg.Host = "api.metacopier.io"
cfg.Scheme = "https"

// Set API key for authorization
cfg.AddDefaultHeader("X-API-Key", apiKey)

// Create API client
client := metacopier.NewAPIClient(cfg)

// Create an instance of the account API
ctx := context.Background()

// Send request to fetch accounts
accounts, resp, err := client.AccountAPIApi.GetAccounts(ctx).Execute()
if err != nil {
log.Fatalf("Exception when calling AccountAPIApi->GetAccounts: %v\n", err)
}

// Print response
fmt.Printf("Accounts: %+v\n", accounts)
fmt.Printf("Status Code: %d\n", resp.StatusCode)
}

Generate your own package​

With the following command, you can generate your own package for the metacopier api:

info

Be sure that you have installed the OpenAPI Generator.
See generation.md page for more information.

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

For more information regarding the Open API generator, please visit their offical page:

πŸ”—https://openapi-generator.tech/openapi-generator.tech

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…