Last active
October 20, 2022 04:47
-
-
Save bgrins/52efd2e47ee11bb42d528bd61263b29d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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