Aller au contenu

Media

Ce contenu n’est pas encore disponible dans votre langue.

The Media resource provides fake media attachment data for social posts, including images, videos, and other file types.

MethodEndpointDescription
GET/v1/mediaList all media
GET/v1/media/:idGet a specific media item
{
"id": 1,
"socialPostId": 1,
"url": "https://example.com/images/photo.jpg",
"type": "image",
"width": 1920,
"height": 1080,
"fileSize": 245760,
"createdAt": "2026-01-15T10:30:00.000Z"
}
Field Type Description
id number Unique identifier
socialPostId number ID of the parent post
url string Media file URL
type string Media type (image, video, file)
width number Width in pixels (for images/videos)
height number Height in pixels (for images/videos)
fileSize number File size in bytes
createdAt string ISO 8601 timestamp
Terminal window
curl https://api.phantomjson.app/v1/media
Parameter Type Default Description
page number 1 Page number
limit number 20 Items per page (max: 100)
sort string Sort field and direction
fields string Fields to return
socialPostId number Filter by post ID
type string Filter by media type
{
"data": [
{
"id": 1,
"socialPostId": 1,
"url": "https://example.com/images/photo.jpg",
"type": "image",
"width": 1920,
"height": 1080,
"fileSize": 245760
}
],
"meta": {
"total": 100,
"page": 1,
"limit": 20,
"totalPages": 5
}
}
Terminal window
curl https://api.phantomjson.app/v1/media/1
{
"data": {
"id": 1,
"socialPostId": 1,
"url": "https://example.com/images/photo.jpg",
"type": "image",
"width": 1920,
"height": 1080,
"fileSize": 245760,
"createdAt": "2026-01-15T10:30:00.000Z"
}
}
Terminal window
curl "https://api.phantomjson.app/v1/media?socialPostId=1"
Terminal window
curl "https://api.phantomjson.app/v1/media?type=image"
Terminal window
# Newest first
curl "https://api.phantomjson.app/v1/media?sort=createdAt:desc"
# Oldest first
curl "https://api.phantomjson.app/v1/media?sort=createdAt:asc"
Terminal window
curl "https://api.phantomjson.app/v1/media?fields=id,url,type,width,height"
Terminal window
# Images on post 1
curl "https://api.phantomjson.app/v1/media?socialPostId=1&type=image&sort=createdAt:desc"

Available media types:

  • image — JPEG, PNG, GIF, WebP images
  • video — MP4, WebM videos
  • file — Other file attachments
  • Social Post — Each media item belongs to a social post (socialPostId)