Skip to content

API Reference#

APKCombo #

This class provides methods to search for an APK on APKCombo based on package name, and to find available versions and their download links for a given APK link.

Parameters:

Name Type Description Default
pkg_name str

The package name of the APK to search for.

required

Attributes:

Name Type Description
pkg_name str

The package name of the APK to search for.

base_url str

The base URL of the APKCombo website.

search_url str

The URL used to search for APKs on APKCombo.

headers dict

The headers used for making HTTP requests.

session Session

The session object used for making HTTP requests.

Methods:

Name Description
search_apk

Searches for the APK on APKCombo and returns the title and link if found.

find_versions

str) -> list[tuple[str, str]]: Finds and returns a list of versions and their download links for the given APK link.

Source code in apksearch/sites/apkcombo.py
class APKCombo:
    """
    This class provides methods to search for an APK on APKCombo based on package name,
    and to find available versions and their download links for a given APK link.

    Parameters:
        pkg_name (str): The package name of the APK to search for.

    Attributes:
        pkg_name (str): The package name of the APK to search for.
        base_url (str): The base URL of the APKCombo website.
        search_url (str): The URL used to search for APKs on APKCombo.
        headers (dict): The headers used for making HTTP requests.
        session (requests.Session): The session object used for making HTTP requests.

    Methods:
        search_apk() -> None | tuple[str, str]:
            Searches for the APK on APKCombo and returns the title and link if found.

        find_versions(apk_link: str) -> list[tuple[str, str]]:
            Finds and returns a list of versions and their download links for the given APK link.
    """

    def __init__(self, pkg_name: str):
        self.pkg_name = pkg_name
        self.base_url = "https://apkcombo.com"
        self.search_url = self.base_url + "/search"
        self.headers = {
            "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
            "accept-language": "en-US,en;q=0.9,en-IN;q=0.8",
            "cache-control": "no-cache",
            "cookie": "__apkcombo_lang=en",
            "dnt": "1",
            "pragma": "no-cache",
            "priority": "u=0, i",
            "referer": "https://apkcombo.com/",
            "sec-ch-ua": '"Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24"',
            "sec-ch-ua-mobile": "?0",
            "sec-ch-ua-platform": '"Windows"',
            "sec-fetch-dest": "document",
            "sec-fetch-mode": "navigate",
            "sec-fetch-site": "same-origin",
            "sec-fetch-user": "?1",
            "upgrade-insecure-requests": "1",
            "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0",
        }
        self.session = requests.Session()

    def search_apk(self) -> None | tuple[str, str]:
        """
        Searches for the APK on APKCombo and returns the title and link if found.

        Returns:
            None: If no matching APK is found.
            tuple[str, str]: A tuple containing the title and link of the matching APK if found.
        """
        pkg_name = self.pkg_name
        url = self.search_url + "/" + pkg_name
        response: requests.Response = self.session.get(
            url, headers=self.headers, allow_redirects=False
        )
        # Redirect to the APK page if there's only one result. i.e, apk found.
        if response.status_code == 302:
            url = self.search_url + response.headers["Location"]
            response: requests.Response = self.session.get(url, headers=self.headers)
        elif response.status_code == 200:  # Package name not found or multiple results.
            return None
        else:
            raise Exception(f"Error: {response.status_code}")
        soup = BeautifulSoup(response.text, "html.parser")
        try:
            title = soup.find("div", {"class": "app_name"}).text.strip()
        except AttributeError:
            return None
        apk_link = url
        return title, apk_link

    def find_versions(self, apk_link: str) -> list[tuple[str, str]]:
        """
        Finds and returns a list of versions and their download links for the given APK link.

        Parameters:
            apk_link (str): The link to the APK on the APKCombo website.

        Returns:
            list[tuple[str, str]]: A list of tuples, where each tuple contains the version number
            and its corresponding download link. If no versions are found, an empty list is returned.
        """
        url = apk_link + "/old-versions"
        response: requests.Response = self.session.get(url, headers=self.headers)
        soup = BeautifulSoup(response.text, "html.parser")
        versions_list = soup.find("ul", {"class": "list-versions"})
        versions_info = []

        if versions_list:
            versions = versions_list.find_all("a", {"class": "ver-item"})
            for version in versions:
                version_number = version.find("span", {"class": "vername"}).text
                version_number = version_number.split(" ")[-1]
                download_url = self.base_url + version["href"]
                versions_info.append((version_number, download_url))

        return versions_info

find_versions(apk_link) #

Finds and returns a list of versions and their download links for the given APK link.

Parameters:

Name Type Description Default
apk_link str

The link to the APK on the APKCombo website.

required

Returns:

Type Description
list[tuple[str, str]]

list[tuple[str, str]]: A list of tuples, where each tuple contains the version number

list[tuple[str, str]]

and its corresponding download link. If no versions are found, an empty list is returned.

Source code in apksearch/sites/apkcombo.py
def find_versions(self, apk_link: str) -> list[tuple[str, str]]:
    """
    Finds and returns a list of versions and their download links for the given APK link.

    Parameters:
        apk_link (str): The link to the APK on the APKCombo website.

    Returns:
        list[tuple[str, str]]: A list of tuples, where each tuple contains the version number
        and its corresponding download link. If no versions are found, an empty list is returned.
    """
    url = apk_link + "/old-versions"
    response: requests.Response = self.session.get(url, headers=self.headers)
    soup = BeautifulSoup(response.text, "html.parser")
    versions_list = soup.find("ul", {"class": "list-versions"})
    versions_info = []

    if versions_list:
        versions = versions_list.find_all("a", {"class": "ver-item"})
        for version in versions:
            version_number = version.find("span", {"class": "vername"}).text
            version_number = version_number.split(" ")[-1]
            download_url = self.base_url + version["href"]
            versions_info.append((version_number, download_url))

    return versions_info

search_apk() #

Searches for the APK on APKCombo and returns the title and link if found.

Returns:

Name Type Description
None None | tuple[str, str]

If no matching APK is found.

None | tuple[str, str]

tuple[str, str]: A tuple containing the title and link of the matching APK if found.

