Skip to content

Cloudflare Go

TrendingActive
cloudflare/cloudflare-go

The official Go library for the Cloudflare API — manage DNS records, zones, Workers, R2 and other Cloudflare resources from Go code.

View on GitHub
Stars
2.1k
Forks
779
Watchers
2.1k
Open issues
10

Cloudflare Go is the official Go client library for the Cloudflare API. It provides comprehensive support for all Cloudflare services including DNS, Firewall, Load Balancing, Workers, and more.

Key Features

  • Complete Cloudflare API coverage
  • Type-safe API calls
  • Automatic retries and error handling
  • Support for pagination and concurrent requests
  • Comprehensive documentation and examples

Quick Start

package main

import (
    "context"
    "fmt"
    "log"
    "os"

    "github.com/cloudflare/cloudflare-go"
)

func main() {
    // Create API client
    api, err := cloudflare.New(os.Getenv("CF_API_KEY"), os.Getenv("CF_API_EMAIL"))
    if err != nil {
        log.Fatal(err)
    }

    // Get account information
    ctx := context.Background()
    accounts, err := api.Accounts(ctx)
    if err != nil {
        log.Fatal(err)
    }

    // Print account information
    for _, account := range accounts {
        fmt.Printf("%s: %s\n", account.ID, account.Name)
    }
}

Installation

go get github.com/cloudflare/cloudflare-go

Documentation

For complete API documentation, please refer to the Cloudflare API Documentation.

Contributing

Pull requests and issues are welcome. Before submitting, please ensure:

  1. Code follows Go standard formatting
  2. Necessary tests are added
  3. Documentation is updated accordingly

License

This project is licensed under the Apache License 2.0.

Similar open-source projects, ranked by shared categories and tags.

All SDK projects →