Update documentation content
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
---
|
||||
title: API Media GET | Datasquirel docs
|
||||
description: Retrieve media file metadata via the Datasquirel API
|
||||
page_title: Media GET
|
||||
page_description: Retrieve a media file or a list of media files using the Datasquirel API.
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
Use the Media GET endpoint to retrieve metadata for one or more media files. You can look up a file by its database ID, by name, or list all files in a folder.
|
||||
|
||||
## npm Package
|
||||
|
||||
### Get All Media Files
|
||||
|
||||
```javascript
|
||||
import datasquirel from "@moduletrace/datasquirel";
|
||||
|
||||
const result = await datasquirel.media.get({
|
||||
apiKey: process.env.DATASQUIREL_API_KEY,
|
||||
});
|
||||
|
||||
console.log(result.payload); // Array of media objects
|
||||
```
|
||||
|
||||
### Get a Single File by ID
|
||||
|
||||
```javascript
|
||||
const result = await datasquirel.media.get({
|
||||
mediaID: 15,
|
||||
apiKey: process.env.DATASQUIREL_API_KEY,
|
||||
});
|
||||
```
|
||||
|
||||
### Get Files in a Specific Folder
|
||||
|
||||
```javascript
|
||||
const result = await datasquirel.media.get({
|
||||
folder: "profile-images",
|
||||
apiKey: process.env.DATASQUIREL_API_KEY,
|
||||
});
|
||||
```
|
||||
|
||||
### Get a File by Name
|
||||
|
||||
```javascript
|
||||
const result = await datasquirel.media.get({
|
||||
mediaName: "avatar.jpg",
|
||||
apiKey: process.env.DATASQUIREL_API_KEY,
|
||||
});
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
|-----------|------|----------|-------------|
|
||||
| `mediaID` | `string \| number` | No | The database ID of the media file |
|
||||
| `mediaName` | `string` | No | The file name to look up |
|
||||
| `folder` | `string` | No | Folder name to filter results |
|
||||
| `thumbnail` | `"true" \| "false"` | No | Return thumbnail URL instead of original |
|
||||
| `skipBase64` | `"true" \| "false"` | No | Skip base64 encoding in the response |
|
||||
| `apiKey` | `string` | No | API key. Falls back to `DATASQUIREL_API_KEY` |
|
||||
|
||||
## REST API
|
||||
|
||||
```
|
||||
GET /api/v1/media
|
||||
GET /api/v1/media/{id}
|
||||
```
|
||||
|
||||
**Headers:**
|
||||
```
|
||||
Authorization: Bearer YOUR_API_KEY
|
||||
```
|
||||
|
||||
## Response
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"payload": {
|
||||
"id": 15,
|
||||
"name": "avatar.jpg",
|
||||
"folder": "profile-images",
|
||||
"url": "https://your-instance.com/media/profile-images/avatar.jpg",
|
||||
"thumbnail_url": "https://your-instance.com/media/profile-images/thumbs/avatar.jpg",
|
||||
"size": 24576,
|
||||
"mime_type": "image/jpeg"
|
||||
}
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user