<pre><code>$categories = Category::find()-&gt;groupId($id)-&gt;all();
</code></pre>

CC BY-SA 3.0
2018-04-20T05:06:29.757Z
2018-04-20T06:55:08.273Z
2018-04-20T06:55:08.273Z
Robin Schambach
<p>I have an endpoint created and I am getting the groupID but I am unable to get all the categories associated with the group.</p>

<p>This is what I have right now:</p>

<pre><code>$categoriesGroup = Craft::$app-&gt;categories-&gt;getGroupById($catId);
</code></pre>

<p>I can't seem to get an array of entries from that.</p>

<craft3><plugin-elementapi>
Get all Categories with getGroupById in Element API plugin - Craft 3
# Get all Categories with getGroupById in Element API plugin - Craft 3

(Asked by: username_0 on 2018-04-20)

I have an endpoint created and I am getting the groupID but I am unable to get all the categories associated with the group.
This is what I have right now:
$categoriesGroup = Craft::$app->categories->getGroupById($catId);

I can't seem to get an array of entries from that.

**Tags:** craft3, plugin-elementapi


---

## 1 answers

### Answer by username_1 on 2018-04-20. Score: 2 | Accepted answer

$categories = Category::find()->groupId($id)->all();


---

