-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples.py
More file actions
301 lines (227 loc) · 7.39 KB
/
examples.py
File metadata and controls
301 lines (227 loc) · 7.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
"""
examples.py - Usage examples for Discard Rest APIs Python SDK
"""
from discard import DiscardAPI
# Initialize the SDK
api = DiscardAPI(api_key="your_api_key_here")
# ===== ISLAMIC API EXAMPLES =====
def islamic_examples():
# Get Quran Surah
surah = api.islam.quran_surah("yaseen")
print(surah)
# Get Prayer Timings
prayer = api.islam.prayer_timing("jakarta")
print(prayer)
# Get Hadith
hadith = api.islam.hadit("muslim", "1")
print(hadith)
# ===== AI API EXAMPLES =====
def ai_examples():
# Use Gemini Pro
response = api.ai.gemini_pro("What is artificial intelligence?")
print(response)
# Generate image with Stable Diffusion
image = api.ai.stable_diffusion("A beautiful sunset over mountains")
print(image)
# Use Llama AI
answer = api.ai.llama_ai("Explain quantum computing")
print(answer)
# ===== DOWNLOADS EXAMPLES =====
def download_examples():
# Download Instagram post
insta = api.downloads.instagram("https://www.instagram.com/p/example")
print(insta)
# Download TikTok video
tiktok = api.downloads.tiktok("https://vm.tiktok.com/example")
print(tiktok)
# Download YouTube video
youtube = api.downloads.youtube_video("https://youtube.com/watch?v=example", format="720")
print(youtube)
# Search Pinterest images
pinterest = api.downloads.pinterest_search("nature")
print(pinterest)
# ===== TOOLS EXAMPLES =====
def tools_examples():
# Translate text
translation = api.tools.translate("Hello world", "es")
print(translation)
# Generate QR code
qr = api.imagemakers.qrcode("https://example.com")
print(qr)
# Solve math expression
result = api.tools.mathematics("2+2*2")
print(result)
# Get website screenshot
screenshot = api.tools.screenshot("https://github.com")
print(screenshot)
# Detect language
lang = api.tools.detect_lang("Bonjour le monde")
print(lang)
# ===== SEARCH EXAMPLES =====
def search_examples():
# Google search
results = api.search.google_search("Python programming")
print(results)
# Search YouTube
videos = api.search.youtube_search("coding tutorial")
print(videos)
# Search movies
movies = api.search.movies_search("Inception")
print(movies)
# ===== NEWS EXAMPLES =====
def news_examples():
# Get CNN news
cnn = api.news.cnn_news()
print(cnn)
# Get specific article
article = api.news.cnn_article("https://cnn.com/article/example")
print(article)
# Get Sky Sports news
sports = api.news.sky_sports("cricket")
print(sports)
# ===== STALKER EXAMPLES =====
def stalker_examples():
# Stalk GitHub user
github = api.stalker.github_stalk("GlobalTechInfo")
print(github)
# Stalk Instagram user
insta = api.stalker.instagram_stalk("username")
print(insta)
# Get NPM package info
npm = api.stalker.npm_stalk("axios")
print(npm)
# ===== IMAGE PROCESSING EXAMPLES =====
def image_processing_examples():
# Remove background from image
with open("image.jpg", "rb") as f:
result = api.imageprocess.remove_bg(f)
print(result)
# Convert to grayscale
with open("image.jpg", "rb") as f:
gray = api.imageprocess.grayscale(f)
print(gray)
# Resize image
with open("image.jpg", "rb") as f:
resized = api.imageprocess.resize(f, "800", "600")
print(resized)
# Apply cartoon effect
with open("image.jpg", "rb") as f:
cartoon = api.imageprocess.cartoon(f)
print(cartoon)
# ===== UPLOADS EXAMPLES =====
def upload_examples():
# Upload to Catbox
with open("file.pdf", "rb") as f:
catbox = api.uploads.catbox(f)
print(catbox)
# Upload to ImgBB
with open("image.png", "rb") as f:
imgbb = api.uploads.imgbb(f)
print(imgbb)
# ===== TEMPMAIL EXAMPLES =====
def tempmail_examples():
# Create temporary email
mail = api.tempmail.create_mail("password123")
print(f"Email: {mail}")
# Check inbox (using token from create_mail response)
# inbox = api.tempmail.mail_inbox(token="your_token")
# print(inbox)
# ===== MUSIC EXAMPLES =====
def music_examples():
# Search Spotify
spotify = api.music.spotify_search("Bohemian Rhapsody")
print(spotify)
# Get song lyrics
lyrics = api.music.lyrics("never gonna give you up")
print(lyrics)
# Search SoundCloud
soundcloud = api.music.soundcloud_search("remix")
print(soundcloud)
# ===== MEMES EXAMPLES =====
def memes_examples():
# Create Drake meme
drake = api.memes.drake_hotline("Python", "Go")
print(drake)
# Create Success Kid meme
success = api.memes.success_kid("First learning Go", "Then i will learn Rust")
print(success)
# Get trending memes
trending = api.memes.trending_memes()
print(trending)
# ===== INFORMATION EXAMPLES =====
def information_examples():
# Get weather info
weather = api.information.weather_city("London")
print(weather)
# Get country info
country = api.information.country_info("Japan")
print(country)
# Get IP info
ip_info = api.information.ip_info("8.8.8.8")
print(ip_info)
# Search Wikipedia
wiki = api.information.wikipedia("Quantum Computing")
print(wiki)
# ===== TIME EXAMPLES =====
def time_examples():
# Get time by timezone
time = api.time.time_by_zone("Asia/Karachi")
print(time)
# Convert time between timezones
converted = api.time.time_convert("Asia/Karachi", "America/New_York", "2021-03-14 14:27:00")
print(converted)
# Get day of week
day = api.time.day_of_week("2021-03-14")
print(day)
# ===== CONTEXT MANAGER USAGE =====
def context_manager_example():
# Using with statement (automatically closes session)
with DiscardAPI(api_key="your_api_key_here") as api:
result = api.jokes.dad()
print(result)
# ===== ERROR HANDLING =====
def error_handling_example():
try:
api = DiscardAPI(api_key="your_api_key_here")
result = api.downloads.instagram("invalid_url")
print(result)
except Exception as e:
print(f"Error: {e}")
# ===== ADVANCED CONFIGURATION =====
def advanced_config():
# Custom configuration
api = DiscardAPI(
api_key="your_api_key_here",
base_url="https://discardapi.dpdns.org", # Custom base URL
full_response=True, # Get full API response
timeout=60 # Custom timeout
)
# Get full response
response = api.jokes.random()
print(f"Creator: {response.creator}")
print(f"Status: {response.status}")
print(f"Result: {response.result}")
# Change settings dynamically
api.client.set_full_response(False)
api.client.set_timeout(30)
if __name__ == "__main__":
# Run examples
print("=== Islamic API Examples ===")
islamic_examples()
print("\n=== AI API Examples ===")
ai_examples()
print("\n=== Tools Examples ===")
tools_examples()
print("\n=== Downloads Examples ===")
download_examples()
# Uncomment to run other examples
# search_examples()
# news_examples()
# stalker_examples()
# image_processing_examples()
# upload_examples()
# tempmail_examples()
# music_examples()
# memes_examples()
# information_examples()
# time_examples()