@backblaze-labs/b2-sdk - v0.6.0
    Preparing search index...

    Class RawClient

    Low-level client providing 1:1 bindings to all B2 native API endpoints.

    Each method maps directly to a single B2 API call. Most methods accept (apiUrl, authToken, request) and return the JSON response. Upload and download methods accept endpoint-specific parameters instead.

    Index
    • Parameters

      • applicationKeyId: string

        The application key ID for authentication.

      • applicationKey: string

        The application key secret.

      • realmUrl: string = 'https://api.backblazeb2.com'

        The B2 realm URL to authenticate against.

      • Optionaloptions: RawRequestOptions

        Optional request controls.

      Returns Promise<AuthorizeAccountResponse>

      The authorization response with API URLs and credentials. Direct token access is unchanged; use authorizeAccountResponseForPersistence before trusted serialization.

    • Calls b2_copy_file. This mutation is not automatically replayed after connection failures or HTTP 408/5xx. Check its outcome before retrying manually; expired-token reauth and HTTP 429 retries remain enabled.

      Parameters

      • apiUrl: string

        The B2 API base URL.

      • authToken: string

        The authorization token.

      • request: CopyFileRequest

        The API request parameters.

      • Optionaloptions: RawRequestOptions

        Optional request controls such as an abort signal.

      Returns Promise<FileVersion>

      The copied file version metadata.

    • Calls b2_create_bucket. This mutation is not automatically replayed after connection failures or HTTP 408/5xx. Check its outcome before retrying manually; expired-token reauth and HTTP 429 retries remain enabled.

      Parameters

      • apiUrl: string

        The B2 API base URL.

      • authToken: string

        The authorization token.

      • request: CreateBucketRequest

        The API request parameters.

      Returns Promise<BucketInfo>

      The created bucket metadata.

    • Calls b2_create_key. This mutation is not automatically replayed after connection failures or HTTP 408/5xx. Check its outcome before retrying manually; expired-token reauth and HTTP 429 retries remain enabled.

      Parameters

      • apiUrl: string

        The B2 API base URL.

      • authToken: string

        The authorization token.

      • request: CreateKeyRequest

        The API request parameters.

      Returns Promise<FullApplicationKey>

      The newly created application key with secret.

    • Parameters

      • downloadUrl: string

        The B2 download base URL.

      • authToken: string

        The authorization token.

      • fileId: string

        The unique identifier of the file to download.

      • Optionaloptions: DownloadFileOptions

        Optional download parameters for range requests and cancellation.

      Returns Promise<
          {
              body: ReadableStream<Uint8Array<ArrayBufferLike>>
              | null;
              headers: Headers;
              status: number;
          },
      >

      The response headers, streaming body, and HTTP status code.

    • Parameters

      • downloadUrl: string

        The B2 download base URL.

      • authToken: string

        The authorization token.

      • bucketName: string

        The name of the bucket containing the file.

      • fileName: string

        The name of the file to download.

      • Optionaloptions: DownloadFileOptions

        Optional download parameters for range requests and cancellation.

      Returns Promise<
          {
              body: ReadableStream<Uint8Array<ArrayBufferLike>>
              | null;
              headers: Headers;
              status: number;
          },
      >

      The response headers, streaming body, and HTTP status code.

    • Calls b2_get_upload_part_url with legacy positional request controls.

      Parameters

      • apiUrl: string

        The B2 API base URL.

      • authToken: string

        The authorization token.

      • request: GetUploadPartUrlRequest

        The API request parameters.

      • Optionalsignal: AbortSignal

        Optional abort signal for cancellation.

      • Optionalretry: Partial<RetryOptions>

        Optional per-request retry override.

      Returns Promise<GetUploadPartUrlResponse>

      The upload part URL and authorization token. Diagnostics redact the token; use getUploadPartUrlResponseForPersistence from @backblaze-labs/b2-sdk/raw before trusted serialization.

      Use the options-bag overload: getUploadPartUrl(apiUrl, authToken, request, { signal, retry }).

    • Parameters

      • apiUrl: string

        The B2 API base URL.

      • authToken: string

        The authorization token.

      • request: GetUploadPartUrlRequest

        The API request parameters.

      • Optionaloptions: RawRequestOptions

        Optional request controls such as cancellation and retry overrides.

      Returns Promise<GetUploadPartUrlResponse>

      The upload part URL and authorization token. Diagnostics redact the token; use getUploadPartUrlResponseForPersistence from @backblaze-labs/b2-sdk/raw before trusted serialization.

    • Calls b2_get_upload_url with legacy positional request controls.

      Parameters

      • apiUrl: string

        The B2 API base URL.

      • authToken: string

        The authorization token.

      • request: GetUploadUrlRequest

        The API request parameters.

      • Optionalsignal: AbortSignal

        Optional abort signal for cancellation.

      • Optionalretry: Partial<RetryOptions>

        Optional per-request retry override.

      Returns Promise<GetUploadUrlResponse>

      The upload URL and authorization token. Use getUploadUrlResponseForPersistence before trusted serialization.

      Use the options-bag overload: getUploadUrl(apiUrl, authToken, request, { signal, retry }).

    • Parameters

      • apiUrl: string

        The B2 API base URL.

      • authToken: string

        The authorization token.

      • request: GetUploadUrlRequest

        The API request parameters.

      • Optionaloptions: RawRequestOptions

        Optional request controls such as cancellation and retry overrides.

      Returns Promise<GetUploadUrlResponse>

      The upload URL and authorization token. Use getUploadUrlResponseForPersistence before trusted serialization.

    • Calls b2_hide_file. This mutation is not automatically replayed after connection failures or HTTP 408/5xx. Check its outcome before retrying manually; expired-token reauth and HTTP 429 retries remain enabled.

      Parameters

      • apiUrl: string

        The B2 API base URL.

      • authToken: string

        The authorization token.

      • request: HideFileRequest

        The API request parameters.

      • Optionaloptions: { signal?: AbortSignal }

        Optional request controls such as an abort signal.

      Returns Promise<FileVersion>

      The hidden file version metadata.

    • Calls b2_upload_file.

      Unlike most methods, this posts directly to the uploadUrl obtained from getUploadUrl rather than the API URL.

      Parameters

      • uploadUrl: string

        The upload endpoint URL.

      • headers: UploadFileHeaders

        The request headers including authorization and content metadata.

      • body: BodyInit

        The file data to upload.

      • Optionalsignal: AbortSignal

        Optional legacy abort signal for cancellation.

      • Optionalretry: Partial<RetryOptions>

        Optional legacy per-request retry override.

      Returns Promise<FileVersion>

      The uploaded file version metadata.

      Use the options-bag overload: uploadFile(uploadUrl, headers, body, { signal, retry }).

    • Calls b2_upload_file.

      Unlike most methods, this posts directly to the uploadUrl obtained from getUploadUrl rather than the API URL.

      Parameters

      • uploadUrl: string

        The upload endpoint URL.

      • headers: UploadFileHeaders

        The request headers including authorization and content metadata.

      • body: BodyInit

        The file data to upload.

      • Optionaloptions: RawRequestOptions

        Optional request controls such as cancellation and retry overrides.

      Returns Promise<FileVersion>

      The uploaded file version metadata.

    • Calls b2_upload_part.

      Posts directly to the uploadUrl obtained from getUploadPartUrl rather than the API URL.

      Parameters

      • uploadUrl: string

        The upload endpoint URL.

      • headers: UploadPartHeaders

        The request headers including authorization and content metadata.

      • body: BodyInit

        The file data to upload.

      • Optionalsignal: AbortSignal

        Optional legacy abort signal for cancellation.

      • Optionalretry: Partial<RetryOptions>

        Optional legacy per-request retry override.

      Returns Promise<UploadPartResponse>

      The uploaded part metadata.

      Use the options-bag overload: uploadPart(uploadUrl, headers, body, { signal, retry }).

    • Calls b2_upload_part.

      Posts directly to the uploadUrl obtained from getUploadPartUrl rather than the API URL.

      Parameters

      • uploadUrl: string

        The upload endpoint URL.

      • headers: UploadPartHeaders

        The request headers including authorization and content metadata.

      • body: BodyInit

        The file data to upload.

      • Optionaloptions: RawRequestOptions

        Optional request controls such as cancellation and retry overrides.

      Returns Promise<UploadPartResponse>

      The uploaded part metadata.