PandaAPI 1.0.0__tar.gz → 1.0.2__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PandaAPI
3
- Version: 1.0.0
3
+ Version: 1.0.2
4
4
  Summary: Python utility hub by @ll_PANDA_BBY_ll
5
5
  Author: PANDA
6
6
  Author-email:
@@ -0,0 +1,60 @@
1
+ import requests
2
+ import json
3
+
4
+
5
+ def gemini(prompt: str) -> dict:
6
+ # gemini-2.0-flash free tier
7
+ url = (
8
+ "https://generativelanguage.googleapis.com/v1beta/models/"
9
+ "gemini-2.0-flash:generateContent"
10
+ "?key=AIzaSyBQaoUF-KWjPV_4ABtSN0DQ0RPkNeCh4tM"
11
+ )
12
+ payload = {"contents": [{"parts": [{"text": prompt}]}]}
13
+ try:
14
+ r = requests.post(
15
+ url,
16
+ headers={"Content-Type": "application/json"},
17
+ data=json.dumps(payload),
18
+ timeout=15,
19
+ )
20
+ if r.status_code == 200:
21
+ text = r.json()["candidates"][0]["content"]["parts"][0]["text"]
22
+ return {"result": text, "success": True}
23
+ return {"success": False, "error": r.text}
24
+ except Exception as e:
25
+ return {"success": False, "error": str(e)}
26
+
27
+
28
+ def chatgpt(prompt: str) -> dict:
29
+ try:
30
+ url = "https://api.intelligence.io.solutions/api/v1/chat/completions"
31
+ headers = {
32
+ "Authorization": "Bearer io-v2-eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJvd25lcl9pZCI6IjZjZWIxZTZkLWI4MjItNDJkMi05NjY3LTc3Nzk5OTRlNGI3YiIsImtleV9pZCI6IjhiNDVhYTk1LWM2OWUtNDI1OS1hMmQwLTI0MjFmNzYyM2JjZCJ9.dummy",
33
+ "Content-Type": "application/json",
34
+ }
35
+ # fallback to a working free provider
36
+ url = "https://api.openai.com/v1/chat/completions"
37
+ # use pollinations free API instead
38
+ r = requests.get(
39
+ f"https://text.pollinations.ai/{requests.utils.quote(prompt)}",
40
+ timeout=20,
41
+ )
42
+ if r.status_code == 200:
43
+ return {"result": r.text.strip(), "success": True}
44
+ return {"success": False, "error": f"Status {r.status_code}"}
45
+ except Exception as e:
46
+ return {"success": False, "error": str(e)}
47
+
48
+
49
+ def blackbox(prompt: str) -> dict:
50
+ # use pollinations with blackbox model
51
+ try:
52
+ r = requests.get(
53
+ f"https://text.pollinations.ai/{requests.utils.quote(prompt)}?model=blackboxai",
54
+ timeout=20,
55
+ )
56
+ if r.status_code == 200:
57
+ return {"result": r.text.strip(), "success": True}
58
+ return {"success": False, "error": f"Status {r.status_code}"}
59
+ except Exception as e:
60
+ return {"success": False, "error": str(e)}
@@ -0,0 +1,262 @@
1
+ import random
2
+ import string
3
+ import requests
4
+ from bs4 import BeautifulSoup
5
+ from ..func import MORSE_CODE_DICT
6
+
7
+
8
+ def password(length: int = 12) -> str:
9
+ chars = string.ascii_letters + string.punctuation + string.digits
10
+ return "".join(random.sample(chars, length))
11
+
12
+
13
+ def morse_encode(text: str) -> dict:
14
+ cipher = ""
15
+ for ch in text.upper():
16
+ if ch == " ":
17
+ cipher += " "
18
+ elif ch in MORSE_CODE_DICT:
19
+ cipher += MORSE_CODE_DICT[ch] + " "
20
+ return {"input": text, "result": cipher.strip(), "success": True}
21
+
22
+
23
+ def morse_decode(code: str) -> dict:
24
+ code += " "
25
+ decipher = ""
26
+ citext = ""
27
+ i = 0
28
+ for ch in code:
29
+ if ch != " ":
30
+ i = 0
31
+ citext += ch
32
+ else:
33
+ i += 1
34
+ if i == 2:
35
+ decipher += " "
36
+ else:
37
+ key = next(
38
+ (k for k, v in MORSE_CODE_DICT.items() if v == citext), "?"
39
+ )
40
+ decipher += key
41
+ citext = ""
42
+ return {"input": code.strip(), "result": decipher, "success": True}
43
+
44
+
45
+ def github(username: str) -> dict:
46
+ r = requests.get(f"https://api.github.com/users/{username}").json()
47
+ return {
48
+ "name": r.get("name"),
49
+ "username": r.get("login"),
50
+ "id": r.get("id"),
51
+ "bio": r.get("bio"),
52
+ "location": r.get("location"),
53
+ "repos": r.get("public_repos"),
54
+ "followers": r.get("followers"),
55
+ "following": r.get("following"),
56
+ "avatar": r.get("avatar_url"),
57
+ "url": r.get("html_url"),
58
+ "success": True,
59
+ }
60
+
61
+
62
+ def pypi(package: str) -> dict:
63
+ r = requests.get(f"https://pypi.org/pypi/{package}/json").json()
64
+ info = r.get("info", {})
65
+ return {
66
+ "name": info.get("name"),
67
+ "version": info.get("version"),
68
+ "summary": info.get("summary"),
69
+ "author": info.get("author"),
70
+ "license": info.get("license"),
71
+ "home_page": info.get("home_page"),
72
+ "success": True,
73
+ }
74
+
75
+
76
+ def hashtag(keyword: str) -> dict:
77
+ try:
78
+ # using ritetag API (no auth needed for basic)
79
+ url = f"https://ritetag.com/best-hashtags-for/{requests.utils.quote(keyword)}"
80
+ headers = {"User-Agent": "Mozilla/5.0"}
81
+ r = requests.get(url, headers=headers, timeout=10)
82
+ soup = BeautifulSoup(r.text, "html.parser")
83
+ tags = []
84
+ for el in soup.select(".hashtag-text, .tag, span.ht"):
85
+ t = el.text.strip()
86
+ if t.startswith("#"):
87
+ tags.append(t)
88
+ if not tags:
89
+ # fallback: generate basic hashtags
90
+ words = keyword.lower().split()
91
+ tags = [
92
+ f"#{keyword.replace(' ', '')}",
93
+ f"#{keyword.replace(' ', '_')}",
94
+ ] + [f"#{w}" for w in words]
95
+ return {"input": keyword, "results": tags[:20], "success": True}
96
+ except Exception as e:
97
+ return {"success": False, "error": str(e)}
98
+
99
+
100
+ def chatbot(text: str) -> dict:
101
+ try:
102
+ r = requests.get(
103
+ f"https://text.pollinations.ai/{requests.utils.quote(text)}",
104
+ timeout=20,
105
+ )
106
+ if r.status_code == 200:
107
+ return {"result": r.text.strip(), "success": True}
108
+ return {"success": False, "error": f"Status {r.status_code}"}
109
+ except Exception as e:
110
+ return {"success": False, "error": str(e)}
111
+
112
+
113
+ def meme() -> dict:
114
+ try:
115
+ r = requests.get("https://meme-api.com/gimme", timeout=10).json()
116
+ return {
117
+ "title": r.get("title"),
118
+ "url": r.get("url"),
119
+ "subreddit": r.get("subreddit"),
120
+ "author": r.get("author"),
121
+ "success": True,
122
+ }
123
+ except Exception as e:
124
+ return {"success": False, "error": str(e)}
125
+
126
+
127
+ def unsplash(query: str) -> dict:
128
+ try:
129
+ url = f"https://source.unsplash.com/featured/?{requests.utils.quote(query)}"
130
+ r = requests.get(url, timeout=10, allow_redirects=True)
131
+ # unsplash source redirects to actual image
132
+ final_url = r.url
133
+ # also fetch a few via scraping picsum/unsplash search
134
+ search_url = f"https://unsplash.com/s/photos/{requests.utils.quote(query)}"
135
+ headers = {"User-Agent": "Mozilla/5.0"}
136
+ rs = requests.get(search_url, headers=headers, timeout=10)
137
+ soup = BeautifulSoup(rs.text, "html.parser")
138
+ imgs = []
139
+ for img in soup.find_all("img"):
140
+ src = img.get("src", "")
141
+ if "images.unsplash.com" in src:
142
+ imgs.append(src)
143
+ if len(imgs) >= 10:
144
+ break
145
+ if not imgs:
146
+ imgs = [final_url]
147
+ return {"results": imgs, "success": True}
148
+ except Exception as e:
149
+ return {"success": False, "error": str(e)}
150
+
151
+
152
+ def imdb(query: str) -> dict:
153
+ try:
154
+ headers = {
155
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
156
+ "Accept-Language": "en-US,en;q=0.9",
157
+ }
158
+ # use OMDB-style scrape via IMDB search JSON endpoint
159
+ search_url = f"https://v2.sg.media-imdb.com/suggestion/x/{requests.utils.quote(query)}.json"
160
+ r = requests.get(search_url, headers=headers, timeout=10)
161
+ data = r.json()
162
+ results = data.get("d", [])
163
+ if not results:
164
+ return {"success": False, "error": "No results"}
165
+ top = results[0]
166
+ imdb_id = top.get("id", "")
167
+ title = top.get("l", "")
168
+ year = top.get("y", "")
169
+ image = top.get("i", {}).get("imageUrl", "") if isinstance(top.get("i"), dict) else ""
170
+ rank = top.get("rank", "")
171
+ # fetch detail page for more info
172
+ detail_url = f"https://www.imdb.com/title/{imdb_id}/"
173
+ rd = requests.get(detail_url, headers=headers, timeout=10)
174
+ soup = BeautifulSoup(rd.text, "html.parser")
175
+ import json as _json
176
+ description = ""
177
+ genre = []
178
+ actors = []
179
+ rating = ""
180
+ script = soup.find("script", type="application/ld+json")
181
+ if script:
182
+ ld = _json.loads(script.string)
183
+ description = ld.get("description", "")
184
+ genre = ld.get("genre", [])
185
+ actors = [a["name"] for a in ld.get("actor", [])]
186
+ rating = ld.get("aggregateRating", {}).get("ratingValue", "")
187
+ return {
188
+ "name": title,
189
+ "year": year,
190
+ "imdb_id": imdb_id,
191
+ "image": image,
192
+ "url": detail_url,
193
+ "description": description,
194
+ "genre": genre,
195
+ "actors": actors,
196
+ "rating": rating,
197
+ "success": True,
198
+ }
199
+ except Exception as e:
200
+ return {"success": False, "error": str(e)}
201
+
202
+
203
+ def leetcode(username: str) -> dict:
204
+ url = "https://leetcode.com/graphql/"
205
+ q2 = {
206
+ "operationName": "userPublicProfile",
207
+ "query": """
208
+ query userPublicProfile($username: String!) {
209
+ matchedUser(username: $username) {
210
+ username
211
+ githubUrl
212
+ twitterUrl
213
+ linkedinUrl
214
+ submitStats {
215
+ acSubmissionNum {
216
+ difficulty
217
+ count
218
+ }
219
+ }
220
+ profile {
221
+ ranking
222
+ userAvatar
223
+ realName
224
+ countryName
225
+ company
226
+ jobTitle
227
+ skillTags
228
+ }
229
+ }
230
+ }""",
231
+ "variables": {"username": username},
232
+ }
233
+ try:
234
+ headers = {"Content-Type": "application/json", "Referer": "https://leetcode.com"}
235
+ r2 = requests.post(url, json=q2, headers=headers, timeout=10).json()
236
+ user = r2.get("data", {}).get("matchedUser")
237
+ if not user:
238
+ return {"success": False, "error": "User not found"}
239
+ return {**user, "success": True}
240
+ except Exception as e:
241
+ return {"success": False, "error": str(e)}
242
+
243
+
244
+ def bhagwatgita(chapter: int, shalok: int = 1) -> dict:
245
+ try:
246
+ # use bhagavad-gita.org API
247
+ url = f"https://bhagavad-gita3.p.rapidapi.com/v2/chapters/{chapter}/verses/{shalok}/"
248
+ # fallback to free API
249
+ url = f"https://vedicscriptures.github.io/slok/{chapter}/{shalok}/"
250
+ r = requests.get(url, timeout=10)
251
+ data = r.json()
252
+ return {
253
+ "chapter": chapter,
254
+ "shloka": shalok,
255
+ "slok": data.get("slok", ""),
256
+ "transliteration": data.get("transliteration", ""),
257
+ "hindi": data.get("tej", {}).get("ht", ""),
258
+ "english": data.get("siva", {}).get("et", ""),
259
+ "success": True,
260
+ }
261
+ except Exception as e:
262
+ return {"success": False, "error": str(e)}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PandaAPI
3
- Version: 1.0.0
3
+ Version: 1.0.2
4
4
  Summary: Python utility hub by @ll_PANDA_BBY_ll
