Instagram API is a FastAPI-based application that provides various endpoints to interact with Instagram's functionalities, including user authentication, profile information retrieval, post metrics, and media details. The service incorporates middleware for timeout handling and authentication.
- User Login: Authenticate users using their Instagram credentials.
- Profile Information: Retrieve profile information for a given username.
- User Posts: Fetch post metrics for a specified user within optional date ranges.
- Media Details: Obtain details of a specific media post using its URL.
- Media Likers: Get the list of users who liked a particular media post.
URL: /v1/api/login
Method: POST
Description: Authenticates a user with their Instagram credentials.
Request Body:
{
"username": "string",
"password": "string"
}
Response:
{
"message": "Login Successful",
"username": "string"
}
URL: /v1/api/profile
Method: GET
Description: Retrieves profile information for a given username.
Query Parameters:
username
(required): The username of the profile to retrieve.
Response:
{
"profile_data": { /* Profile information */ }
}
URL: /v1/api/user_posts
Method: GET
Description: Fetches post metrics for a specified user within optional date ranges.
Query Parameters:
username
(required): The username to retrieve posts for.from_date
(optional): Start date for post retrieval (YYYY-MM-DD).to_date
(optional): End date for post retrieval (YYYY-MM-DD).
Response:
{
"posts": [ /* List of posts */ ]
}
URL: /v1/api/media
Method: GET
Description: Retrieves details of a specific media post using its URL.
Query Parameters:
url
(required): The URL of the media to retrieve details for.
Response:
{
"media_details": { /* Media details */ }
}
URL: /v1/api/media_likers
Method: GET
Description: Gets the list of users who liked a particular media post.
Query Parameters:
media_id
(required): The media ID in the format{post_id}_{owner_id}
.username
(required): The username of the logged-in user.
Response:
{
"likers": [ /* List of likers */ ]
}
Handles request timeouts. The timeout is set to 600 seconds.
Handles authentication using the Instagram service.
This project makes use of several third-party libraries:
- Instaloader: A tool to download pictures (or videos) along with their captions and other metadata from Instagram.
- Instagpy: An Instagram automation tool.
- Instagrapi: A fast and effective Instagram Private API wrapper (compatible with Python 3.7+).
- Clone the repository:
git clone https://github.com/maron09/instagram-api.git
- Navigate to the project directory:
cd instagram-api
- Install the required dependencies:
pip install -r requirements.txt
- Run the application:
fastapi dev main.py
Access the API endpoints at http://127.0.0.1:8000
. Use tools like curl
, Postman, or any HTTP client to interact with the endpoints.
maron09
GitHub: maron09