dambel

دمبل

shevron
ورود | ثبت نام

API Docs / posts / index



GET /api/v1/posts

Retrieves a list of posts, with support for filtering by profile type, profile ID, search, and order. Useful for both admin management and fetching posts for a specific profile.


Permissions

PermissionDescription
posts.viewView your own posts and posts on any public profile
posts.view_allView all posts, including drafts, on any profile (admin only)

Query Parameters

NameTypeRequiredDescriptionExample
typestringNoProfile type (App\Models\Gym, App\Models\User). Comma-separated for multiple types"App\Models\Gym,App\Models\User"
item_idintNoProfile ID(s) to filter by (comma-separated for multiple)"1,2,3"
searchstringNoSearch term for post title or content"workout"
orderstringNoOrder of results: ASC or DESC (default: DESC)"DESC"

Response

200 OK

Returns a paginated list of post resources.

Schema

{
  "data": [
    { /* Post Resource */ }
  ],
  "links": { /* Pagination Data */ },
  "meta": { /* Pagination Data */ }
}

Example

{
  "data": [
    {
      "id": 123,
      "profile_type": "App\\Models\\User",
      "profile_id": 42,
      "title": "My Workout",
      "content": "Today I did squats and deadlifts.",
      "is_draft": false,
      "media": [
        {
          "id": 10,
          "attachable_type": "App\\Models\\Posts\\Post",
          "attachable_id": 123,
          "link": "https://example.com/media/10.jpg"
        }
      ],
    }
  ],
  "links": {
    "first": "https://api.example.com/api/v1/posts?page=1",
    "last": "https://api.example.com/api/v1/posts?page=10",
    "prev": null,
    "next": "https://api.example.com/api/v1/posts?page=2"
  },
  "meta": {
    "current_page": 1,
    "from": 1,
    "last_page": 10,
    "path": "https://api.example.com/api/v1/posts",
    "per_page": 50,
    "to": 50,
    "total": 500
  }
}

For a full schema, see Post Resource and Pagination Data.


Error Responses

StatusDescriptionReference
401UnauthorizedAuthentication error
403Forbidden (no permission)Permission error
404Not foundNot-found error
footer wave
logo

دمبل، دنیای هوشمند ورزش و تغذیه

LinkedinInstagramXYoutube