Answers.Body: <pre><code>$categories = Category::find()-&gt;groupId($id)-&gt;all();
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-20T05:06:29.757Z
Answers.LastActivityDate: 2018-04-20T06:55:08.273Z
Answers.LastEditDate: 2018-04-20T06:55:08.273Z
Answers.UserDisplayName: Robin Schambach
Body: <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>
  
Tags: <craft3><plugin-elementapi>
Title: Get all Categories with getGroupById in Element API plugin - Craft 3
ThreadText: # 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();
  
  ```
  
  
  ---
  
  