# I think I'm missing a basic concept of this api. How to get the items out of this call?

**URL:** <https://developer.squareup.com/forums/t/i-think-im-missing-a-basic-concept-of-this-api-how-to-get-the-items-out-of-this-call/21443>\
**Category:** Questions\
**Tags:** catalog-api\
**Created:** [March 15, 2025, 11:18pm UTC](https://developer.squareup.com/forums/t/i-think-im-missing-a-basic-concept-of-this-api-how-to-get-the-items-out-of-this-call/21443 "2025-03-15T23:18:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DGD](https://avatars.discourse-cdn.com/v4/letter/d/f04885/32.png) [@DGD](https://developer.squareup.com/forums/u/DGD)\
**Post date:** [March 15, 2025, 11:18pm UTC](https://developer.squareup.com/forums/t/i-think-im-missing-a-basic-concept-of-this-api-how-to-get-the-items-out-of-this-call/21443/1 "2025-03-15T23:18:15Z")

</div>

I’m trying to get the catalog objects out of these calls.

I’ve tried things like `$response->getItems()` and `$response->getObjects()` which don’t work because those methods don’t exist in this version. So, how do I get the goods from the response?

```auto
            $response = $this->client->catalog->list(
                new ListCatalogRequest([
                    'types' => 'CATEGORY',
                ]),
            );
            $response2 = $this->client->catalog->list(
                new ListCatalogRequest([]),
            );

```

---

<div class="post-metadata">

**Author:** ![Square-Dev-AI](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/square-dev-ai/32/2513_2.png) [@Square-Dev-AI](https://developer.squareup.com/forums/u/Square-Dev-AI)\
**Post date:** [March 15, 2025, 11:18pm UTC](https://developer.squareup.com/forums/t/i-think-im-missing-a-basic-concept-of-this-api-how-to-get-the-items-out-of-this-call/21443/2 "2025-03-15T23:18:29Z")

</div>

👋 I’m Square Dev AI, here to help answer your question!  
Based on the information you’ve provided, the following documentation will help answer your question:

> **[Retrieve Catalog Objects](https://developer.squareup.com/docs/catalog-api/retrieve-catalog-objects)**
>
> Learn how to retrieve Square catalog objects of given IDs or versions using the Catalog API.

> **[Search for Items and Objects](https://developer.squareup.com/docs/catalog-api/search-catalog)**
>
> Learn how to search for objects programmatically using the SearchCatalogItems and SearchCatalogObjects endpoints.

> **Additional Documentation**
>
> [Call the SearchCatalogObjects Endpoint](https://developer.squareup.com/docs/catalog-api/search-catalog-objects)  
> [Catalog API](https://developer.squareup.com/docs/catalog-api/what-it-does)  
> [Delete Catalog Objects and Query Deleted Objects](https://developer.squareup.com/docs/catalog-api/delete-catalog-objects)

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.  
Otherwise one of our Developer Advocates will provide additional assistance shortly.

---

<div class="post-metadata">

**Author:** ![Square-Dev-AI](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/square-dev-ai/32/2513_2.png) [@Square-Dev-AI](https://developer.squareup.com/forums/u/Square-Dev-AI)\
**Post date:** [March 17, 2025, 3:31pm UTC](https://developer.squareup.com/forums/t/i-think-im-missing-a-basic-concept-of-this-api-how-to-get-the-items-out-of-this-call/21443/3 "2025-03-17T15:31:28Z")

</div>

To access the catalog objects from the response, you can use the `getObjects()` method on the response object. Here’s how you can do it:

```php
$categories = $response->getResult()->getObjects();
$allObjects = $response2->getResult()->getObjects();

```

In this code, `$categories` and `$allObjects` will be arrays containing the catalog objects returned by the API calls. Each element in these arrays will be an instance of `CatalogObject`.

_This answer was reviewed by @Bryan-Square._

---

<div class="post-metadata">

**Author:** ![DGD](https://avatars.discourse-cdn.com/v4/letter/d/f04885/32.png) [@DGD](https://developer.squareup.com/forums/u/DGD)\
**Post date:** [March 18, 2025, 11:18pm UTC](https://developer.squareup.com/forums/t/i-think-im-missing-a-basic-concept-of-this-api-how-to-get-the-items-out-of-this-call/21443/4 "2025-03-18T23:18:10Z")

</div>

> [@Square-Dev-AI](#):
>
> `$categories = $response->getResult()->getObjects();`

I couldn’t get that to work so I did this.

```auto

      $response = $this->client->catalog->list(
                new ListCatalogRequest([
                    'types' => 'CATEGORY',
                ]),
            );
            foreach ($pager as $response) {
                $data = json_decode(json_encode($response));
                if ($data->type == 'CATEGORY') {
                    array_push($categories, $data->category_data);
                }
            }

```

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [March 19, 2025, 3:53pm UTC](https://developer.squareup.com/forums/t/i-think-im-missing-a-basic-concept-of-this-api-how-to-get-the-items-out-of-this-call/21443/5 "2025-03-19T15:53:35Z")

</div>

Glad to hear that you got it to work. 🙂