Source code in apksearch/sites/apkcombo.py
def search_apk(self) -> None | tuple[str, str]:
    """
    Searches for the APK on APKCombo and returns the title and link if found.

    Returns:
        None: If no matching APK is found.
        tuple[str, str]: A tuple containing the title and link of the matching APK if found.
    """
    pkg_name = self.pkg_name
    url = self.search_url + "/" + pkg_name
    response: requests.Response = self.session.get(
        url, headers=self.headers, allow_redirects=False
    )
    # Redirect to the APK page if there's only one result. i.e, apk found.
    if response.status_code == 302:
        url = self.search_url + response.headers["Location"]
        response: requests.Response = self.session.get(url, headers=self.headers)
    elif response.status_code == 200:  # Package name not found or multiple results.
        return None
    else:
        raise Exception(f"Error: {response.status_code}")
    soup = BeautifulSoup(response.text, "html.parser")
    try:
        title = soup.find("div", {"class": "app_name"}).text.strip()
    except AttributeError:
        return None
    apk_link = url
    return title, apk_link

APKFab #

This class provides methods to search for an APK on APKFab based on package name, and to find available versions and their download links for a given APK link.

Parameters:

Name Type Description Default
pkg_name str

The package name of the APK to search for.

required

Attributes:

Name Type Description
pkg_name str

The package name of the APK to search for.

base_url str

The base URL of the APKFab website.

search_url str

The URL used to search for APKs on APKFab.

headers dict

The headers used for making HTTP requests.

session Session

The session object used for making HTTP requests.

Methods:

Name Description
search_apk

Searches for the APK on APKFab and returns the title and link if found.

find_versions

str) -> list[tuple[str, str]]: Finds and returns a list of versions and their download links for the given APK link.

Source code in apksearch/sites/apkfab.py
class APKFab:
    """
    This class provides methods to search for an APK on APKFab based on package name,
    and to find available versions and their download links for a given APK link.

    Parameters:
        pkg_name (str): The package name of the APK to search for.

    Attributes:
        pkg_name (str): The package name of the APK to search for.
        base_url (str): The base URL of the APKFab website.
        search_url (str): The URL used to search for APKs on APKFab.
        headers (dict): The headers used for making HTTP requests.
        session (requests.Session): The session object used for making HTTP requests.

    Methods:
        search_apk() -> None | tuple[str, str]:
            Searches for the APK on APKFab and returns the title and link if found.

        find_versions(apk_link: str) -> list[tuple[str, str]]:
            Finds and returns a list of versions and their download links for the given APK link.
    """

    def __init__(self, pkg_name: str):
        self.pkg_name = pkg_name
        self.base_url = "https://apkfab.com"
        self.search_url = self.base_url + "/search?q="
        self.headers = {
            "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
            "accept-language": "en-US,en;q=0.9,en-IN;q=0.8",
            "cache-control": "no-cache",
            "dnt": "1",
            "pragma": "no-cache",
            "priority": "u=0, i",
            "referer": "https://apkfab.com/search",
            "sec-ch-ua": '"Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24"',
            "sec-ch-ua-mobile": "?0",
            "sec-ch-ua-platform": '"Windows"',
            "sec-fetch-dest": "document",
            "sec-fetch-mode": "navigate",
            "sec-fetch-site": "same-origin",
            "sec-fetch-user": "?1",
            "upgrade-insecure-requests": "1",
            "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0",
        }
        self.session = requests.Session()

    def search_apk(self) -> None | tuple[str, str]:
        """
        Searches for the APK on APKFab and returns the title and link if found.

        Returns:
            None: If no matching APK is found.
            tuple[str, str]: A tuple containing the title and link of the matching APK if found.
        """
        pkg_name = self.pkg_name
        url = self.search_url + pkg_name
        params = {"headers": self.headers}
        if curl:
            params["impersonate"] = "chrome"
        response: requests.Response = self.session.get(url, **params)
        soup = BeautifulSoup(response.text, "html.parser")
        search_result = soup.find("div", {"class": "search-white"})
        if search_result:
            container = search_result.find("div", {"class": "container"})
            if container:
                lists = container.find("div", {"class": "list-template lists"})
                if lists:
                    items = lists.find_all("div", {"class": "list"})
                    if items:
                        item = items[0]
                        apk_title = item.find("div", {"class": "title"}).text
                        apk_link = item.find("a")["href"]
                        package_name = apk_link.split("/")[-1]
                        if package_name == pkg_name:
                            return apk_title, apk_link
        return None

    def find_versions(self, apk_link: str) -> list[tuple[str, str]]:
        """
        Finds and returns a list of versions and their download links for the given APK link.

        Parameters:
            apk_link (str): The link to the APK on the APKFab website.

        Returns:
            list[tuple[str, str]]: A list of tuples, where each tuple contains the version number
            and its corresponding download link. If no versions are found, an empty list is returned.
        """
        versions_info = []
        if apk_link.startswith(self.base_url):
            url = apk_link + "/versions"
            response: requests.Response = self.session.get(url, headers=self.headers)
            soup = BeautifulSoup(response.text, "html.parser")
            versions_list = soup.find("div", {"class": "version_history"})

            if versions_list:
                versions = versions_list.find_all("div", {"class": "list"})
                if versions:
                    for version in versions:
                        package_info = version.find(
                            "div", {"class": "package_info open_info"}
                        )
                        if package_info:
                            title = package_info.find("div", {"class": "title"})
                            apk_version = title.find(
                                "span", {"class": "version"}
                            ).text.strip()
                            dl = version.find(
                                "div", {"class": "v_h_button button_down"}
                            )
                            if dl:
                                download_link = dl.find("a")["href"]
                                versions_info.append((apk_version, download_link))
                            else:
                                # Some versions have multiple variants
                                versions_info.append((apk_version, url))

        return versions_info

find_versions(apk_link) #

Finds and returns a list of versions and their download links for the given APK link.

Parameters:

Name Type Description Default
apk_link str

The link to the APK on the APKFab website.

required

Returns:

Type Description
list[tuple[str, str]]

list[tuple[str, str]]: A list of tuples, where each tuple contains the version number

list[tuple[str, str]]

and its corresponding download link. If no versions are found, an empty list is returned.

Source code in apksearch/sites/apkfab.py
def find_versions(self, apk_link: str) -> list[tuple[str, str]]:
    """
    Finds and returns a list of versions and their download links for the given APK link.

    Parameters:
        apk_link (str): The link to the APK on the APKFab website.

    Returns:
        list[tuple[str, str]]: A list of tuples, where each tuple contains the version number
        and its corresponding download link. If no versions are found, an empty list is returned.
    """
    versions_info = []
    if apk_link.startswith(self.base_url):
        url = apk_link + "/versions"
        response: requests.Response = self.session.get(url, headers=self.headers)
        soup = BeautifulSoup(response.text, "html.parser")
        versions_list = soup.find("div", {"class": "version_history"})

        if versions_list:
            versions = versions_list.find_all("div", {"class": "list"})
            if versions:
                for version in versions:
                    package_info = version.find(
                        "div", {"class": "package_info open_info"}
                    )
                    if package_info:
                        title = package_info.find("div", {"class": "title"})
                        apk_version = title.find(
                            "span", {"class": "version"}
                        ).text.strip()
                        dl = version.find(
                            "div", {"class": "v_h_button button_down"}
                        )
                        if dl:
                            download_link = dl.find("a")["href"]
                            versions_info.append((apk_version, download_link))
                        else:
                            # Some versions have multiple variants
                            versions_info.append((apk_version, url))

    return versions_info

