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

# Get screen layout

> Get the current structured screen layout information. This endpoint returns detailed structural information about the UI elements currently displayed on the screen, which can be used for UI automation, element analysis, and accessibility purposes. The format varies by box type: Android boxes return XML format with detailed UI hierarchy information including element bounds, text content, resource IDs, and properties, while other box types may return different structured formats.



## OpenAPI

````yaml get /boxes/{boxId}/actions/screen-layout
openapi: 3.0.0
info:
  title: GBOX Open API
  description: GBOX Open API Documentation
  version: '1.0'
  contact: {}
servers:
  - url: https://gbox.ai/api/v1
    description: Production Server
security: []
tags: []
paths:
  /boxes/{boxId}/actions/screen-layout:
    get:
      tags:
        - UI Action
      summary: Get screen layout
      description: >-
        Get the current structured screen layout information. This endpoint
        returns detailed structural information about the UI elements currently
        displayed on the screen, which can be used for UI automation, element
        analysis, and accessibility purposes. The format varies by box type:
        Android boxes return XML format with detailed UI hierarchy information
        including element bounds, text content, resource IDs, and properties,
        while other box types may return different structured formats.
      operationId: UIActionController_getScreenLayout
      parameters:
        - name: boxId
          required: true
          in: path
          description: Box ID
          schema:
            example: c9bdc193-b54b-4ddb-a035-5ac0c598d32d
            type: string
      responses:
        '200':
          description: Structured screen layout information (XML format for Android boxes)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScreenLayout'
      security:
        - bearer: []
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import GboxSDK from "gbox-sdk";

            const gboxSDK = new GboxSDK({
              apiKey: process.env["GBOX_API_KEY"] // This is the default and can be omitted
            });

            async function main() {
              const box = await gboxSDK.create({ type: "android" });

              // Get screen layout
              const layout = await box.action.screenLayout();

              console.log(layout);
            }

            main();
        - lang: Python
          source: |-
            import os
            from gbox_sdk import GboxSDK

            def main():
                gbox_sdk = GboxSDK(api_key=os.environ["GBOX_API_KEY"])  # This is the default and can be omitted

                # Create Android box
                box = gbox_sdk.create(type="android")

                # Get screen layout
                layout = box.action.screen_layout()

                print(layout)

            if __name__ == "__main__":
                main()
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"log\"\n\t\"os\"\n\n\t\"github.com/gbox/gbox-sdk-go\"\n)\n\nfunc main() {\n\tgboxSDK := gbox.NewGboxSDK(os.Getenv(\"GBOX_API_KEY\")) // This is the default and can be omitted\n\n\t// Create Android box\n\tbox, err := gboxSDK.Create(context.Background(), gbox.CreateRequest{Type: \"android\"})\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to create box: %v\", err)\n\t}\n\n\t// Get screen layout\n\tlayout, err := box.Action.ScreenLayout(context.Background())\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to get screen layout: %v\", err)\n\t}\n\n\tfmt.Println(layout)\n}"
components:
  schemas:
    ScreenLayout:
      type: object
      properties:
        content:
          type: string
          description: |
            Screen layout content.

            Android boxes (XML):
            ```xml
            <?xml version='1.0' encoding='UTF-8' standalone='yes'?>
            <hierarchy rotation="0">
              <node ... />
            </hierarchy>
            ```

            Browser (Linux) boxes (HTML):
            ```html
            <html>
              <head><title>Example</title></head>
              <body>
                <h1>Hello World</h1>
              </body>
            </html>
            ```
          example: |-
            <?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
            <hierarchy rotation="0">
              <node index="0" text="" resource-id="" class="android.widget.FrameLayout" package="com.android.systemui" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,0][1080,2316]" displayed="true">
                <!-- UI elements -->
              </node>
            </hierarchy>
      title: Screen Layout
      description: |
        Screen layout content.

        Android boxes (XML):
        <?xml version='1.0' encoding='UTF-8' standalone='yes'?>
        <hierarchy rotation="0">
          <node ... />
        </hierarchy>

        Browser (Linux) boxes (HTML):
        <html>
          <head><title>Example</title></head>
          <body>
            <h1>Hello World</h1>
          </body>
        </html>
      required:
        - content
  securitySchemes:
    bearer:
      scheme: bearer
      bearerFormat: JWT
      type: http
      description: >-
        Enter your API Key in the format: Bearer <token>. Get it from
        https://gbox.ai

````