> ## Documentation Index
> Fetch the complete documentation index at: https://developers.telnyx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get API Usage

> Returns the detail on API usage on a bucket of a particular time period, group by method category.



## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/storage-data.yml get /storage/buckets/{bucketName}/usage/api
openapi: 3.1.0
info:
  title: Telnyx Storage & Data API
  version: 2.0.0
  description: API for Storage & Data.
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
security:
  - bearerAuth: []
paths:
  /storage/buckets/{bucketName}/usage/api:
    get:
      tags:
        - Bucket Usage
      summary: Get API Usage
      description: >-
        Returns the detail on API usage on a bucket of a particular time period,
        group by method category.
      operationId: GetStorageAPIUsage
      parameters:
        - name: bucketName
          in: path
          description: The name of the bucket
          required: true
          example: ''
          schema:
            type: string
        - name: filter
          in: query
          required: true
          style: deepObject
          explode: true
          description: >-
            Consolidated filter parameter (deepObject style). Originally:
            filter[start_time], filter[end_time]
          schema:
            type: object
            required:
              - start_time
              - end_time
            properties:
              start_time:
                type: string
                format: date-time
                description: >-
                  The start time of the period to filter the usage (ISO
                  microsecond format)
              end_time:
                type: string
                format: date-time
                description: >-
                  The end time of the period to filter the usage (ISO
                  microsecond format)
            additionalProperties: false
          example:
            start_time: '2020-01-01T00:00:00.000Z'
            end_time: '2020-01-01T00:00:00.000Z'
      responses:
        '200':
          description: Bucket Usage
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/BucketAPIUsageResponse'
          headers: {}
        '401':
          description: Unauthorized
        '404':
          description: Bucket not found
        '422':
          description: Unprocessable Entity
      deprecated: false
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Telnyx from 'telnyx';


            const client = new Telnyx({
              apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
            });


            const response = await client.storage.buckets.usage.getAPIUsage('',
            {
              filter: { end_time: '2019-12-27T18:11:19.117Z', start_time: '2019-12-27T18:11:19.117Z' },
            });


            console.log(response.data);
        - lang: Python
          source: |-
            import os
            from datetime import datetime
            from telnyx import Telnyx

            client = Telnyx(
                api_key=os.environ.get("TELNYX_API_KEY"),  # This is the default and can be omitted
            )
            response = client.storage.buckets.usage.get_api_usage(
                bucket_name="",
                filter={
                    "end_time": datetime.fromisoformat("2019-12-27T18:11:19.117"),
                    "start_time": datetime.fromisoformat("2019-12-27T18:11:19.117"),
                },
            )
            print(response.data)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/team-telnyx/telnyx-go\"\n\t\"github.com/team-telnyx/telnyx-go/option\"\n)\n\nfunc main() {\n\tclient := telnyx.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tresponse, err := client.Storage.Buckets.Usage.GetAPIUsage(\n\t\tcontext.TODO(),\n\t\t\"\",\n\t\ttelnyx.StorageBucketUsageGetAPIUsageParams{\n\t\t\tFilter: telnyx.StorageBucketUsageGetAPIUsageParamsFilter{\n\t\t\t\tEndTime:   time.Now(),\n\t\t\t\tStartTime: time.Now(),\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.Data)\n}\n"
        - lang: Java
          source: >-
            package com.telnyx.sdk.example;


            import com.telnyx.sdk.client.TelnyxClient;

            import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;

            import
            com.telnyx.sdk.models.storage.buckets.usage.UsageGetApiUsageParams;

            import
            com.telnyx.sdk.models.storage.buckets.usage.UsageGetApiUsageResponse;

            import java.time.OffsetDateTime;


            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    TelnyxClient client = TelnyxOkHttpClient.fromEnv();

                    UsageGetApiUsageParams params = UsageGetApiUsageParams.builder()
                        .bucketName("")
                        .filter(UsageGetApiUsageParams.Filter.builder()
                            .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                            .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                            .build())
                        .build();
                    UsageGetApiUsageResponse response = client.storage().buckets().usage().getApiUsage(params);
                }
            }
        - lang: Ruby
          source: |-
            require "telnyx"

            telnyx = Telnyx::Client.new(api_key: "My API Key")

            response = telnyx.storage.buckets.usage.get_api_usage(
              "",
              filter: {end_time: "2019-12-27T18:11:19.117Z", start_time: "2019-12-27T18:11:19.117Z"}
            )

            puts(response)
        - lang: PHP
          source: >-
            <?php


            require_once dirname(__DIR__) . '/vendor/autoload.php';


            use Telnyx\Client;

            use Telnyx\Core\Exceptions\APIException;


            $client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API
            Key');


            try {
              $response = $client->storage->buckets->usage->getAPIUsage(
                '',
                filter: [
                  'endTime' => new \DateTimeImmutable('2019-12-27T18:11:19.117Z'),
                  'startTime' => new \DateTimeImmutable('2019-12-27T18:11:19.117Z'),
                ],
              );

              var_dump($response);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx storage:buckets:usage get-api-usage \
              --api-key 'My API Key' \
              --bucket-name '' \
              --filter "{end_time: '2019-12-27T18:11:19.117Z', start_time: '2019-12-27T18:11:19.117Z'}"
components:
  schemas:
    BucketAPIUsageResponse:
      type: object
      properties:
        categories:
          type: array
          items:
            $ref: '#/components/schemas/BucketOps'
        total:
          $ref: '#/components/schemas/BucketOpsTotal'
        timestamp:
          type: string
          format: date-time
          description: The time the usage was recorded
          example: '2020-01-01T00:00:00Z'
    BucketOps:
      type: object
      properties:
        bytes_sent:
          type: integer
          description: The number of bytes sent
          example: 123456
        bytes_received:
          type: integer
          description: The number of bytes received
          example: 123456
        ops:
          type: integer
          description: The number of operations
          example: 123456
        successful_ops:
          type: integer
          description: The number of successful operations
          example: 123456
        category:
          type: string
          enum:
            - list_bucket
            - list_buckets
            - get-bucket_location
            - create_bucket
            - stat_bucket
            - get_bucket_versioning
            - set_bucket_versioning
            - get_obj
            - put_obj
            - delete_obj
          description: The category of the bucket operation
          example: put_obj
    BucketOpsTotal:
      type: object
      properties:
        bytes_sent:
          type: integer
          description: The number of bytes sent
          example: 123456
        bytes_received:
          type: integer
          description: The number of bytes received
          example: 123456
        ops:
          type: integer
          description: The number of operations
          example: 123456
        successful_ops:
          type: integer
          description: The number of successful operations
          example: 123456
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````