@jerrycoder/instagram-api 2.5.5 โ†’ 2.5.6

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 (4) hide show
  1. package/README.md +12 -2
  2. package/index.js +27 -7
  3. package/index.mjs +27 -7
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -103,12 +103,22 @@ Depends on external API availability
103
103
  โ€ข ๐Ÿงฉ Works with CommonJS & ESM
104
104
 
105
105
 
106
+ ## ๐Ÿ” Security
107
+
108
+ This package makes HTTP requests to:
109
+ https://jerrycoder.oggyapi.workers.dev
110
+
111
+ - No personal data is collected
112
+ - No tracking is performed
113
+ - Open for inspection
114
+
115
+
106
116
  ## ๐Ÿงช Status
107
117
 
108
118
  ยฐ โœ… Fully Tested on Node.js & Vercel
109
119
 
110
- ยฐ ๐Ÿš€ Version: 2.5.5 (Latest)
120
+ ยฐ ๐Ÿš€ Version: 2.5.6 (Latest)
111
121
 
112
122
 
113
123
  ## ๐Ÿ“„ License
114
- MIT License ยฉ JerryCoder
124
+ MIT License ยฉ JerryCoder
package/index.js CHANGED
@@ -1,16 +1,36 @@
1
1
  const axios = require("axios");
2
2
 
3
- async function instagram(url) {
3
+ const DEFAULT_API = "https://jerrycoder.oggyapi.workers.dev";
4
+
5
+ async function instagram(url, options = {}) {
4
6
  if (!url) throw new Error("URL is required");
5
7
 
6
- const apiUrl = `https://jerrycoder.oggyapi.workers.dev/insta?url=${encodeURIComponent(url)}`;
7
- const { data } = await axios.get(apiUrl);
8
+ const apiBase = options.api || DEFAULT_API;
9
+ const timeout = options.timeout || 10000;
8
10
 
9
- if (data.status !== "success") {
10
- throw new Error("Failed to fetch data");
11
- }
11
+ const apiUrl = `${apiBase}/insta?url=${encodeURIComponent(url)}`;
12
+
13
+ try {
14
+ const response = await axios.get(apiUrl, {
15
+ timeout,
16
+ headers: {
17
+ "User-Agent": "jerrycoder-instagram-api/2.5.5",
18
+ "Accept": "application/json"
19
+ },
20
+ validateStatus: (status) => status < 500
21
+ });
22
+
23
+ const data = response.data;
12
24
 
13
- return data.data;
25
+ if (!data || data.status !== "success") {
26
+ throw new Error(data?.message || "Failed to fetch data");
27
+ }
28
+
29
+ return data.data;
30
+
31
+ } catch (err) {
32
+ throw new Error(`API request failed: ${err.message}`);
33
+ }
14
34
  }
15
35
 
16
36
  module.exports = {
package/index.mjs CHANGED
@@ -1,16 +1,36 @@
1
1
  import axios from "axios";
2
2
 
3
- export async function instagram(url) {
3
+ const DEFAULT_API = "https://jerrycoder.oggyapi.workers.dev";
4
+
5
+ export async function instagram(url, options = {}) {
4
6
  if (!url) throw new Error("URL is required");
5
7
 
6
- const apiUrl = `https://jerrycoder.oggyapi.workers.dev/insta?url=${encodeURIComponent(url)}`;
7
- const { data } = await axios.get(apiUrl);
8
+ const apiBase = options.api || DEFAULT_API;
9
+ const timeout = options.timeout || 10000;
8
10
 
9
- if (data.status !== "success") {
10
- throw new Error("Failed to fetch data");
11
- }
11
+ const apiUrl = `${apiBase}/insta?url=${encodeURIComponent(url)}`;
12
+
13
+ try {
14
+ const response = await axios.get(apiUrl, {
15
+ timeout,
16
+ headers: {
17
+ "User-Agent": "jerrycoder-instagram-api/2.5.5",
18
+ "Accept": "application/json"
19
+ },
20
+ validateStatus: (status) => status < 500 // prevent throwing on 4xx
21
+ });
22
+
23
+ const data = response.data;
12
24
 
13
- return data.data;
25
+ if (!data || data.status !== "success") {
26
+ throw new Error(data?.message || "Failed to fetch data");
27
+ }
28
+
29
+ return data.data;
30
+
31
+ } catch (err) {
32
+ throw new Error(`API request failed: ${err.message}`);
33
+ }
14
34
  }
15
35
 
16
36
  export default {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jerrycoder/instagram-api",
3
- "version": "2.5.5",
3
+ "version": "2.5.6",
4
4
  "description": "Unofficial Instagram Downloader API โ€” fetch Reels, Posts, Stories using JerryCoder API.",
5
5
  "main": "index.js",
6
6
  "author": "JerryCoder",