Перейти к содержимому

Read and asset routes

Each route here returns one stored or external file.

  • The paths are unversioned and are under the endpoints.media base URL from instance discovery.
  • Get static object is under the endpoints.static_cdn base URL.
  • Every route accepts GET and HEAD and has no rate limit.

Every route can also return these statuses.

StatusBodyCondition
403ForbiddenThe cross-origin read policy refuses the request Origin on an mp or upload endpoint
404Not FoundThe path is not a media route, the endpoint runs in relay mode, or the object does not exist
405Method Not AllowedThe method is neither GET nor HEAD
413Payload Too LargeThe route has to hold an object larger than 500 MiB in memory
502Bad GatewayThe object store could not be read
  • Attachments without a transformation, entrance sounds and static objects stream the stored bytes and have no size limit.
  • Every route accepts Range when it returns the stored bytes unchanged. A satisfiable range returns 206, and an unsatisfiable one returns 416.
  • A transformed response ignores Range and is always complete.
GET /attachments/{path}
Без входа.

Returns the attachment at the url or proxy_url of a message attachment object. Use the URL as issued, and add a transformation parameter to its query string to resize or convert the file. Anyone with the URL can read the file, and the signed attachment URL policy decides how long it works.

FieldTypeDescription
width?integerThe output width in pixels, up to the decoded edge bound
height?integerThe output height in pixels, up to the same bound
format?stringThe output format
quality?stringThe encoder quality profile
animated?booleanWhether animated output is requested
effort?integerThe WebP encoder effort (at most 9)
download?booleanWhether the response has attachment disposition
ex?stringThe URL expiry, from the issued URL
is?stringThe URL issue time, from the issued URL
hm?stringThe URL signature, from the issued URL
uc?stringSet to dp on data package download URLs, from the issued URL

Not every parameter starts a transformation. A video needs an image format to return a frame, and a video request that sets another transformation parameter without format returns 400. Setting format on a file that is neither an image nor a video also returns 400.

StatusBodyCondition
200Complete media representationThe attachment was returned
206Selected media bytesOne range over the stored bytes is satisfiable
400Bad RequestThe path, a dimension, the format or the transformation is invalid, or the transformation failed
404This content is no longer available.The signed attachment URL policy refuses the signature, or the object does not exist under enforce
416EmptyA range over the stored bytes is unsatisfiable
503Service UnavailableSquad has no transformation capacity free
504Gateway TimeoutThe transformation timed out
GET /external/{signature}/{target}
Без входа.

Returns a third-party file through Squad, optionally transformed. The HTTP API returns these URLs in proxy_url on embed media, proxy_icon_url on embed authors and footers, and proxy_url and proxy_src on GIF results. Use each URL exactly as the API returns it, and don’t build /external/ paths yourself.

