Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/galloclaudio/mega-search-links/llms.txt

Use this file to discover all available pages before exploring further.

This guide will walk you through making your first API call with Mega Search Links to retrieve URLs from Meawfy’s internal API.
1

Import the library

First, import the URLFetcher class from the main module:
from main import URLFetcher
2

Configure the API settings

Set up the base URL and user-agent for your requests:
# Base URL of the Meawfy API
base_url = "https://meawfy.com/internal/api/results.json"

# Custom user-agent string
user_agent = "MyCustomUserAgent/1.0"
You can customize the user-agent string to identify your application. This is useful for tracking API usage and debugging.
3

Initialize the URLFetcher

Create an instance of the URLFetcher class:
url_fetcher = URLFetcher(base_url, user_agent)
4

Fetch URLs with a search query

Call the fetch_urls() method with your search query:
search_query = "example_query"
urls = url_fetcher.fetch_urls(search_query)
Replace "example_query" with your actual search term (e.g., “python tutorials”, “machine learning”, etc.)
5

Process the results

Handle the returned URLs:
if urls:
    print("Retrieved URLs:")
    for url in urls:
        print(url)
else:
    print("No URLs found or an error occurred.")

Complete Example

Here’s a complete working example that puts it all together:
import requests
from main import URLFetcher

def main():
    # Base URL of the API
    base_url = "https://meawfy.com/internal/api/results.json"
    
    # User-agent string
    user_agent = "MyCustomUserAgent/1.0"
    
    # Initialize the URLFetcher with the base URL and user-agent
    url_fetcher = URLFetcher(base_url, user_agent)
    
    # Example search query
    search_query = "example_query"
    
    # Fetch URLs based on the search query
    urls = url_fetcher.fetch_urls(search_query)
    
    # Display the retrieved URLs
    if urls:
        print("Retrieved URLs:")
        for url in urls:
            print(url)
    else:
        print("No URLs found or an error occurred.")

if __name__ == "__main__":
    main()

Understanding the Response

The fetch_urls() method returns a list of URLs:
  • Success: Returns a list of URL strings (can be empty if no results found)
  • Error: Returns an empty list and prints an error message to the console
The API returns results in JSON format with a urls key containing the array of URLs. The library automatically extracts this for you.

Error Handling

The library includes built-in error handling for common issues:
try:
    urls = url_fetcher.fetch_urls(search_query)
    if urls:
        print(f"Found {len(urls)} URLs")
    else:
        print("No results found")
except Exception as e:
    print(f"Unexpected error: {e}")
The fetch_urls() method catches requests.exceptions.RequestException internally and returns an empty list on error. Check the console output for error details.

Common Use Cases

Batch Processing Multiple Queries

queries = ["python tutorials", "machine learning", "web development"]

for query in queries:
    print(f"\nSearching for: {query}")
    urls = url_fetcher.fetch_urls(query)
    print(f"Found {len(urls)} URLs")

Filtering Results

urls = url_fetcher.fetch_urls("data science")

# Filter for specific domains
mega_urls = [url for url in urls if "mega.nz" in url]
print(f"Found {len(mega_urls)} Mega.nz links")

Best Practices

Use descriptive user-agent strings: Include your application name and version to help identify your requests.
Handle empty results gracefully: Always check if the returned list is empty before processing.
Respect rate limits: If making multiple requests, consider adding delays between calls to avoid overwhelming the API.

Next Steps

Now that you’ve made your first successful search, explore more advanced features:

API Reference

Detailed documentation of all classes and methods

Advanced Guides

Learn advanced techniques and best practices