-
# doc sample code
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_email=os.environ.get("CLOUDFLARE_EMAIL"), # This is the default and can be omitted
api_key=os.environ.get("CLOUDFLARE_API_KEY"), # This is the default and can be omitted
)
response = client.kv.namespaces.keys.bulk_update(
namespace_id="0f2ac74b498b48028cb68387c421e279",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
body=[{}],
)
print(response.successful_key_count) I refer doc code to write the following code. import os
import json
from cloudflare import Cloudflare
# read json file as str
with open('config.json', 'r', encoding='utf-8') as file:
data = json.load(file)
json_str = json.dumps(data, ensure_ascii=False)
client = Cloudflare(
api_email=os.environ.get("CLOUDFLARE_EMAIL"),
api_key=os.environ.get("CLOUDFLARE_API_KEY"),
)
response = client.kv.namespaces.keys.bulk_update(
namespace_id=os.environ.get("KV_NAMESPACE_ID"),
account_id=os.environ.get("CF_ACCOUNT_ID"),
body=[{
"key" : "sb",
"values": json_str
}],
)
print(response.successful_key_count) run
the python sdk version import cloudflare
print(cloudflare.__version__)
python3 version.py
4.1.0 Using the wrong version? |
Beta Was this translation helpful? Give feedback.
Answered by
yanghao5
Apr 16, 2025
Replies: 1 comment
-
I figured it out. CF official has not implemented this api. (|||゚д゚) https://github.com/cloudflare/cloudflare-python/blob/main/api.md#keys ![]() |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
yanghao5
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I figured it out.
CF official has not implemented this api.
(|||゚д゚)
https://github.com/cloudflare/cloudflare-python/blob/main/api.md#keys