Skip to content

Instantly share code, notes, and snippets.

@bgrins
Last active October 20, 2022 04:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bgrins/52efd2e47ee11bb42d528bd61263b29d to your computer and use it in GitHub Desktop.
Save bgrins/52efd2e47ee11bb42d528bd61263b29d to your computer and use it in GitHub Desktop.
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/cloudflare/cloudflare-go"
"github.com/joho/godotenv"
)
func main() {
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
// Construct a new API object using a global API key
api, err := cloudflare.New(os.Getenv("CLOUDFLARE_API_KEY"), os.Getenv("CLOUDFLARE_API_EMAIL"))
// alternatively, you can use a scoped API token
// api, err := cloudflare.NewWithAPIToken(os.Getenv("CLOUDFLARE_API_TOKEN"))
if err != nil {
log.Fatal(err)
}
// Most API calls require a Context
ctx := context.Background()
// Fetch user details on the account
u, err := api.UserDetails(ctx)
if err != nil {
log.Fatal(err)
}
// Print user details
fmt.Println(u)
out, err := api.IntelligenceDomainDetails(context.Background(), cloudflare.GetDomainDetailsParameters{AccountID: os.Getenv("CLOUDFLARE_ACCOUNT_ID"), Domain: "cloudflare.com"})
fmt.Println(out)
}
import CloudFlare
def main():
account_id = "<>"
email = "<>"
key = "<>"
cf = CloudFlare.CloudFlare(
email,
key
)
print(cf.accounts.intel.domain(account_id, params={'domain':"example.com"}))
print(cf.accounts.intel.domain.bulk(account_id, params={'domain':["wikipedia.com", "mozilla.org"]}))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment