User Story: “As an enterprise API user, I want to download snapshot chunks”
I'm trying to download snapshot chunks using the Python SDK.
filters = [ Filter(field="is_part_of.identifier", value="enwiktionary") ] req = Request(filters=filters) snapshots = api_client.get_snapshots(req) # server-side NS filtering doesn't work, see T393198 mainspace = [s for s in snapshots if s['namespace']['identifier'] == 0] for snapshot in mainspace: snapshot_identifier = snapshot['identifier'] for chunk in snapshot['chunks']: with open(f"{chunk}", "wb") as f: print(f"downloading {chunk}") api_client.download_chunk(snapshot_identifier, chunk, f)
This returns an error:
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://api.enterprise.wikimedia.com/v2/snapshots/enwiktionary_namespace_0/chunks/enwiktionary_namespace_0_chunk_0/download
It happens on the first HEAD request issued by the SDK.
Running this from curl gives the same result:
$ curl -I -H @header -X HEAD https://api.enterprise.wikimedia.com/v2/snapshots/enwiktionary_namespace_0/chunks/enwiktionary_namespace_0_chunk_0/download HTTP/2 403 date: Fri, 02 May 2025 17:21:49 GMT content-type: application/json content-length: 37 x-request-id: 0298630d-31be-48cd-b8b3-3003a6d02207 x-envoy-upstream-service-time: 2 server: istio-envoy