Google Drive Image Proxy for Notion¶
The Google Drive Image Proxy API provides endpoints for embedding Google Drive images in Notion pages. This API solves the challenge of using Google Drive images in Notion, which doesn't natively support direct embedding of Google Drive images.
Key Features¶
- Google Drive Integration: Easily embed Google Drive images in Notion pages
- Image Optimization: Resize and optimize images for Notion
- Caching: Improve loading times with server-side caching
Authentication¶
All Google Drive Image Proxy API endpoints require authentication using an API key. Include your API key in the X-API-KEY
header of your requests.
curl -X GET "https://magic-meal-kits-xxxxx.run.app/api/v1/proxy-url?url=https://drive.google.com/file/d/YOUR_FILE_ID/view" \
-H "X-API-KEY: your-api-key"
Video¶
Endpoints¶
Generate Proxy URL for Google Drive Image¶
Generates a proxy URL for a Google Drive image that can be used in Notion.
GET /api/v1/proxy-url
¶
Query Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
url | String | Yes | URL of the Google Drive image |
width | Integer | No | Desired width of the image |
Example Request:
curl -X GET "https://magic-meal-kits-xxxxx.run.app/api/v1/proxy-url?url=https://drive.google.com/file/d/YOUR_FILE_ID/view" \
-H "X-API-KEY: your-api-key"
Example Response:
{
"success": true,
"original_url": "https://drive.google.com/file/d/YOUR_FILE_ID/view",
"proxy_url": "https://magic-meal-kits-xxxxx.run.app/proxy.jpg?url=encrypted_url_data",
"proxy_urls": {
"original": "https://magic-meal-kits-xxxxx.run.app/proxy.jpg?url=encrypted_url_data",
"thumbnail": "https://magic-meal-kits-xxxxx.run.app/proxy.jpg?url=encrypted_url_data&width=150",
"small": "https://magic-meal-kits-xxxxx.run.app/proxy.jpg?url=encrypted_url_data&width=400",
"medium": "https://magic-meal-kits-xxxxx.run.app/proxy.jpg?url=encrypted_url_data&width=800",
"large": "https://magic-meal-kits-xxxxx.run.app/proxy.jpg?url=encrypted_url_data&width=1200"
}
}
Access Proxied Google Drive Image¶
Accesses and optimizes a Google Drive image through the proxy.
GET /proxy.jpg
¶
Query Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
url | String | Yes | Encrypted URL data from the proxy-url endpoint |
width | Integer | No | Width to resize the image to |
Example Request:
curl -X GET "https://magic-meal-kits-xxxxx.run.app/proxy.jpg?url=encrypted_url_data&width=800"
Response:
The image data with appropriate content type headers.
Google Drive Integration for Notion¶
This API is specifically designed to solve the challenge of embedding Google Drive images in Notion, which doesn't natively support direct embedding of Google Drive images.
How It Works¶
- You provide a Google Drive public image URL
- The API converts it to a directly accessible URL
- The image can now be embedded in Notion pages
Step-by-Step Guide for Notion¶
- Make your Google Drive image publicly accessible (right-click β Share β Anyone with the link)
- Get the image URL from Google Drive (right-click β Get link)
- Generate a proxy URL using the
/api/v1/proxy-url
endpoint - Use the returned proxy URL in your Notion page's image block
Supported Google Drive URL Formats¶
The API supports various Google Drive URL formats:
https://drive.google.com/file/d/FILE_ID/view
https://drive.google.com/open?id=FILE_ID
https://docs.google.com/uc?id=FILE_ID
Benefits for Notion Users¶
- Direct Embedding: Bypass Notion's limitations with Google Drive images
- Optimized Loading: Images load faster due to optimization and caching
- Responsive Images: Create different sized versions for different devices
- Persistent Access: Images remain accessible even if Google Drive changes URL structures
Usage Example in Notion¶
Here's how to use the Google Drive Image Proxy API with Notion:
-
Generate a proxy URL for your Google Drive image:
curl -X GET "https://magic-meal-kits-xxxxx.run.app/api/v1/proxy-url?url=https://drive.google.com/file/d/YOUR_FILE_ID/view" \ -H "X-API-KEY: your-api-key"
-
Copy the
proxy_url
value from the response - In Notion, create an image block (type
/image
) - Select "Link" and paste the proxy URL
- The image will now display properly in your Notion page
Error Handling¶
If an error occurs, the API returns an error response:
{
"success": false,
"error": "Error message description"
}
Common error codes:
- 400 Bad Request: Invalid parameters or request body
- 401 Unauthorized: Missing or invalid API key
- 404 Not Found: Image not found or URL is invalid
- 429 Too Many Requests: Rate limit exceeded
- 500 Internal Server Error: Server-side error