search_apk() #

Searches for the APK on APKFab and returns the title and link if found.

Returns:

Name Type Description
None None | tuple[str, str]

If no matching APK is found.

None | tuple[str, str]

tuple[str, str]: A tuple containing the title and link of the matching APK if found.

Source code in apksearch/sites/apkfab.py
def search_apk(self) -> None | tuple[str, str]:
    """
    Searches for the APK on APKFab and returns the title and link if found.

    Returns:
        None: If no matching APK is found.
        tuple[str, str]: A tuple containing the title and link of the matching APK if found.
    """
    pkg_name = self.pkg_name
    url = self.search_url + pkg_name
    params = {"headers": self.headers}
    if curl:
        params["impersonate"] = "chrome"
    response: requests.Response = self.session.get(url, **params)
    soup = BeautifulSoup(response.text, "html.parser")
    search_result = soup.find("div", {"class": "search-white"})
    if search_result:
        container = search_result.find("div", {"class": "container"})
        if container:
            lists = container.find("div", {"class": "list-template lists"})
            if lists:
                items = lists.find_all("div", {"class": "list"})
                if items:
                    item = items[0]
                    apk_title = item.find("div", {"class": "title"}).text
                    apk_link = item.find("a")["href"]
                    package_name = apk_link.split("/")[-1]
                    if package_name == pkg_name:
                        return apk_title, apk_link
    return None

APKMirror #

This class provides methods to search for an APK on APKMirror based on package name, and to find available versions and their download links for a given APK link.

Parameters:

Name Type Description Default
pkg_name str

The package name of the APK to search for.

required

Attributes:

Name Type Description
pkg_name str

The package name of the APK to search for.

base_url str

The base URL of the APKMirror website.

api_url str

The base URL for the APKMirror API.

headers dict

The headers used for making HTTP requests.

session Session

The session object used for making HTTP requests.

Methods:

Name Description
search_apk

Searches for the APK on APKMirror and returns the title and link if found.

find_versions

str) -> list[tuple[str, str]]: Finds and returns a list of versions and their download links for the given APK link.

Source code in apksearch/sites/apkmirror.py
class APKMirror:
    """
    This class provides methods to search for an APK on APKMirror based on package name,
    and to find available versions and their download links for a given APK link.

    Parameters:
        pkg_name (str): The package name of the APK to search for.

    Attributes:
        pkg_name (str): The package name of the APK to search for.
        base_url (str): The base URL of the APKMirror website.
        api_url (str): The base URL for the APKMirror API.
        headers (dict): The headers used for making HTTP requests.
        session (requests.Session): The session object used for making HTTP requests.

    Methods:
        search_apk() -> None | tuple[str, str]:
            Searches for the APK on APKMirror and returns the title and link if found.

        find_versions(apk_link: str) -> list[tuple[str, str]]:
            Finds and returns a list of versions and their download links for the given APK link.
    """

    def __init__(self, pkg_name: str):
        self.pkg_name = pkg_name
        self.base_url = "https://www.apkmirror.com"
        self.api_url = self.base_url + "/wp-json/apkm/v1"
        # https://github.com/rumboalla/apkupdater/blob/3.x/app/src/main/kotlin/com/apkupdater/service/ApkMirrorService.kt
        self.headers = {
            "User-Agent": "APKUpdater-v3.0.3",
            "Authorization": "Basic YXBpLWFwa3VwZGF0ZXI6cm01cmNmcnVVakt5MDRzTXB5TVBKWFc4",
            "Content-Type": "application/json",
        }
        self.session = requests.Session()

    def search_apk(self) -> None | tuple[str, str]:
        """
        Searches for the APK on APKMirror and returns the title and link if found.

        Returns:
            None: If no matching APK is found.
            tuple[str, str]: A tuple containing the title and link of the matching APK if found.
        """
        pkg_name = self.pkg_name
        url = self.api_url + "/app_exists"
        json = {"pnames": pkg_name}
        response: requests.Response = self.session.post(
            url, json=json, headers=self.headers
        )
        result = response.json()["data"][0]
        if result and result["exists"]:
            pname = result["pname"]
            if pname == pkg_name:
                title = result["app"]["name"]
                apk_link = self.base_url + result["app"]["link"]
                return title, apk_link
        return None

    def find_version(self, apk_link: str, version: str, title: str) -> str | None:
        """
        Finds and returns the download link for the given APK link and version.

        Parameters:
            apk_link (str): The link to the APK on the APKMirror website.
            version (str): The version number of the APK to find.

        Returns:
            str: The download link for the specified version of the APK.
        """
        name = re.sub(r"[(),]", "", title).lower().replace(" ", "-")
        name = re.sub(r"-+", "-", name)
        version = version.replace(".", "-")
        url = apk_link + name + "-" + version + "-release"
        response = self.session.get(url, headers=self.headers)
        if response.status_code == 404:
            return None
        return url

find_version(apk_link, version, title) #

Finds and returns the download link for the given APK link and version.

Parameters:

Name Type Description Default
apk_link str

The link to the APK on the APKMirror website.

required
version str

The version number of the APK to find.

required

Returns:

Name Type Description
str str | None

The download link for the specified version of the APK.

Source code in apksearch/sites/apkmirror.py
def find_version(self, apk_link: str, version: str, title: str) -> str | None:
    """
    Finds and returns the download link for the given APK link and version.

    Parameters:
        apk_link (str): The link to the APK on the APKMirror website.
        version (str): The version number of the APK to find.

    Returns:
        str: The download link for the specified version of the APK.
    """
    name = re.sub(r"[(),]", "", title).lower().replace(" ", "-")
    name = re.sub(r"-+", "-", name)
    version = version.replace(".", "-")
    url = apk_link + name + "-" + version + "-release"
    response = self.session.get(url, headers=self.headers)
    if response.status_code == 404:
        return None
    return url

search_apk() #

Searches for the APK on APKMirror and returns the title and link if found.

Returns:

Name Type Description
None None | tuple[str, str]

If no matching APK is found.

None | tuple[str, str]

tuple[str, str]: A tuple containing the title and link of the matching APK if found.

