@it_dhruv/delta-instagram-feed 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/readme.md +197 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@it_dhruv/delta-instagram-feed",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Plug-and-play Instagram Feed API with caching using Instagram Graph API",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/readme.md ADDED
@@ -0,0 +1,197 @@
1
+ # 📸 delta-instagram-feed
2
+
3
+ A plug-and-play **Instagram Feed API** for Node.js & Express with **built-in caching**, **secure token handling**, and **zero frontend exposure**.
4
+
5
+ Fetch Instagram posts using the official **Instagram Graph API**, cache them automatically, and serve them safely to your frontend.
6
+
7
+ ---
8
+
9
+ ## ✨ Features
10
+
11
+ - ✅ Official Instagram Graph API
12
+ - 🔐 Secure server-side token usage
13
+ - ⚡ Built-in 3-hour caching (prevents rate limits)
14
+ - 🧩 Express-ready router
15
+ - 🎥 Supports Images, Videos & Carousel posts
16
+ - 🚫 No frontend token leakage
17
+ - 📦 ESM compatible (`import` syntax)
18
+
19
+ ---
20
+
21
+ ## 📦 Installation
22
+
23
+ ```bash
24
+ npm i @it_dhruv/delta-instagram-feed
25
+ ```
26
+
27
+ ---
28
+
29
+ ## ⚙️ Prerequisites
30
+
31
+ Before using this package, you must have:
32
+
33
+ - Instagram **Business / Creator** account
34
+ - Facebook App with **Instagram Graph API enabled**
35
+ - **Long-Lived Access Token** (valid for 60 days)
36
+
37
+ ---
38
+
39
+ ## 🔐 Environment Variables
40
+
41
+ Create a `.env` file in your backend project:
42
+
43
+ ```env
44
+ INSTAGRAM_BASE_URL=https://graph.instagram.com
45
+ INSTAGRAM_ACCOUNT_ID=YOUR_INSTAGRAM_USER_ID
46
+ INSTAGRAM_ACCESS_TOKEN=YOUR_LONG_LIVED_ACCESS_TOKEN
47
+ ```
48
+
49
+ ### Important Notes
50
+
51
+ - ❌ Do NOT use short-lived tokens
52
+ - ❌ Do NOT wrap values in quotes
53
+ - ❌ Do NOT use Facebook Page ID
54
+ - ✅ Use Instagram **User ID** from `/me` endpoint
55
+
56
+ ---
57
+
58
+ ## 🚀 Usage (Express)
59
+
60
+ ### Basic Setup
61
+
62
+ ```js
63
+ import express from "express";
64
+ import dotenv from "dotenv";
65
+ import { instagramRoutes } from "@it_dhruv/delta-instagram-feed";
66
+
67
+ dotenv.config();
68
+
69
+ const app = express();
70
+
71
+ app.use("/api/instagram", instagramRoutes);
72
+
73
+ app.listen(2025, () => {
74
+ console.log("Server running on port 2025");
75
+ });
76
+ ```
77
+
78
+ ---
79
+
80
+ ## 🌐 API Endpoint
81
+
82
+ ### GET `/api/instagram/feed`
83
+
84
+ Returns a list of Instagram posts.
85
+
86
+ #### Example Response
87
+
88
+ ```json
89
+ [
90
+ {
91
+ "id": "17905934592164608",
92
+ "media_type": "IMAGE",
93
+ "media_url": "https://...",
94
+ "permalink": "https://www.instagram.com/p/..."
95
+ }
96
+ ]
97
+ ```
98
+
99
+ ### Supported Media Types
100
+
101
+ - `IMAGE`
102
+ - `VIDEO`
103
+ - `CAROUSEL_ALBUM`
104
+
105
+ ---
106
+
107
+ ## ⚡ Caching Behavior
108
+
109
+ - Instagram API is called **once every 3 hours**
110
+ - Subsequent requests return cached data
111
+ - Improves performance & avoids rate limits
112
+
113
+ > Cache duration is currently fixed at **3 hours**
114
+
115
+ ---
116
+
117
+ ## ❌ Error Handling
118
+
119
+ If something goes wrong, the API responds with:
120
+
121
+ ```json
122
+ {
123
+ "message": "Unable to fetch Instagram feed"
124
+ }
125
+ ```
126
+
127
+ ### Common Causes
128
+
129
+ - Expired or invalid access token
130
+ - Wrong Instagram User ID
131
+ - Missing API permissions
132
+ - App not in Live / Tester mode
133
+
134
+ Check backend logs for detailed error output.
135
+
136
+ ---
137
+
138
+ ## 🔎 Debug Tip
139
+
140
+ To verify your token manually:
141
+
142
+ ```
143
+ https://graph.instagram.com/me?access_token=YOUR_TOKEN
144
+ ```
145
+
146
+ If this fails, regenerate your **long-lived token**.
147
+
148
+ ---
149
+
150
+ ## 🧠 Security Best Practices
151
+
152
+ - Tokens are **never exposed to frontend**
153
+ - Always fetch Instagram data from your backend
154
+ - Safe for production usage
155
+
156
+ ---
157
+
158
+ ## 📁 Package Structure (Internal)
159
+
160
+ ```
161
+ instagram.routes.js → Express routes
162
+ instagram.controller.js → Request handling
163
+ instagram.services.js → Instagram API calls
164
+ instagram.util.js → Cache logic
165
+ instagram.types.js → Media constants
166
+ ```
167
+
168
+ ---
169
+
170
+ ## 🛠️ Roadmap (Planned)
171
+
172
+ - 🔁 Auto token refresh
173
+ - 📄 Pagination support
174
+ - ⚙️ Configurable cache duration
175
+ - 🔐 Optional API key middleware
176
+ - 📘 TypeScript support
177
+
178
+ ---
179
+
180
+ ## 🧑‍💻 Author
181
+
182
+ **Dhruv Itwala**
183
+ MERN Stack Developer
184
+
185
+ 📦 npm: `@it_dhruv/delta-instagram-feed`
186
+
187
+ ---
188
+
189
+ ## ⭐ Support
190
+
191
+ If this package helps you:
192
+
193
+ - ⭐ Star it on npm
194
+ - 🐛 Report issues
195
+ - 🚀 Suggest improvements
196
+
197
+ ---