5
5
  Author: PANDA
6
6
  Author-email:
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "PandaAPI"
7
- version = "1.0.0"
7
+ version = "1.0.2"
8
8
  authors = [
9
9
  { name = "PANDA" }
10
10
  ]
@@ -1,59 +0,0 @@
1
- import requests
2
- import json
3
-
4
-
5
- def gemini(prompt: str) -> dict:
6
- url = (
7
- "https://generativelanguage.googleapis.com/v1beta/models/"
8
- "gemini-pro:generateContent"
9
- "?key=AIzaSyBQaoUF-KWjPV_4ABtSN0DQ0RPkNeCh4tM"
10
- )
11
- payload = {"contents": [{"parts": [{"text": prompt}]}]}
12
- try:
13
- r = requests.post(url, headers={"Content-Type": "application/json"},
14
- data=json.dumps(payload))
15
- if r.status_code == 200:
16
- text = r.json()["candidates"][0]["content"]["parts"][0]["text"]
17
- return {"result": text, "success": True}
18
- return {"success": False, "error": r.text}
19
- except Exception as e:
20
- return {"success": False, "error": str(e)}
21
-
22
-
23
- def chatgpt(prompt: str) -> dict:
24
- """Uses free exh.ai endpoint (same as BadAPI)."""
25
- try:
26
- url = "https://api.exh.ai/chatbot/v1/get_response"
27
- headers = {
28
- "Authorization": (
29
- "Bearer eyJhbGciOiJIUzUxMiJ9"
30
- ".eyJ1c2VybmFtZSI6ImJvdGlmeS13ZWItdjMifQ"
31
- ".O-w89I5aX2OE_i4k6jdHZJEDWECSUfOb1lr9UdVH4oT"
32
- "PMkFGUNm9BNzoQjcXOu8NEiIXq64-481hnenHdUrXfg"
33
- ),
34
- "Content-Type": "application/json",
35
- }
36
- payload = {
37
- "messages": [{"role": "user", "content": prompt}],
38
- "model": "gpt-3.5-turbo",
39
- }
40
- r = requests.post(url, headers=headers, data=json.dumps(payload))
41
- return {"result": r.json().get("response", ""), "success": True}
42
- except Exception as e:
43
- return {"success": False, "error": str(e)}
44
-
45
-
46
- def blackbox(prompt: str) -> dict:
47
- try:
48
- url = "https://www.blackbox.ai/api/chat"
49
- headers = {"Content-Type": "application/json"}
50
- payload = {
51
- "messages": [{"role": "user", "content": prompt}],
52
- "agentMode": {},
53
- "trendingAgentMode": {},
54
- "isMicMode": False,
55
- }
56
- r = requests.post(url, headers=headers, json=payload)
57
- return {"result": r.text, "success": True}
58
- except Exception as e:
59
- return {"success": False, "error": str(e)}
@@ -1,248 +0,0 @@
1
- import random
2
- import string
3
- import re
4
- import requests
5
- from bs4 import BeautifulSoup
6
- from requests_html import HTMLSession
7
- from ..func import MORSE_CODE_DICT
8
-
9
-
10
- def password(length: int = 12) -> str:
11
- chars = string.ascii_letters + string.punctuation + string.digits
12
- return "".join(random.sample(chars, length))
13
-
14
-
15
- def morse_encode(text: str) -> dict:
16
- cipher = ""
17
- for ch in text.upper():
18
- if ch == " ":
19
- cipher += " "
20
- elif ch in MORSE_CODE_DICT:
21
- cipher += MORSE_CODE_DICT[ch] + " "
22
- return {"input": text, "result": cipher.strip(), "success": True}
23
-
24
-
25
- def morse_decode(code: str) -> dict:
26
- code += " "
27
- decipher = ""
28
- citext = ""
29
- i = 0
30
- for ch in code:
31
- if ch != " ":
32
- i = 0
33
- citext += ch
34
- else:
35
- i += 1
36
- if i == 2:
37
- decipher += " "
38
- else:
39
- key = next(
40
- (k for k, v in MORSE_CODE_DICT.items() if v == citext), "?"
41
- )
42
- decipher += key
43
- citext = ""
44
- return {"input": code.strip(), "result": decipher, "success": True}
45
-
46
-
47
- def github(username: str) -> dict:
48
- r = requests.get(f"https://api.github.com/users/{username}").json()
49
- return {
50
- "name": r.get("name"),
51
- "username": r.get("login"),
52
- "id": r.get("id"),
53
- "bio": r.get("bio"),
54
- "location": r.get("location"),
55
- "repos": r.get("public_repos"),
56
- "followers": r.get("followers"),
57
- "following": r.get("following"),
58
- "avatar": r.get("avatar_url"),
59
- "url": r.get("html_url"),
60
- "success": True,
61
- }
62
-
63
-
64
- def pypi(package: str) -> dict:
65
- r = requests.get(f"https://pypi.org/pypi/{package}/json").json()
66
- info = r.get("info", {})
67
- return {
68
- "name": info.get("name"),
69
- "version": info.get("version"),
70
- "summary": info.get("summary"),
71
- "author": info.get("author"),
72
- "license": info.get("license"),
73
- "home_page": info.get("home_page"),
74
- "success": True,
75
- }
76
-
77
-
78
- def hashtag(keyword: str) -> dict:
79
- url = "https://all-hashtag.com/library/contents/ajax_generator.php"
80
- data = {"keyword": keyword, "filter": "top"}
81
- response = requests.post(url, data=data).text
82
- soup = BeautifulSoup(response, "html.parser")
83
- div = soup.find("div", {"class": "copy-hashtags"})
84
- if not div:
85
- return {"success": False, "error": "No hashtags found"}
86
- tags = div.string.split()
87
- return {"input": keyword, "results": tags, "success": True}
88
-
89
-
90
- def chatbot(text: str) -> dict:
91
- try:
92
- url = (
93
- "https://fallenxbot.vercel.app/api"
94
- f"?apikey=593560829-fallen-usbk33kbsu"
95
- f"&group-controller/mukesh/message={text}"
96
- )
97
- r = requests.get(url).json()
98
- return {"result": r.get("reply", ""), "success": True}
99
- except Exception as e:
100
- return {"success": False, "error": str(e)}
101
-
102
-
103
- def meme() -> dict:
104
- try:
105
- r = requests.get("https://meme-api.com/gimme").json()
106
- return {
107
- "title": r.get("title"),
108
- "url": r.get("url"),
109
- "subreddit": r.get("subreddit"),
110
- "author": r.get("author"),
111
- "success": True,
112
- }
113
- except Exception as e:
114
- return {"success": False, "error": str(e)}
115
-
116
-
117
- def unsplash(query: str) -> dict:
118
- url = (
119
- f"https://www.istockphoto.com/search/2/image"
120
- f"?alloweduse=availableforalluses&phrase={query}&sort=best"
121
- )
122
- headers = {
123
- "User-Agent": (
124
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
125
- "AppleWebKit/537.36 (KHTML, like Gecko) "
126
- "Chrome/121.0.0.0 Safari/537.36"
127
- ),
128
- "Accept-Language": "en-US,en;q=0.9",
129
- "Referer": "https://unsplash.com/",
130
- }
131
- r = requests.get(url, headers=headers)
132
- if r.status_code != 200:
133
- return {"success": False, "error": f"Status {r.status_code}"}
134
- soup = BeautifulSoup(r.content, "html.parser")
135
- imgs = [
136
- img["src"]
137
- for img in soup.find_all("img")
138
- if img.get("src", "").startswith("https://media.istockphoto.com")
139
- ]
140
- return {"results": imgs, "success": True}
141
-
142
-
143
- def imdb(query: str) -> dict:
144
- try:
145
- session = HTMLSession()
146
- r = session.get(f"https://www.imdb.com/find?q={query}")
147
- results = r.html.xpath(
148
- "//section[@data-testid='find-results-section-title']/div/ul/li"
149
- )
150
- if not results:
151
- return {"success": False, "error": "No results"}
152
- first_url = results[0].find("a")[0].attrs["href"]
153
- headers = {
154
- "User-Agent": (
155
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
156
- "AppleWebKit/537.36"
157
- )
158
- }
159
- page = requests.get(f"https://www.imdb.com/{first_url}", headers=headers)
160
- soup = BeautifulSoup(page.text, "html.parser")
161
- import json as _json
162
- ld = _json.loads(soup.find("script", type="application/ld+json").string)
163
- return {
164
- "name": soup.title.text.strip(),
165
- "url": ld.get("url"),
166
- "image": ld.get("image"),
167
- "description": ld.get("description"),
168
- "genre": ld.get("genre"),
169
- "actors": [a["name"] for a in ld.get("actor", [])],
170
- "review": ld.get("review", {}).get("reviewBody"),
171
- "rating": ld.get("review", {}).get("reviewRating", {}).get("ratingValue"),
172
- "trailer": ld.get("trailer"),
173
- "success": True,
174
- }
175
- except Exception as e:
176
- return {"success": False, "error": str(e)}
177
-
178
-
179
- def leetcode(username: str) -> dict:
180
- url = "https://leetcode.com/graphql/"
181
- q1 = {
182
- "operationName": "userProfileCalendar",
183
- "query": """
184
- query userProfileCalendar($username: String!, $year: Int) {
185
- matchedUser(username: $username) {
186
- userCalendar(year: $year) {
187
- streak
188
- totalActiveDays
189
- activeYears
190
- }
191
- }
192
- }""",
193
- "variables": {"username": username, "year": 2024},
194
- }
195
- q2 = {
196
- "operationName": "userPublicProfile",
197
- "query": """
198
- query userPublicProfile($username: String!) {
199
- matchedUser(username: $username) {
200
- username
201
- githubUrl
202
- twitterUrl
203
- linkedinUrl
204
- profile {
205
- ranking
206
- userAvatar
207
- realName
208
- countryName
209
- company
210
- jobTitle
211
- skillTags
212
- }
213
- }
214
- }""",
215
- "variables": {"username": username},
216
- }
217
- try:
218
- r1 = requests.post(url, json=q1).json()
219
- r2 = requests.post(url, json=q2).json()
220
- d1 = r1["data"]["matchedUser"]
221
- d2 = r2["data"]["matchedUser"]
222
- return {**d1, **d2, "success": True}
223
- except Exception as e:
224
- return {"success": False, "error": str(e)}
225
-
226
-
227
- def bhagwatgita(chapter: int, shalok: int = 1) -> dict:
228
- try:
229
- url = f"https://www.holy-bhagavad-gita.org/chapter/{chapter}/hi"
230
- r = requests.get(url)
231
- soup = BeautifulSoup(r.text, "html.parser")
232
- intro_div = soup.find("div", class_="chapterIntro")
233
- verses = soup.find_all("section", class_="listItem")
234
- texts = [
235
- v.text.strip()
236
- .replace("View commentary »", "")
237
- .replace("Bhagavad Gita ", "")
238
- .strip()
239
- for v in verses
240
- ]
241
- return {
242
- "chapter": chapter,
243
- "chapter_intro": intro_div.text if intro_div else "",
244
- "shalok": texts[shalok] if shalok < len(texts) else "",
245
- "success": True,
246
- }
247
- except Exception as e:
248
- return {"success": False, "error": str(e)}
File without changes
File without changes
File without changes
File without changes
File without changes