Source code in apksearch/sites/apkmirror.py
def search_apk(self) -> None | tuple[str, str]:
    """
    Searches for the APK on APKMirror and returns the title and link if found.

    Returns:
        None: If no matching APK is found.
        tuple[str, str]: A tuple containing the title and link of the matching APK if found.
    """
    pkg_name = self.pkg_name
    url = self.api_url + "/app_exists"
    json = {"pnames": pkg_name}
    response: requests.Response = self.session.post(
        url, json=json, headers=self.headers
    )
    result = response.json()["data"][0]
    if result and result["exists"]:
        pname = result["pname"]
        if pname == pkg_name:
            title = result["app"]["name"]
            apk_link = self.base_url + result["app"]["link"]
            return title, apk_link
    return None

APKPure #

This class provides methods to search for an APK on APKPure based on package name, and to find available versions and their download links for a given APK link.

Parameters:

Name Type Description Default
pkg_name str

The package name of the APK to search for.

required

Attributes:

Name Type Description
pkg_name str

The package name of the APK to search for.

base_url str

The base URL of the APKPure website.

search_url str

The URL used to search for APKs on APKPure.

headers dict

The headers used for making HTTP requests.

session Session

The session object used for making HTTP requests.

Methods:

Name Description
search_apk

Searches for the APK on APKPure and returns the title and link if found.

find_versions

str) -> list[tuple[str, str]]: Finds and returns a list of versions and their download links for the given APK link.

Source code in apksearch/sites/apkpure.py
class APKPure:
    """
    This class provides methods to search for an APK on APKPure based on package name,
    and to find available versions and their download links for a given APK link.

    Parameters:
        pkg_name (str): The package name of the APK to search for.

    Attributes:
        pkg_name (str): The package name of the APK to search for.
        base_url (str): The base URL of the APKPure website.
        search_url (str): The URL used to search for APKs on APKPure.
        headers (dict): The headers used for making HTTP requests.
        session (requests.Session): The session object used for making HTTP requests.

    Methods:
        search_apk() -> None | tuple[str, str]:
            Searches for the APK on APKPure and returns the title and link if found.

        find_versions(apk_link: str) -> list[tuple[str, str]]:
            Finds and returns a list of versions and their download links for the given APK link.
    """

    def __init__(self, pkg_name: str):
        self.pkg_name = pkg_name
        self.base_url = "https://apkpure.net"
        self.cdn_url = "https://d.cdnpure.com/b/APK/"
        self.cdn_version = "?version="
        self.search_url = self.base_url + "/search?q="
        self.api_url = "https://tapi.pureapk.com/v3/get_app_his_version"
        self.api_headers = {
            "User-Agent-WebView": "Mozilla/5.0 (Linux; Android 13; Pixel 5 Build/TQ3A.230901.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/132.0.6834.122 Safari/537.36",
            "User-Agent": "Dalvik/2.1.0 (Linux; U; Android 13; Pixel 5 Build/TQ3A.230901.001); APKPure/3.20.34 (Aegon)",
            "Ual-Access-Businessid": "projecta",
            "Ual-Access-ProjectA": """{"device_info":{"abis":["x86_64","arm64-v8a","x86","armeabi-v7a","armeabi"],"android_id":"50f838123d9a9c94","brand":"google","country":"United States","country_code":"US","imei":"","language":"en-US","manufacturer":"Google","mode":"Pixel 5","os_ver":"33","os_ver_name":"13","platform":1,"product":"redfin","screen_height":1080,"screen_width":1920},"host_app_info":{"build_no":"468","channel":"","md5":"6756e53158d6f6c013650a40d8f1147b","pkg_name":"com.apkpure.aegon","sdk_ver":"3.20.34","version_code":3203427,"version_name":"3.20.34"}}""",
            "Ual-Access-ExtInfo": """{"ext_info":"{\"gaid\":\"\",\"oaid\":\"\"}","lbs_info":{"accuracy":0.0,"city":"","city_code":0,"country":"","country_code":"","district":"","latitude":0.0,"longitude":0.0,"province":"","street":""}}""",
            "Ual-Access-Sequence": "",
            "Ual-Access-Nonce": "21448252",
            "Ual-Access-Timestamp": "1738560597165",
            "Connection": "Keep-Alive",
            "Accept-Encoding": "gzip",
        }
        self.headers = {
            "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
            "accept-language": "en-US,en;q=0.9,en-IN;q=0.8",
            "cache-control": "no-cache",
            "dnt": "1",
            "pragma": "no-cache",
            "priority": "u=0, i",
            "referer": "https://apkpure.net/",
            "sec-ch-ua": '"Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24"',
            "sec-ch-ua-mobile": "?0",
            "sec-ch-ua-platform": '"Windows"',
            "sec-fetch-dest": "document",
            "sec-fetch-mode": "navigate",
            "sec-fetch-site": "same-origin",
            "sec-fetch-user": "?1",
            "upgrade-insecure-requests": "1",
            "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0",
        }
        self.session = requests.Session()

    def _api_search(self) -> None | tuple[str, list[tuple[str, str]]]:
        """
        Attempts to fetch app information using API.

        Returns:
            None: If API request fails or no data found
            tuple[str, list[tuple[str, str]]]: App title and list of (version, download_url) tuples
        """
        try:
            params = {"package_name": self.pkg_name, "hl": "en"}
            response = self.session.get(
                self.api_url, headers=self.api_headers, params=params
            )
            data = response.json()

            if not data.get("version_list"):
                return None

            versions_info = []
            title = None

            for version in data["version_list"]:
                version_name = version["version_name"]
                if not title:
                    title = version["title"]
                if version.get("asset", {}).get("urls"):
                    download_url = version["asset"]["urls"][0]
                    versions_info.append((version_name, download_url))

            return (title, versions_info) if title and versions_info else None

        except Exception:
            return None

    def search_apk(self) -> None | tuple[str, str]:
        """
        Searches for the APK on APKPure and returns the title and link if found.

        Returns:
            None: If no matching APK is found.
            tuple[str, str]: A tuple containing the title and link of the matching APK if found.
        """
        pkg_name = self.pkg_name
        url = self.search_url + pkg_name
        response: requests.Response = self.session.get(url, headers=self.headers)
        soup = BeautifulSoup(response.text, "html.parser")
        search_results = soup.find("div", {"class": "apk-list"})
        if search_results:
            apk_items = search_results.find_all("a", {"class": "apk-item"})
            if apk_items:
                for apk_item in apk_items:
                    apk_link = self.base_url + apk_item["href"]
                    apk_title = apk_item["title"]
                    apk_package_name = apk_item["data-dt-pkg"]
                    if apk_package_name == pkg_name:
                        return apk_title, apk_link
        # If site search resulted 0 results, try cdn link
        # https://github.com/AbhiTheModder/apksearch/issues/2
        url = self.cdn_url + pkg_name + self.cdn_version + "latest"
        response: requests.Response = self.session.get(
            url, headers=self.headers, allow_redirects=False
        )
        try:
            location = response.headers.get("Location")
        except AttributeError:
            location = None
        if location:
            if location == "https://apkpure.com":
                return None
            response: requests.Response = self.session.head(
                location, allow_redirects=False
            )
            try:
                content = response.headers.get("Content-Disposition")
            except AttributeError:
                return None
            if content:
                apk_title = content.split("filename=")[1].strip('"').split("_")[0]
                return apk_title, location

        api_result = self._api_search()
        if api_result:
            title, versions = api_result
            if versions:
                return title, versions[0][1]

        return None

    def find_versions(self, apk_link: str) -> list[tuple[str, str]]:
        """
        Finds and returns a list of versions and their download links for the given APK link.

        Parameters:
            apk_link (str): The link to the APK on the APKPure website.

        Returns:
            list[tuple[str, str]]: A list of tuples, where each tuple contains the version number
            and its corresponding download link. If no versions are found, an empty list is returned.
        """
        api_result = self._api_search()
        if api_result:
            return api_result[1]

        versions_info = []
        if apk_link.startswith(self.base_url):
            url = apk_link + "/versions"
            response: requests.Response = self.session.get(url, headers=self.headers)
            soup = BeautifulSoup(response.text, "html.parser")
            versions_list = soup.find("ul", {"class": "version-list"})

            if versions_list:
                versions = versions_list.find_all(
                    "li", {"class": re.compile("^version dt-version-item.*")}
                )
                for ver in versions:
                    version_icon = ver.find("a", {"class": "dt-version-icon"})
                    version_info = ver.find("div", {"class": "version-info"})
                    if version_icon and version_info:
                        version_number = version_info.find(
                            "span", {"class": "name one-line"}
                        ).text
                        download_url = self.base_url + version_icon["href"]
                        versions_info.append((version_number, download_url))
        return versions_info

