Skip to content

Packngo

Welcome to packngo, the Equinix Metalâ„¢ Go API Client. This library is used by the Terraform provider, and the Equinix Metal CLI.

For more information about our API endpoints, please visit our API Documentation.

Installation

packngo can be installed with go get.

go get github.com/packethost/packngo

Authentication

To authenticate to the Equinix Metal API, you must have your API token exported in environment variable PACKET_AUTH_TOKEN.

export PACKET_AUTH_TOKEN=<your_api_token>

Usage Example

This code snippet initializes Equinix Metal API client, and lists your Projects.

package main

import (
    "log"

    "github.com/packethost/packngo"
)

func main() {
    c, err := packngo.NewClient()
    if err != nil {
        log.Fatal(err)
    }

    ps, _, err := c.Projects.List(nil)
    if err != nil {
        log.Fatal(err)
    }
    for _, p := range ps {
        log.Println(p.ID, p.Name)
    }
}

Routes and Methods

A complete list of the available routes and methods is in the packngo GitHub repository.