### Install requests library with pip Source: https://feedframer.com/docs/examples/python Use this command to install the 'requests' library, a required dependency for all the code examples in this guide. ```bash pip install requests ``` -------------------------------- ### Get User Media - Example Request (PHP/Laravel) Source: https://feedframer.com/docs/instagram-api Example PHP request using Laravel's HTTP client to fetch user media. Handles pagination if a next page exists. ```php use Illuminate\Support\Facades\Http; public function fetchMedia(): void { $fields = [ 'id', 'caption', 'media_type', 'media_url', 'thumbnail_url', 'permalink', 'timestamp', 'comments_count', 'like_count', ]; $response = Http::get("https://graph.instagram.com/{$this->instagram_user_id}/media", [ 'fields' => implode(',', $fields), 'limit' => 100, 'access_token' => decrypt($this->access_token), ]); $data = $response->json(); foreach ($data['data'] as $media) { $this->media()->updateOrCreate( ['instagram_id' => $media['id']], [ 'caption' => $media['caption'] ?? '', 'media_type' => $media['media_type'], 'media_url' => $media['media_url'], 'thumbnail_url' => $media['thumbnail_url'] ?? null, 'permalink' => $media['permalink'], 'timestamp' => $media['timestamp'], 'comments_count' => $media['comments_count'] ?? 0, 'like_count' => $media['like_count'] ?? 0, ] ); } // Handle pagination if needed if (isset($data['paging']['next'])) { $this->fetchNextPage($data['paging']['next']); } } ``` -------------------------------- ### Install Dependencies Source: https://feedframer.com/docs/integrations/react No special dependencies needed! Use native fetch API or your preferred HTTP client. Run npm install or yarn install. ```bash npm install # or yarn install ``` -------------------------------- ### Get User Profile Information - Example Request (PHP) Source: https://feedframer.com/docs/instagram-api Example PHP request to fetch profile information using Laravel's HTTP client. ```php $response = Http::get('https://graph.instagram.com/me', [ 'fields' => 'id,username,name,profile_picture_url,followers_count,follows_count,media_count,biography', 'access_token' => decrypt($this->access_token), ]); ``` -------------------------------- ### Get Individual Media Details - Example Request (PHP) Source: https://feedframer.com/docs/instagram-api Example PHP request to fetch individual media details. For carousel albums, use children{media_url,media_type} to get all child media. ```php $response = Http::get("https://graph.instagram.com/{$mediaId}", [ 'fields' => 'id,caption,media_type,media_url,timestamp,children{media_url,media_type}', 'access_token' => $token, ]); ``` -------------------------------- ### Pagination Example (JavaScript) Source: https://feedframer.com/docs/rest-api JavaScript example that fetches all posts using cursor-based pagination. It loops until hasMore is false, concatenating posts and updating the cursor. ```javascript let cursor = null; let allPosts = []; do { const url = cursor ? `https://feedframer.com/api/v1/me?api_key=${apiKey}&page[cursor]=${cursor}` : `https://feedframer.com/api/v1/me?api_key=${apiKey}`; const response = await fetch(url); const data = await response.json(); allPosts = allPosts.concat(data.posts); cursor = data.pagination.hasMore ? data.pagination.nextCursor : null; } while (cursor !== null); ``` -------------------------------- ### Preview text example Source: https://feedframer.com/docs/integrations/mailchimp.md Example preview text for the email, using the *|RSSITEMS:COUNT|* merge tag to show the number of new posts. ```plaintext *|RSSITEMS:COUNT|* new posts from Instagram this week ``` -------------------------------- ### Get User Media - Response Structure Source: https://feedframer.com/docs/instagram-api Example JSON response structure for the Get User Media endpoint, showing media items and pagination cursors. ```json { "data": [ { "id": "17895695668004550", "caption": "Beautiful sunset at the beach!", "media_type": "IMAGE", "media_url": "https://scontent.cdninstagram.com/...", "permalink": "https://www.instagram.com/p/ABC123/", "timestamp": "2025-01-15T10:30:00+0000", "comments_count": 42, "like_count": 384 }, { "id": "17895695668004551", "media_type": "VIDEO", "media_url": "https://scontent.cdninstagram.com/...", "thumbnail_url": "https://scontent.cdninstagram.com/...", "permalink": "https://www.instagram.com/p/XYZ789/", "timestamp": "2025-01-14T15:45:00+0000", "comments_count": 23, "like_count": 156 } ], "paging": { "cursors": { "before": "QVFIUjRSa...", "after": "QVFIUjA3b..." }, "next": "https://graph.instagram.com/v23.0/.../media?after=QVFIUjA3b..." } } ``` -------------------------------- ### Example Request with curl Source: https://feedframer.com/docs/rest-api Example curl command for the /api/v1/me endpoint. Uses query parameters to filter by type, sort by published_at descending, and request 12 results per page. ```bash curl 'https://feedframer.com/api/v1/me?api_key=YOUR_API_KEY&filter[type]=IMAGE&sort=-published_at&page[size]=12' ``` -------------------------------- ### Get User Profile Information - Response Source: https://feedframer.com/docs/instagram-api Example JSON response for the Get User Profile Information endpoint. ```json { "id": "17841405793187218", "username": "mycompany", "name": "My Company", "profile_picture_url": "https://scontent.cdninstagram.com/...", "followers_count": 12453, "follows_count": 342, "media_count": 187, "biography": "Official account for My Company" } ``` -------------------------------- ### Specific Filter Example Source: https://feedframer.com/docs/filtering-sorting Use specific filters to improve query speed and reduce data transfer. This example shows a GET request with type and publishedAfter filters and a page size of 10. ```http # ✅ Good - specific filter GET /api/v1/me?api_key=YOUR_API_KEY&filter[type]=IMAGE&filter[publishedAfter]=2024-01-01&page[size]=10 # ❌ Less efficient - no filters GET /api/v1/me?api_key=YOUR_API_KEY ``` -------------------------------- ### API Key Format Example Source: https://feedframer.com/docs/authentication Example of a 64-character hexadecimal API key format used by Feedframer. ```text a1b2c3d4e5f6789012345678901234567890abcdefghijklmnopqrstuvwxyz1234 ``` -------------------------------- ### Make a simple GET request to Feedframer API Source: https://feedframer.com/docs/examples/python Sends a GET request to the '/api/v1/me' endpoint with an API key and pagination, then prints account info and posts. Replace 'YOUR_API_KEY' with your actual key. ```python import requests api_key = 'YOUR_API_KEY' url = f'https://feedframer.com/api/v1/me?api_key={api_key}&page[size]=12' response = requests.get(url) data = response.json() # Display account info print(f"Account: {data['username']}") print(f"Followers: {data['followersCount']}") # Display posts for post in data['posts']: print(post['caption']) print(post['mediaUrl']) ``` -------------------------------- ### GET /api/v1/me Source: https://feedframer.com/docs/rest-api Documentation for the GET /api/v1/me endpoint, including the format parameter and premium responsive image sizes. ```APIDOC ## [GET] /api/v1/me ### Description Retrieves user data including posts with responsive image URLs for premium users. The `format` parameter controls the output image format (JPEG or WebP). ### Method GET ### Endpoint /api/v1/me ### Parameters #### Query Parameters - **api_key** (string) - Required - Your API key for authentication. - **format** (string) - Optional - Output image format. Supported values: `jpg` (default) and `webp`. ### Request Example ``` GET /api/v1/me?api_key=YOUR_API_KEY&format=jpg ``` ### Response #### Success Response (200) - **posts** (array) - List of posts. - **id** (string) - Post ID. - **mediaType** (string) - Type of media (e.g., IMAGE). - **mediaUrl** (string) - URL to the original media. - **sizes** (object) - Responsive image URLs (premium only). - **320** (string) - URL for 320px width. - **768** (string) - URL for 768px width. - **960** (string) - URL for 960px width. - **1200** (string) - URL for 1200px width. #### Response Example ``` { "posts": [ { "id": "18123456789012345", "mediaType": "IMAGE", "mediaUrl": "https://cdn.feedframer.com/your_username/123_media.jpg", "sizes": { "320": "https://cdn.feedframer.com/cdn-cgi/image/width=320,format=jpg/your_username/123_media.jpg", "768": "https://cdn.feedframer.com/cdn-cgi/image/width=768,format=jpg/your_username/123_media.jpg", "960": "https://cdn.feedframer.com/cdn-cgi/image/width=960,format=jpg/your_username/123_media.jpg", "1200": "https://cdn.feedframer.com/cdn-cgi/image/width=1200,format=jpg/your_username/123_media.jpg" } } ] } ``` ``` -------------------------------- ### PHP Request with API Key Source: https://feedframer.com/docs/authentication PHP example using file_get_contents to make an authenticated request and print the response. ```php '; } ``` -------------------------------- ### Python Request with API Key Source: https://feedframer.com/docs/authentication Python example using the requests library to make an authenticated request and print the response. ```python import requests api_key = 'YOUR_API_KEY' url = f'https://feedframer.com/api/v1/me?api_key={api_key}' response = requests.get(url) data = response.json() print(data) ``` -------------------------------- ### Combine with Pagination Source: https://feedframer.com/docs/filtering-sorting Always use pagination when fetching filtered results. This example fetches results in batches with a page size of 50. ```http # Fetch results in batches GET /api/v1/me?api_key=YOUR_API_KEY&filter[type]=IMAGE&page[size]=50 ``` -------------------------------- ### Example response with comments array Source: https://feedframer.com/docs/rest-api Shows the structure of a comments array. Each comment includes id, text, username, timestamp, and like_count. ```json { "comments": [ { "id": "17900000000000000", "text": "Love this! 😍", "username": "a_commenter", "timestamp": "2024-01-15T19:02:11+0000", "like_count": 3 } ] } ``` -------------------------------- ### Get Account and Posts - Endpoint Source: https://feedframer.com/docs/rest-api HTTP method and path for retrieving account information and posts. ```text GET /api/v1/me ``` -------------------------------- ### Make a GET request with parameters to filter image posts Source: https://feedframer.com/docs/examples/python Sends a GET request to the Feedframer API using query parameters to filter image posts and sort by publish date. Demonstrates use of the 'params' argument with the requests library. ```python import requests api_key = 'YOUR_API_KEY' params = { 'api_key': api_key, 'filter[type]': 'IMAGE', 'page[size]': 12, 'sort': '-published_at' } response = requests.get('https://feedframer.com/api/v1/me', params=params) data = response.json() for post in data['posts']: print(f"Caption: {post['caption']}") print(f"Media URL: {post['mediaUrl']}") ``` -------------------------------- ### JavaScript Fetch API Request Source: https://feedframer.com/docs/authentication JavaScript example using the Fetch API to make an authenticated request. ```javascript const apiKey = 'YOUR_API_KEY'; const url = `https://feedframer.com/api/v1/me?api_key=${apiKey}`; fetch(url) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); ``` -------------------------------- ### Get User Profile Information - Available Fields Source: https://feedframer.com/docs/instagram-api Comma-separated list of fields that can be requested for the user profile. ```text id, username, name, profile_picture_url, followers_count, follows_count, media_count, biography, website ``` -------------------------------- ### REST API Request with api_key Source: https://feedframer.com/docs/authentication Example REST API request with the api_key query parameter. ```http GET https://feedframer.com/api/v1/me?api_key=YOUR_API_KEY ``` -------------------------------- ### Example Response JSON Source: https://feedframer.com/docs/rest-api Sample JSON response for the /api/v1/me endpoint. Contains account fields and a posts array with media metadata and pagination info. ```json { "username": "your_username", "name": "Your Name", "biography": "Your bio text", "website": "https://example.com", "profilePictureUrl": "https://scontent.cdninstagram.com/...", "followersCount": 1234, "followsCount": 567, "mediaCount": 89, "posts": [ { "id": "18123456789012345", "caption": "Beautiful sunset over the ocean 🌅 #photography #nature", "altText": "Sunset over the ocean", "mediaType": "IMAGE", "mediaUrl": "https://scontent.cdninstagram.com/...", "thumbnailUrl": null, "sizes": { "320": "https://cdn.feedframer.com/cdn-cgi/image/width=320,format=jpg/your_username/123_media.jpg", "768": "https://cdn.feedframer.com/cdn-cgi/image/width=768,format=jpg/your_username/123_media.jpg", "960": "https://cdn.feedframer.com/cdn-cgi/image/width=960,format=jpg/your_username/123_media.jpg", "1200": "https://cdn.feedframer.com/cdn-cgi/image/width=1200,format=jpg/your_username/123_media.jpg" }, "permalink": "https://www.instagram.com/p/ABC123/", "timestamp": "2024-01-15T18:30:00+00:00", "likeCount": 1542, "commentsCount": 87 } ], "pagination": { "nextCursor": "eyJpZCI6MTJ9", "prevCursor": null, "hasMore": true, "perPage": 12 } } ``` -------------------------------- ### Authenticated GraphQL Request Source: https://feedframer.com/docs/graphql-api Example of a GET request to the GraphQL endpoint with an API key as a query parameter. All requests use GET for caching. ```http GET https://feedframer.com/graphql?api_key=YOUR_API_KEY&query=... ``` -------------------------------- ### Environment Variables Setup (.env.local) Source: https://feedframer.com/docs/examples/nextjs Create a .env.local file with the Feedframer API key. The NEXT_PUBLIC_ prefix is safe for client-side usage because the API serves only public Instagram data. ```plaintext # For server-side usage (Server Components, API Routes) FEEDFRAMER_API_KEY=your_api_key_here # For client-side usage (optional - safe for Feedframer!) NEXT_PUBLIC_FEEDFRAMER_API_KEY=your_api_key_here ``` -------------------------------- ### GET /api/v1/me Source: https://feedframer.com/docs/errors The Feedframer API endpoint for retrieving the authenticated user's information. This endpoint is used in examples to demonstrate error handling for authentication and validation errors. ```APIDOC ## [GET] /api/v1/me ### Description Retrieves the authenticated user's information. This endpoint is used in examples to demonstrate error handling for authentication and validation errors. ### Method GET ### Endpoint /api/v1/me ### Parameters #### Query Parameters - **api_key** (string) - Required - API key for authentication. - **page[size]** (integer) - Optional - Number of items per page (must be between 1 and 100). - **filter[type]** (string) - Optional - Filter posts by type (must be one of: IMAGE, VIDEO, CAROUSEL_ALBUM, REELS). ### Request Example ``` curl 'https://feedframer.com/api/v1/me?api_key=YOUR_API_KEY' ``` ### Response #### Success Response (200) - **data** (object) - The authenticated user's data. #### Response Example ``` { "data": { "id": "123", "type": "user", "attributes": { "username": "example_user" } } } ``` ### Error Responses #### 401 Unauthorized - **errors** (array) - List of error objects. - **status** (string) - HTTP status code as a string. - **code** (string) - Machine-readable error code. - **title** (string) - Short, human-readable summary. - **detail** (string) - Detailed error message. - **source** (object) - Optional pointer to the error source. #### 422 Unprocessable Entity - **errors** (array) - List of error objects. - **status** (string) - HTTP status code as a string. - **code** (string) - Machine-readable error code. - **title** (string) - Short, human-readable summary. - **detail** (string) - Detailed error message. - **source** (object) - Optional pointer to the error source. #### 500 Internal Server Error - **errors** (array) - List of error objects. - **status** (string) - HTTP status code as a string. - **code** (string) - Machine-readable error code. - **title** (string) - Short, human-readable summary. - **detail** (string) - Detailed error message. ``` -------------------------------- ### Success Response (200 OK) Source: https://feedframer.com/docs/accounts-api Example JSON:API compliant response returned on a successful request. Contains account attributes such as username, biography, follower counts, and status. ```json { "data": [ { "type": "instagram-accounts", "id": "1", "attributes": { "instagramUserId": "9703719383064401", "username": "your_username", "name": "Your Display Name", "biography": "Your Instagram bio \ud83d\ude80", "website": "https://yourwebsite.com", "profilePictureUrl": "https://scontent.cdninstagram.com/...", "followersCount": 1234, "followsCount": 567, "mediaCount": 89, "status": "active", "profileLastUpdatedAt": "2025-10-04T08:45:34+00:00", "lastFetchAt": "2025-10-04T08:45:34+00:00" } } ], "meta": { "total": 1 } } ``` -------------------------------- ### Basic Query: Get account info with latest 12 posts Source: https://feedframer.com/docs/graphql-api Fetches the authenticated user's username, name, profile picture, latest 12 posts, and pagination info. Use this as a starting point for retrieving basic account and post data. ```graphql query GetMe { me(first: 12) { username name profilePictureUrl posts { id instagramPostId caption mediaUrl publishedAt } pagination { nextCursor hasMore perPage } } } ``` -------------------------------- ### Multi-Step Flow Diagram Source: https://feedframer.com/docs/integrations/klaviyo.md Flow diagram for a new product launch email sequence. Shows trigger, email, wait, and conditional split steps. ```text Trigger: RSS Feed (new post) ↓ Email: "New on Instagram!" ↓ Wait: 1 day ↓ Conditional Split: Clicked email? ├─ Yes → Add to Segment "Instagram Engaged" └─ No → Wait 2 days → Reminder Email ``` -------------------------------- ### In-Memory Cache for API Route Source: https://feedframer.com/docs/examples/nextjs Cache API responses in memory using a Map. The example shows a GET handler that returns cached data if less than 1 hour old, otherwise fetches fresh data and updates the cache. Note: production should use Redis instead of in-memory cache. ```typescript // Simple in-memory cache (production: use Redis) const cache = new Map(); export async function GET(request: Request) { const cacheKey = 'instagram_posts'; if (cache.has(cacheKey)) { const { data, timestamp } = cache.get(cacheKey); // Return cached data if less than 1 hour old if (Date.now() - timestamp < 3600000) { return NextResponse.json(data); } } // Fetch fresh data const res = await fetch(url); const data = await res.json(); cache.set(cacheKey, { data, timestamp: Date.now() }); return NextResponse.json(data); } ``` -------------------------------- ### Feedframer Laravel integration: service, controller, and route Source: https://feedframer.com/docs/examples/laravel Complete Laravel example for integrating the Feedframer API. The service caches the latest posts for 60 minutes, makes a GET request to /api/v1/me with the API key, and logs errors. The controller injects the service and passes posts to the instagram.feed view. The route registers the /instagram endpoint. ```php // app/Services/FeedframerService.php apiKey = config('services.feedframer.api_key'); $this->baseUrl = config('services.feedframer.base_url'); } public function getLatestPosts(int $limit = 12): array { return Cache::remember("feedframer_latest_{$limit}", $this->cacheMinutes, function () use ($limit) { $data = $this->makeRequest([ 'page[size]' => $limit, 'sort' => '-published_at', ]); return $data['data'] ?? []; }); } protected function makeRequest(array $params = []): ?array { try { $response = Http::timeout(10) ->get("{$this->baseUrl}/api/v1/me", array_merge([ 'api_key' => $this->apiKey, ], $params)); if ($response->successful()) { return $response->json(); } $this->handleError($response); return null; } catch (\Exception $e) { Log::error('Feedframer request failed', [ 'message' => $e->getMessage(), 'params' => $params, ]); return null; } } protected function handleError($response): void { $error = $response->json()['errors'][0] ?? null; if ($error) { Log::error('Feedframer API Error', [ 'code' => $error['code'], 'detail' => $error['detail'], ]); } } } ``` ```php // app/Http/Controllers/InstagramFeedController.php getLatestPosts(12); return view('instagram.feed', compact('posts')); } } ``` ```php // routes/web.php Route::get('/instagram', [InstagramFeedController::class, 'index'])->name('instagram'); ``` -------------------------------- ### Example JSON response with sizes object Source: https://feedframer.com/docs/rest-api Shows the response structure for premium users, including the sizes object with URLs for 320, 768, 960, and 1200 pixel widths. Free tier users do not receive the sizes object. ```json { "posts": [ { "id": "18123456789012345", "mediaType": "IMAGE", "mediaUrl": "https://cdn.feedframer.com/your_username/123_media.jpg", "sizes": { "320": "https://cdn.feedframer.com/cdn-cgi/image/width=320,format=jpg/your_username/123_media.jpg", "768": "https://cdn.feedframer.com/cdn-cgi/image/width=768,format=jpg/your_username/123_media.jpg", "960": "https://cdn.feedframer.com/cdn-cgi/image/width=960,format=jpg/your_username/123_media.jpg", "1200": "https://cdn.feedframer.com/cdn-cgi/image/width=1200,format=jpg/your_username/123_media.jpg" } } ] } ``` -------------------------------- ### cURL GET request with URL-encoded query Source: https://feedframer.com/docs/graphql-api cURL command to make a GET request to the GraphQL endpoint. The query is passed as a URL-encoded parameter, and the API key is included. All GraphQL requests use GET for optimal CDN caching. ```bash curl -G 'https://feedframer.com/graphql' \ --data-urlencode 'api_key=YOUR_API_KEY' \ --data-urlencode 'query=query { me(first: 12) { username posts { id caption mediaUrl publishedAt } } }' ``` -------------------------------- ### Navigate Pages with Cursor Source: https://feedframer.com/docs/rest-api Use page[cursor] with the cursor value from the previous response. The example shows first page, next page using nextCursor, and previous page using prevCursor. ```http # First page GET /api/v1/me?api_key=YOUR_API_KEY&page[size]=12 # Next page (using nextCursor from previous response) GET /api/v1/me?api_key=YOUR_API_KEY&page[size]=12&page[cursor]=eyJpZCI6MTJ9 # Previous page (using prevCursor) GET /api/v1/me?api_key=YOUR_API_KEY&page[size]=12&page[cursor]=eyJpZCI6MX0 ``` -------------------------------- ### GET /api/v1/accounts endpoint Source: https://feedframer.com/docs/accounts-api The endpoint to retrieve profile information for connected Instagram accounts. Use this HTTP GET request to fetch account data. ```http GET /api/v1/accounts ``` -------------------------------- ### Instagram CAROUSEL_ALBUM Media Type JSON Example Source: https://feedframer.com/docs/instagram-api Example JSON response for a CAROUSEL_ALBUM, with children data containing media items and their URLs, plus permalink and timestamp. ```json { "id": "789", "media_type": "CAROUSEL_ALBUM", "caption": "Carousel caption", "children": { "data": [ { "id": "789_1", "media_type": "IMAGE", "media_url": "https://..." }, { "id": "789_2", "media_type": "VIDEO", "media_url": "https://...", "thumbnail_url": "https://..." } ] }, "permalink": "https://instagram.com/p/...", "timestamp": "2025-01-13T12:00:00+0000" } ``` -------------------------------- ### Instagram VIDEO Media Type JSON Example Source: https://feedframer.com/docs/instagram-api Example JSON response for a VIDEO media type, including required fields media_url and thumbnail_url, and optional caption. ```json { "id": "456", "media_type": "VIDEO", "media_url": "https://video.cdninstagram.com/...", "thumbnail_url": "https://scontent.cdninstagram.com/...", "caption": "Video caption", "permalink": "https://instagram.com/p/...", "timestamp": "2025-01-14T15:45:00+0000" } ``` -------------------------------- ### GET /api/v1/me with include[]=children Source: https://feedframer.com/docs/rest-api Requests the children array for carousel posts. Use this to get every media item in a CAROUSEL_ALBUM post, since mediaUrl only points to the first item. ```http GET /api/v1/me?api_key=YOUR_API_KEY&include[]=children ``` -------------------------------- ### Create config/services.php entry Source: https://feedframer.com/docs/cloudflare-cache-setup Add this configuration array to config/services.php to map the Cloudflare environment variables. The 'enabled' key defaults to false if not set. ```php 'cloudflare' => [ 'zone_id' => env('CLOUDFLARE_ZONE_ID'), 'api_token' => env('CLOUDFLARE_API_TOKEN'), 'enabled' => env('CLOUDFLARE_CACHE_ENABLED', false), ], ``` -------------------------------- ### Subject line examples with merge tags Source: https://feedframer.com/docs/integrations/mailchimp.md Example subject lines for the Mailchimp RSS campaign. Use merge tags like *|RSSFEED:TITLE|* to personalize the subject with your feed title. ```plaintext Fresh from Instagram: New posts this week! 📸 *|RSSFEED:TITLE|* - Weekly Update Check out our latest Instagram posts This week's highlights from @yourusername ``` -------------------------------- ### PHP request to list accounts Source: https://feedframer.com/docs/accounts-api Uses file_get_contents to fetch account data and prints each account's username. ```php