find_versions(apk_link) #

Finds and returns a list of versions and their download links for the given APK link.

Parameters:

Name Type Description Default
apk_link str

The link to the APK on the APKPure website.

required

Returns:

Type Description
list[tuple[str, str]]

list[tuple[str, str]]: A list of tuples, where each tuple contains the version number

list[tuple[str, str]]

and its corresponding download link. If no versions are found, an empty list is returned.

Source code in apksearch/sites/apkpure.py
def find_versions(self, apk_link: str) -> list[tuple[str, str]]:
    """
    Finds and returns a list of versions and their download links for the given APK link.

    Parameters:
        apk_link (str): The link to the APK on the APKPure website.

    Returns:
        list[tuple[str, str]]: A list of tuples, where each tuple contains the version number
        and its corresponding download link. If no versions are found, an empty list is returned.
    """
    api_result = self._api_search()
    if api_result:
        return api_result[1]

    versions_info = []
    if apk_link.startswith(self.base_url):
        url = apk_link + "/versions"
        response: requests.Response = self.session.get(url, headers=self.headers)
        soup = BeautifulSoup(response.text, "html.parser")
        versions_list = soup.find("ul", {"class": "version-list"})

        if versions_list:
            versions = versions_list.find_all(
                "li", {"class": re.compile("^version dt-version-item.*")}
            )
            for ver in versions:
                version_icon = ver.find("a", {"class": "dt-version-icon"})
                version_info = ver.find("div", {"class": "version-info"})
                if version_icon and version_info:
                    version_number = version_info.find(
                        "span", {"class": "name one-line"}
                    ).text
                    download_url = self.base_url + version_icon["href"]
                    versions_info.append((version_number, download_url))
    return versions_info

search_apk() #

Searches for the APK on APKPure and returns the title and link if found.

Returns:

Name Type Description
None None | tuple[str, str]

If no matching APK is found.

None | tuple[str, str]

tuple[str, str]: A tuple containing the title and link of the matching APK if found.

Source code in apksearch/sites/apkpure.py
def search_apk(self) -> None | tuple[str, str]:
    """
    Searches for the APK on APKPure and returns the title and link if found.

    Returns:
        None: If no matching APK is found.
        tuple[str, str]: A tuple containing the title and link of the matching APK if found.
    """
    pkg_name = self.pkg_name
    url = self.search_url + pkg_name
    response: requests.Response = self.session.get(url, headers=self.headers)
    soup = BeautifulSoup(response.text, "html.parser")
    search_results = soup.find("div", {"class": "apk-list"})
    if search_results:
        apk_items = search_results.find_all("a", {"class": "apk-item"})
        if apk_items:
            for apk_item in apk_items:
                apk_link = self.base_url + apk_item["href"]
                apk_title = apk_item["title"]
                apk_package_name = apk_item["data-dt-pkg"]
                if apk_package_name == pkg_name:
                    return apk_title, apk_link
    # If site search resulted 0 results, try cdn link
    # https://github.com/AbhiTheModder/apksearch/issues/2
    url = self.cdn_url + pkg_name + self.cdn_version + "latest"
    response: requests.Response = self.session.get(
        url, headers=self.headers, allow_redirects=False
    )
    try:
        location = response.headers.get("Location")
    except AttributeError:
        location = None
    if location:
        if location == "https://apkpure.com":
            return None
        response: requests.Response = self.session.head(
            location, allow_redirects=False
        )
        try:
            content = response.headers.get("Content-Disposition")
        except AttributeError:
            return None
        if content:
            apk_title = content.split("filename=")[1].strip('"').split("_")[0]
            return apk_title, location

    api_result = self._api_search()
    if api_result:
        title, versions = api_result
        if versions:
            return title, versions[0][1]

    return None

APKad #

This class provides methods to search for an APK on APKAD based on package name, and to find available versions and their download links for a given APK link.

Parameters:

Name Type Description Default
pkg_name str

The package name of the APK to search for.

required

Attributes:

Name Type Description
pkg_name str

The package name of the APK to search for.

base_url str

The base URL of the APKAD website.

search_url str

The URL used to search for APKs on APKAD.

headers dict

The headers used for making HTTP requests.

session Session

The session object used for making HTTP requests.

Methods:

Name Description
search_apk

Searches for the APK on APKAD and returns the title and link if found.

Source code in apksearch/sites/apkad.py
class APKad:
    """
    This class provides methods to search for an APK on APKAD based on package name,
    and to find available versions and their download links for a given APK link.

    Parameters:
        pkg_name (str): The package name of the APK to search for.

    Attributes:
        pkg_name (str): The package name of the APK to search for.
        base_url (str): The base URL of the APKAD website.
        search_url (str): The URL used to search for APKs on APKAD.
        headers (dict): The headers used for making HTTP requests.
        session (requests.Session): The session object used for making HTTP requests.

    Methods:
        search_apk() -> None | tuple[str, str]:
            Searches for the APK on APKAD and returns the title and link if found.
    """

    def __init__(self, pkg_name: str):
        self.pkg_name = pkg_name
        self.base_url = "https://apkdownloader.pages.dev"
        self.api_url = "https://api.mi9.com"
        self.token_url = "https://token.mi9.com/"
        self.search_url = self.api_url + "/get"
        self.headers = {
            "accept": "text/event-stream",
            "accept-language": "en-US,en;q=0.9,en-IN;q=0.8",
            "cache-control": "no-cache",
            "dnt": "1",
            "origin": "https://apkdownloader.pages.dev",
            "pragma": "no-cache",
            "priority": "u=1, i",
            "referer": "https://apkdownloader.pages.dev/",
            "sec-ch-ua": '"Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24"',
            "sec-ch-ua-mobile": "?0",
            "sec-ch-ua-platform": '"Windows"',
            "sec-fetch-dest": "empty",
            "sec-fetch-mode": "cors",
            "sec-fetch-site": "same-site",
            "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0",
        }
        self.session = requests.Session()

    def get_token(self) -> tuple[str, int] | None:
        """
        Retrieves a token from the token endpoint.

        Returns:
            tuple[str, int]: A tuple containing the token and timestamp if successful.
            None: If the token retrieval fails.
        """
        data = {
            "package": self.pkg_name,
            "device": "phone",
            "arch": "arm64-v8a",
            "vc": "",
            "device_id": "",
            "sdk": "default",
        }
        response = self.session.post(self.token_url, headers=self.headers, json=data)
        if response.status_code == 200:
            token_data = response.json()
            if token_data.get("success"):
                return token_data.get("token"), token_data.get("timestamp")
        return None

    def search_apk(self) -> None | tuple[str, list[tuple[str, str]]]:
        token_tuple = self.get_token()
        if not token_tuple:
            return None

        token, ts = token_tuple
        data_json = json.dumps(
            {
                "hl": "en",
                "package": self.pkg_name,
                "device": "phone",
                "arch": "arm64-v8a",
                "vc": "",
                "device_id": "",
                "sdk": "default",
                "timestamp": ts,
            },
            separators=(",", ":"),
        )

        data_b64 = base64.b64encode(data_json.encode("utf-8")).decode("utf-8")

        params = {"token": token, "data": data_b64}

        response = self.session.get(
            self.search_url, headers=self.headers, params=params, stream=True
        )

        stream_response = None
        for line in response.iter_lines():
            if not line:
                continue
            line_response = line.decode("utf-8")
            if line_response.startswith("data: "):
                payload = line_response[6:]
                try:
                    j = json.loads(payload)
                    if j.get("progress") == 100 and j.get("html"):
                        stream_response = j
                        break
                except json.JSONDecodeError:
                    continue

        if stream_response:
            html_body = stream_response["html"]
            soup = BeautifulSoup(html_body, "html.parser")
            if not soup:
                return None

            title = soup.find("li", {"class": "_title"})
            title = title.text.strip() if title else self.pkg_name

            apk_files_div = soup.find("div", {"id": "apkslist"})
            if not apk_files_div:
                return None

            apk_links: list[tuple[str, str]] = []
            for a in apk_files_div.find_all("a", href=True):
                link = a["href"].strip()
                filename = a.find("span", {"class": "der_name"})
                filename = filename.text.strip() if filename else link.split("/")[-1]
                apk_links.append((filename, link))

            return title, apk_links

        return None

get_token() #

Retrieves a token from the token endpoint.

Returns:

Name Type Description
tuple[str, int] | None

tuple[str, int]: A tuple containing the token and timestamp if successful.

None tuple[str, int] | None

If the token retrieval fails.

Source code in apksearch/sites/apkad.py
def get_token(self) -> tuple[str, int] | None:
    """
    Retrieves a token from the token endpoint.

    Returns:
        tuple[str, int]: A tuple containing the token and timestamp if successful.
        None: If the token retrieval fails.
    """
    data = {
        "package": self.pkg_name,
        "device": "phone",
        "arch": "arm64-v8a",
        "vc": "",
        "device_id": "",
        "sdk": "default",
    }
    response = self.session.post(self.token_url, headers=self.headers, json=data)
    if response.status_code == 200:
        token_data = response.json()
        if token_data.get("success"):
            return token_data.get("token"), token_data.get("timestamp")
    return None

AppTeka #

This class provides methods to search for an APK on AppTeka based on package name, and to find available versions and their download links for a given APK link.

Parameters:

Name Type Description Default
pkg_name str

The package name of the APK to search for.

required

Attributes:

Name Type Description
pkg_name str

The package name of the APK to search for.

base_url str

The base URL of the AppTeka website.

search_url str

The URL used to search for APKs on AppTeka.

headers dict

The headers used for making HTTP requests.

session Session

The session object used for making HTTP requests.

Methods:

Name Description
search_apk

Searches for an APK on AppTeka based on the package name and version. Returns a tuple containing the APK name and download link if found, otherwise None.

Source code in apksearch/sites/appteka.py
class AppTeka:
    """
    This class provides methods to search for an APK on AppTeka based on package name,
    and to find available versions and their download links for a given APK link.

    Parameters:
        pkg_name (str): The package name of the APK to search for.

    Attributes:
        pkg_name (str): The package name of the APK to search for.
        base_url (str): The base URL of the AppTeka website.
        search_url (str): The URL used to search for APKs on AppTeka.
        headers (dict): The headers used for making HTTP requests.
        session (requests.Session): The session object used for making HTTP requests.

    Methods:
        search_apk(version) -> None | tuple[str, str]:
            Searches for an APK on AppTeka based on the package name and version.
            Returns a tuple containing the APK name and download link if found, otherwise None.
    """

    def __init__(self, pkg_name: str):
        self.pkg_name = pkg_name
        self.base_url = "https://appteka.store"
        self.search_url = self.base_url + "/list/?query="
        self.headers = {
            "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
            "accept-language": "en-US,en;q=0.9,en-IN;q=0.8",
            "cache-control": "no-cache",
            "dnt": "1",
            "connection": "keep-alive",
            "pragma": "no-cache",
            "referer": "https://appteka.store/list/",
            "sec-ch-ua": '"Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24"',
            "sec-ch-ua-mobile": "?0",
            "sec-ch-ua-platform": '"Windows"',
            "sec-fetch-dest": "document",
            "sec-fetch-mode": "navigate",
            "sec-fetch-site": "same-origin",
            "sec-fetch-user": "?1",
            "upgrade-insecure-requests": "1",
            "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0",
        }
        self.session = requests.Session()

    def search_apk(self, version: str | None = None) -> None | tuple[str, str | None]:
        """
        Searches for the APK on AppTeka and returns the title and link if found.

        Parameters:
           version (str, optional): The version of the APK to search for.

        Returns:
            None: If no matching APK is found.
            tuple[str, str]: A tuple containing the title and link of the matching APK if found.
        """
        pkg_name = self.pkg_name
        url = self.search_url + pkg_name
        response: requests.Response = self.session.get(url, headers=self.headers)
        soup = BeautifulSoup(response.text, "html.parser")
        search_results = soup.find("div", {"class": "list-group"})
        if search_results:
            apk_items = search_results.find_all(
                "a",
                {"class": "list-group-item list-group-item-action d-flex gap-3 py-3"},
            )
            if apk_items:
                for apk_item in apk_items:
                    apk_link = self.base_url + apk_item["href"]
                    apk_title = apk_item.find(
                        "strong", {"class": "text-gray-dark"}
                    ).text.strip()
                    # Unfortunately, AppTeka does not provide a package name in the search results.
                    # So, we can't compare the package names here.
                    # We can instead do a workaround by doing a request to the apk_link and check the package name there.
                    new_url = apk_link
                    new_response: requests.Response = self.session.get(
                        new_url, headers=self.headers
                    )
                    new_soup = BeautifulSoup(new_response.text, "html.parser")
                    rows = new_soup.find_all("dl", {"class": "row"})
                    for row in rows:
                        dt_tags = row.find_all("dt")
                        dd_tags = row.find_all("dd")
                        for dt, dd in zip(dt_tags, dd_tags):
                            if dt.text.strip() == "Package":
                                package_name = dd.text.strip()
                                if package_name == pkg_name:
                                    # Appteka also stores the list of all the versions on same page
                                    # So, if the version param is given then we can check if the version is available or not
                                    if version:
                                        version_modal = new_soup.find(
                                            "div", {"id": "versionsModal"}
                                        )
                                        if version_modal:
                                            version_links = version_modal.find_all(
                                                "a",
                                                {
                                                    "class": re.compile(
                                                        "^list-group-item list-group-item-action*"
                                                    )
                                                },
                                            )
                                            for link in version_links:
                                                version_text = (
                                                    link.find("p", {"class": "m-1"})
                                                    .text.strip()
                                                    .split("\xa0")[0]
                                                )
                                                if version_text == version:
                                                    apk_link = (
                                                        self.base_url + link["href"]
                                                    )
                                                    return apk_title, apk_link
                                            return apk_title, None
                                    else:
                                        return apk_title, apk_link

        return None

search_apk(version=None) #

Searches for the APK on AppTeka and returns the title and link if found.

Parameters:

Name Type Description Default
version str

The version of the APK to search for.

None

Returns:

Name Type Description
None None | tuple[str, str | None]

If no matching APK is found.

None | tuple[str, str | None]

tuple[str, str]: A tuple containing the title and link of the matching APK if found.

Source code in apksearch/sites/appteka.py
def search_apk(self, version: str | None = None) -> None | tuple[str, str | None]:
    """
    Searches for the APK on AppTeka and returns the title and link if found.

    Parameters:
       version (str, optional): The version of the APK to search for.

    Returns:
        None: If no matching APK is found.
        tuple[str, str]: A tuple containing the title and link of the matching APK if found.
    """
    pkg_name = self.pkg_name
    url = self.search_url + pkg_name
    response: requests.Response = self.session.get(url, headers=self.headers)
    soup = BeautifulSoup(response.text, "html.parser")
    search_results = soup.find("div", {"class": "list-group"})
    if search_results:
        apk_items = search_results.find_all(
            "a",
            {"class": "list-group-item list-group-item-action d-flex gap-3 py-3"},
        )
        if apk_items:
            for apk_item in apk_items:
                apk_link = self.base_url + apk_item["href"]
                apk_title = apk_item.find(
                    "strong", {"class": "text-gray-dark"}
                ).text.strip()
                # Unfortunately, AppTeka does not provide a package name in the search results.
                # So, we can't compare the package names here.
                # We can instead do a workaround by doing a request to the apk_link and check the package name there.
                new_url = apk_link
                new_response: requests.Response = self.session.get(
                    new_url, headers=self.headers
                )
                new_soup = BeautifulSoup(new_response.text, "html.parser")
                rows = new_soup.find_all("dl", {"class": "row"})
                for row in rows:
                    dt_tags = row.find_all("dt")
                    dd_tags = row.find_all("dd")
                    for dt, dd in zip(dt_tags, dd_tags):
                        if dt.text.strip() == "Package":
                            package_name = dd.text.strip()
                            if package_name == pkg_name:
                                # Appteka also stores the list of all the versions on same page
                                # So, if the version param is given then we can check if the version is available or not
                                if version:
                                    version_modal = new_soup.find(
                                        "div", {"id": "versionsModal"}
                                    )
                                    if version_modal:
                                        version_links = version_modal.find_all(
                                            "a",
                                            {
                                                "class": re.compile(
                                                    "^list-group-item list-group-item-action*"
                                                )
                                            },
                                        )
                                        for link in version_links:
                                            version_text = (
                                                link.find("p", {"class": "m-1"})
                                                .text.strip()
                                                .split("\xa0")[0]
                                            )
                                            if version_text == version:
                                                apk_link = (
                                                    self.base_url + link["href"]
                                                )
                                                return apk_title, apk_link
                                        return apk_title, None
                                else:
                                    return apk_title, apk_link

    return None

Aptoide #

This class provides methods to search for an APK on Aptoide based on package name, and to find available versions and their download links for a given APK link.

Parameters:

Name Type Description Default
pkg_name str

The package name of the APK to search for.

required

Attributes:

Name Type Description
pkg_name str

The package name of the APK to search for.

api_url str

The base URL for the Aptoide API.

search_url str

The URL used to search for APKs on Aptoide.

headers dict

The headers used for making HTTP requests.

session Session

The session object used for making HTTP requests.

Methods:

Name Description
search_apk

Searches for the APK on Aptoide and returns the title and link if found.

find_versions

str) -> list[str | None]: Finds and returns a list of versions for the given APK link.

Source code in apksearch/sites/aptoide.py
class Aptoide:
    """
    This class provides methods to search for an APK on Aptoide based on package name,
    and to find available versions and their download links for a given APK link.

    Parameters:
        pkg_name (str): The package name of the APK to search for.

    Attributes:
        pkg_name (str): The package name of the APK to search for.
        api_url (str): The base URL for the Aptoide API.
        search_url (str): The URL used to search for APKs on Aptoide.
        headers (dict): The headers used for making HTTP requests.
        session (requests.Session): The session object used for making HTTP requests.

    Methods:
        search_apk() -> None | tuple[str, str]:
            Searches for the APK on Aptoide and returns the title and link if found.

        find_versions(apk_link: str) -> list[str | None]:
            Finds and returns a list of versions for the given APK link.
    """

    def __init__(self, pkg_name: str):
        self.pkg_name = pkg_name
        self.api_url = "https://ws75.aptoide.com/api/7"
        self.search_url = f"{self.api_url}/apps/search"
        self.headers = {
            "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
            "accept-language": "en-US,en;q=0.9,en-IN;q=0.8",
            "cache-control": "no-cache",
            "dnt": "1",
            "pragma": "no-cache",
            "priority": "u=0, i",
            "referer": "https://en.aptoide.com/",
            "sec-ch-ua": '"Not A(Brand";v="8", "Chromium";v="132", "Microsoft Edge";v="132"',
            "sec-ch-ua-mobile": "?0",
            "sec-ch-ua-platform": '"Windows"',
            "sec-fetch-dest": "document",
            "sec-fetch-mode": "navigate",
            "sec-fetch-site": "same-origin",
            "sec-fetch-user": "?1",
            "upgrade-insecure-requests": "1",
            "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0",
        }
        self.params = {
            "cdn": "web",
            "q": "bXlDUFU9YXJtNjQtdjhhLGFybWVhYmktdjdhLGFybWVhYmkmbGVhbmJhY2s9MA",
            "aab": "1",
            "mature": "false",
            "language": "en_US",
            "country": "US",
            "not_apk_tags": "",
            "query": self.pkg_name,
            "limit": "1",
            "offset": "0",
            "origin": "SITE",
            "store_name": "aptoide-web",
        }
        self.session = requests.Session()

    def search_apk(self) -> None | tuple[str, str]:
        """
        Searches for the APK on Aptoide and returns the title and link if found.

        Returns:
            None: If no matching APK is found.
            tuple[str, str]: A tuple containing the title and link of the matching APK if found.
        """
        pkg_name = self.pkg_name
        url = self.search_url
        response: requests.Response = self.session.get(
            url, headers=self.headers, params=self.params
        )
        data = response.json()
        if data and data["info"]["status"] == "OK":
            lis = data["datalist"]["list"]
            if lis:
                package = data["datalist"]["list"][0]["package"]
                apk_title = data["datalist"]["list"][0]["name"]
                if package == pkg_name:
                    app_id: int = data["datalist"]["list"][0]["id"]
                    meta_url = self.api_url + f"/app/getMeta?app_id={app_id}"
                    meta_response: requests.Response = self.session.get(
                        meta_url, headers=self.headers
                    )
                    meta_data = meta_response.json()
                    if meta_data and meta_data["info"]["status"] == "OK":
                        url = meta_data["data"]["urls"]["w"].split("?")[0]
                        return apk_title, url
        return None

    def find_versions(self, apk_link: str) -> list[str | None]:
        """
        Finds and returns a list of versions for the given APK link.

        Parameters:
            apk_link (str): The link to the APK on the Aptoide website.

        Returns:
           list[str | None]: A list of version strings for the given APK link.
        """
        versions_info = []

        url = apk_link + "/versions"
        response: requests.Response = self.session.get(url, headers=self.headers)
        soup = BeautifulSoup(response.content, "html.parser")
        version_spans = soup.find_all("span", string=re.compile(r"^\d+\.\d+\.\d+$"))
        for span in version_spans:
            version = span.text
            versions_info.append(version)

        return versions_info

find_versions(apk_link) #

Finds and returns a list of versions for the given APK link.

Parameters:

Name Type Description Default
apk_link str

The link to the APK on the Aptoide website.

required

Returns:

Type Description
list[str | None]

list[str | None]: A list of version strings for the given APK link.

Source code in apksearch/sites/aptoide.py
def find_versions(self, apk_link: str) -> list[str | None]:
    """
    Finds and returns a list of versions for the given APK link.

    Parameters:
        apk_link (str): The link to the APK on the Aptoide website.

    Returns:
       list[str | None]: A list of version strings for the given APK link.
    """
    versions_info = []

    url = apk_link + "/versions"
    response: requests.Response = self.session.get(url, headers=self.headers)
    soup = BeautifulSoup(response.content, "html.parser")
    version_spans = soup.find_all("span", string=re.compile(r"^\d+\.\d+\.\d+$"))
    for span in version_spans:
        version = span.text
        versions_info.append(version)

    return versions_info

search_apk() #

Searches for the APK on Aptoide and returns the title and link if found.

Returns:

Name Type Description
None None | tuple[str, str]

If no matching APK is found.

None | tuple[str, str]

tuple[str, str]: A tuple containing the title and link of the matching APK if found.

Source code in apksearch/sites/aptoide.py
def search_apk(self) -> None | tuple[str, str]:
    """
    Searches for the APK on Aptoide and returns the title and link if found.

    Returns:
        None: If no matching APK is found.
        tuple[str, str]: A tuple containing the title and link of the matching APK if found.
    """
    pkg_name = self.pkg_name
    url = self.search_url
    response: requests.Response = self.session.get(
        url, headers=self.headers, params=self.params
    )
    data = response.json()
    if data and data["info"]["status"] == "OK":
        lis = data["datalist"]["list"]
        if lis:
            package = data["datalist"]["list"][0]["package"]
            apk_title = data["datalist"]["list"][0]["name"]
            if package == pkg_name:
                app_id: int = data["datalist"]["list"][0]["id"]
                meta_url = self.api_url + f"/app/getMeta?app_id={app_id}"
                meta_response: requests.Response = self.session.get(
                    meta_url, headers=self.headers
                )
                meta_data = meta_response.json()
                if meta_data and meta_data["info"]["status"] == "OK":
                    url = meta_data["data"]["urls"]["w"].split("?")[0]
                    return apk_title, url
    return None