> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pxxl.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Pxxl CDN Go SDK

> Use the Pxxl Go CDN client for typed uploads, downloads, summaries, and asset management.

The Go SDK module is published from the public Pxxl repository:

```bash theme={null}
go get github.com/pxxlspace/pxxlspace/sdks/go/pxxl
```

```go theme={null}
package main

import (
  "context"
  "os"
  "strings"

  "github.com/pxxlspace/pxxlspace/sdks/go/pxxl"
)

func main() {
  client, err := pxxl.NewClient(os.Getenv("PXXL_API_KEY"))
  if err != nil {
    panic(err)
  }
  asset, err := client.UploadAsset(context.Background(), pxxl.UploadAssetInput{
    FileName:   "hello.txt",
    Reader:     strings.NewReader("hello from Pxxl"),
    Visibility: "public",
  })
  if err != nil {
    panic(err)
  }
  println(asset.PublicURL)
}
```

The client uses `net/http`, accepts any `io.Reader` for uploads, and returns typed API errors for non-2xx responses.

## Return Values

The Go SDK unwraps the CDN API envelopes into typed values:

| Method | Returns |
| - | - |
| `Summary` | `*CDNSummary`. |
| `ListAssets` | `[]CDNAsset`. |
| `UploadAsset` | `*CDNAsset`. |
| `DownloadAsset` | `[]byte` containing the file body. |
| `DeleteAsset` | `error`, nil on success. |

`CDNAsset` includes `ID`, `UserID`, `ProjectID`, `DeploymentID`, `StorageName`, `Key`, `FileName`, `ContentType`, `Size`, `PublicURL`, `SHA256`, `ETag`, `Visibility`, `Kind`, `CreatedAt`, and `UpdatedAt`.

## Upload an Image

Open the image file and pass it as the upload reader. Public image uploads return a URL that can be used directly in an `<img>` tag, Open Graph metadata, avatars, or product galleries.

```go theme={null}
package main

import (
  "context"
  "os"

  "github.com/pxxlspace/pxxlspace/sdks/go/pxxl"
)

func main() {
  client, err := pxxl.NewClient(os.Getenv("PXXL_API_KEY"))
  if err != nil {
    panic(err)
  }

  file, err := os.Open("./public/og-image.png")
  if err != nil {
    panic(err)
  }
  defer file.Close()

  image, err := client.UploadAsset(context.Background(), pxxl.UploadAssetInput{
    FileName:   "og-image.png",
    Reader:     file,
    Visibility: "public",
  })
  if err != nil {
    panic(err)
  }

  println(image.PublicURL)
}
```

```html theme={null}
<img src="https://cdn.pxxl.app/..." alt="Product preview" />
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.