--- title: leadfetcher app_file: space.py sdk: gradio sdk_version: 5.6.0 --- # Apollo - Leads Fetcher Leads Fetcher is a Python-based tool that extracts contact information and company details using the Apollo API. The tool processes JSON input, retrieves and organizes data into a structured format, and exports it as an Excel file. It also includes a web interface powered by Gradio. ## Features - Fetches leads data from the Apollo API. - Retrieves contact information (emails, phone numbers) and LinkedIn profiles. - Outputs the data as an Excel file for easy analysis. - Interactive Gradio-based web interface for user-friendly operation. ## Requirements - Python 3.8 or higher Install the dependencies using: ```bash pip install -r requirements.txt ``` ## How to Run the Code 1. **Clone the Repository** 3. **Run via Gradio Interface** ```bash python space.py ``` - The application will launch in your web browser, allowing you to input JSON data. ## Input Format The input must be a valid JSON object with the required fields for Apollo API queries. Example: ```json { "page": 1, "contact_email_status_v2": ["likely_to_engage", "verified"], "prospected_by_current_team": ["no"], "person_titles": ["ceo"], "person_locations": ["Pakistan"], "per_page": 25 } ``` You can get the input from Aollo website like this. ## How to get JSON input ## 1. Go to the Apollo filtered link (for example): [Apollo Filtered Link](https://app.apollo.io/#/people?page=1&contactEmailStatusV2[]=likely_to_engage&contactEmailStatusV2[]=verified&prospectedByCurrentTeam[]=no&sortByField=%5Bnone%5D&sortAscending=false&includedOrganizationKeywordFields[]=tags&includedOrganizationKeywordFields[]=name&organizationIndustryTagIds[]=5567cd4773696439b10b0000&personLocations[]=United%20States&organizationNumEmployeesRanges[]=21%2C50&organizationNumEmployeesRanges[]=51%2C100&organizationNumEmployeesRanges[]=101%2C200&organizationNumEmployeesRanges[]=201%2C500&excludedOrganizationKeywordFields[]=tags&excludedOrganizationKeywordFields[]=name&excludedOrganizationKeywordFields[]=social_media_description&excludedOrganizationKeywordFields[]=seo_description&personDepartmentOrSubdepartments[]=master_human_resources&personSeniorities[]=entry&personSeniorities[]=senior&personSeniorities[]=manager&personSeniorities[]=director&personSeniorities[]=head&personSeniorities[]=vp&personSeniorities[]=c_suite&personSeniorities[]=partner) 2. Open **Inspect Element** in your browser and navigate to the **Network** tab. 3. Click on the first **"search"** entry in the **Name** column. 4. Click on **"View Parsed"** and copy the entire payload. --- ![Leads Fetcher Demo](https://i.ibb.co/2qwk2vd/ezgif-2-93235bbbb8.gif) ## Output - **Excel File**: The output is saved in the `output_files/` directory with a unique identifier. - **CSV Preview**: If using the Gradio interface, a preview of the data is displayed. ## Explanation of Key Functions 1. **`convert_json_to_files(payload)`** - Takes JSON input and fetches lead data from the Apollo API. - Processes paginated results and retrieves detailed information. - Organizes data into a Pandas DataFrame and exports it as an Excel file. 2. **`get_mixed_people(payload)`** - Sends a POST request to the Apollo API to fetch lead details. - Handles pagination and extracts people data. 3. **`get_person_contact(linkedin_url_list)`** - Retrieves contact information (email, phone) for a batch of LinkedIn profiles. 4. **Gradio Interface** - Allows users to input JSON, preview the extracted data, and download the result in Excel format. ## Notes - Ensure your Apollo API key is valid and authorized for the endpoints used. - Large JSON inputs may take longer to process due to API and data handling. - Only works on 150 leads a hit on free plan ---