The signature covers only the target and works until FLUXER_MEDIA_PROXY_SECRET_KEY changes. Squad fetches the target with the user agent Mozilla/5.0 (compatible; Fluxerbot/1.0; +https://app.squad-fun.su) and follows at most five redirects to public http or https addresses.

FieldTypeDescription
width?integerThe output width in pixels, up to the decoded edge bound
height?integerThe output height in pixels, up to the same bound
format?stringThe output format
quality?stringThe encoder quality profile
animated?booleanWhether animated output is requested
download?booleanWhether the response has attachment disposition

When no transformation runs, Squad forwards Range to the origin, which can respond with 200 or with 206.

StatusBodyCondition
200Complete external representationThe origin returned the file
206Selected external bytesThe origin or Squad returned a range
400Bad RequestThe path, target, redirect or transformation is invalid or not allowed
401UnauthorizedThe signature is invalid
413Payload Too LargeThe origin sent more than 500 MiB
416EmptyA local range is unsatisfiable
502Bad GatewayThe origin failed, was unreachable or redirected too many times
503Service UnavailableSquad could not allocate a buffer for the origin body or has no transformation capacity free
504Gateway TimeoutThe transformation timed out

Most origin 4xx statuses, such as 403, 404 and 429, come back with the same status and the body Upstream fetch failed. Other origin errors become 502.

GET /themes/{path}
Без входа.

Returns a theme stylesheet written by the themes resource as text/css; charset=utf-8. The path must end in .css.

GET /entrance-sounds/{user_id}/{filename}
Без входа.

Returns the audio of an entrance sound. filename is {hash}.{ext}, with the hash from the API and one of the extensions mp3, ogg, m4a or wav.

The image routes below all take the same query parameters and return the same statuses. Build the URL from the endpoints.media base URL, the route path, the hash from the resource object and an extension. An a_ hash means the asset is animated.

The extension sets the output format, in upper or lower case. Each route uses one size class for its sizes.

ExtensionFormat
pngPNG
jpg, jpegJPEG
webpWebP
gifGIF
apngAPNG
avifAVIF
heicHEIC
heifHEIF
jxlJPEG XL
svgSVG
FieldTypeDescription
size?integerThe square edge in pixels, snapped to the size ladder (default 128)
format?stringThe output format, also accepted as fmt, where auto uses the path extension
quality?stringThe encoder quality profile, defaulting to high
animated?booleanWhether animated output is requested, defaulting to true for an a_ hash
download?booleanWhether the response has attachment disposition

An unknown or invalid query value uses the default.

StatusBodyCondition
200Complete asset representationThe asset was returned
206Selected asset bytesOne range over the stored bytes is satisfiable
400Bad RequestThe path makes an unsafe storage key
404Not FoundThe path is not a valid asset path or the asset does not exist
416EmptyA range over the stored bytes is unsatisfiable
500Transcode FailedA required transcode failed and the source can’t be shown as it is
503Service UnavailableSquad has no transformation capacity free
504Gateway TimeoutThe transformation timed out
GET /avatars/{user_id}/{hash}.{ext}
Без входа.

Returns a user avatar in the icon size class.

GET /icons/{guild_id}/{hash}.{ext}
Без входа.

Returns a guild icon in the icon size class.

GET /branding/{entity_id}/{hash}.{ext}
Без входа.

Returns an instance branding image written by Create branding asset, in the branding size class. Without size, it returns the image at its original size.

GET /branding-backdrops/{entity_id}/{hash}.{ext}
Без входа.

Returns the sign-in backdrop written by Create branding asset with the sign_in_backdrop kind, in the branding size class. Without size, it returns the image at its original size.

GET /banners/{owner_id}/{hash}.{ext}
Без входа.

Returns a user or guild banner in the banner size class.

GET /splashes/{guild_id}/{hash}.{ext}
Без входа.

Returns a guild splash in the banner size class.

GET /embed-splashes/{guild_id}/{hash}.{ext}
Без входа.

Returns a guild embed splash in the banner size class.

GET /role-icons/{role_id}/{hash}.{ext}
Без входа.

Returns a role icon in the role icon size class. Role icons are never animated.

GET /guilds/{guild_id}/users/{user_id}/avatars/{hash}.{ext}
Без входа.

Returns a member’s guild avatar in the icon size class.

GET /guilds/{guild_id}/users/{user_id}/banners/{hash}.{ext}
Без входа.

Returns a member’s guild banner in the banner size class.

GET /emojis/{emoji_id}.{ext}
Без входа.

Returns an emoji cropped to a square in the emoji size class, static unless you pass animated=true. The ID never has an a_ prefix.

GET /stickers/{sticker_id}.{ext}
Без входа.

Returns a sticker cropped to a square in the sticker size class. Output is always WebP and ignores format, except that an animated GIF stays GIF when animated=true. The ID never has an a_ prefix.

GET /{key}
Без входа.

Returns a file from the static bucket, such as a default avatar or a client bundle. The route exists only on a Media Proxy in static mode. The whole path is the storage key, and query parameters are ignored.

These paths are for the instance itself and aren’t published by instance discovery.

PathMethodDescription
/_healthGETReturns 200 while the process is running
/_metricsGETReturns Prometheus metrics to loopback requests and 403 to anything else
/_metadataPOSTReturns media metadata for the HTTP API
/_sniffPOSTReturns the media type of a staged upload for the HTTP API
/_thumbnailPOSTMakes a WebP thumbnail of a staged upload for the HTTP API
/_framesPOSTExtracts one JPEG video frame for the HTTP API
/_stripPOSTRemoves metadata from an uploaded image, video or audio file for the HTTP API
/_audio_durationPOSTReturns the length of an uploaded audio file for the HTTP API

Without Authorization: Bearer {FLUXER_MEDIA_PROXY_SECRET_KEY}, the six POST endpoints return 401 Unauthorized.