Skip to content

This project provides a Python client for interacting with the Meta (formerly Facebook) Graph API. It fetches insights and posts data from Facebook and Instagram, and upserts this data into a PostgreSQL database.

License

Notifications You must be signed in to change notification settings

machado000/meta_api_insights

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Meta Graph API Client

This project provides a Python client for interacting with the Meta (formerly Facebook) Graph API. It fetches insights and posts data from Facebook and Instagram, and upserts this data into a PostgreSQL database.

Features

  • Fetches Facebook Page and Post insights
  • Fetches Instagram Account and Post insights
  • Supports save results as local CSV file or upsert data into PostgreSQL using SQLAlchemy.

Installation

  1. Clone the repository:

    git clone <repository_url>
  2. Navigate to the project directory:

    cd meta_api_insights
  3. Create a virtual environment:

    python -m venv venv
  4. Activate the virtual environment:

    # On Windows
    venv\Scripts\activate
    
    # On macOS/Linux
    source venv/bin/activate
  5. Install the dependencies:

    pip install -r requirements.txt

Usage

Run the script from the command line with the following parameters:

./main.py <script_type> <start_date> <end_date>
  • <script_type>: facebook or instagram
  • <start_date> and <end_date>: Dates in YYYY-MM-DD format

For example, to fetch data for Instagram from May 1, 2023, to May 10, 2023:

./main.py instagram 2023-05-01 2023-05-10

Running from an IDE

If running from an IDE, the script defaults to fetching Instagram data for the last 7 days.

API Reference

Contributing

Feel free to submit issues or pull requests. For major changes, please open an issue first to discuss what you would like to change.

License

This project is licensed under the MIT License.

About

This project provides a Python client for interacting with the Meta (formerly Facebook) Graph API. It fetches insights and posts data from Facebook and Instagram, and upserts this data into a PostgreSQL database.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages