This application provides a FastAPI-based API that allows users to find Instagram accounts they follow that do not follow them back. The API interacts with Instagram using the instaloader
library.
- main.py: Contains the FastAPI application and the endpoint to retrieve non-followees.
- instainfo.py: Contains the logic to fetch followers and followees using the
instaloader
library. - requirements.txt: Lists the dependencies required to run the application.
- Python 3.x
- Instagram account credentials
- An
.env
file with your Instagram username and password, handle 2FA id activated.
-
Clone the repository:
git clone https://github.com/your-repository-name.git cd your-repository-name
-
Install dependencies:
pip install -r requirements.txt
-
Create a
.env
file:touch .env
-
Add your Instagram credentials to the
.env
file:USER=your_instagram_username PASSWORD=your_instagram_password
-
Start the FastAPI server:
uvicorn main:app --reload
-
Access the API:
- Endpoint:
/non_followees/{user_id}
- Method:
GET
- Description: Returns a list of Instagram accounts that the user is following but are not following back.
Example:
curl http://127.0.0.1:8000/non_followees/your_instagram_username
- Endpoint:
- Login: The application logs into Instagram using the credentials provided in the
.env
file. - Fetch Data: The
get_insta_followers
function retrieves the user's followers and followees. - Process Data: It calculates the difference between followees and followers to find accounts that the user follows but do not follow back.
- API Response: The
/non_followees/{user_id}
endpoint returns the list of non-followees.
instaloader
: Library to interact with Instagram.fastapi
: Web framework for building APIs.uvicorn
: ASGI server for serving the FastAPI application.python-dotenv
: Library to manage environment variables.
- Ensure that your Instagram account has two-factor authentication disabled, as
instaloader
may have issues handling it. - Be cautious of Instagram's API rate limits to avoid being temporarily blocked from making requests.
This project is licensed under the MIT License.