Skip to main content

python-sage-meta

Black Pylint codecov

PyPI release Supported Python versions Documentation License GitHub last commit

Table of Contents

Introduction

python-sage-meta is a comprehensive Python package designed to simplify the management of Facebook and Instagram operations through the Facebook Graph API. It provides easy-to-use interfaces for managing accounts, media, comments, hashtags, content publishing, and product tagging. This package is ideal for developers looking to integrate social media functionalities into their applications seamlessly.

Features

  • Account management for Facebook and Instagram accounts
  • Media management for uploading and handling Instagram photos, videos, and carousels
  • Comment management for Instagram comments, mentions, and replies
  • Hashtag management for searching and retrieving hashtag information
  • Content publishing for Instagram photos, videos, and carousels
  • Product tagging for Instagram media

Installation

To install python-sage-meta, use pip:

pip install python-sage-meta

Configuration

The sage_meta package requires certain configuration variables to establish and manage interactions with the Facebook Graph API effectively.

This library offers flexibility to accommodate both single-user and multi-user scenarios:

  • Single User Configuration: If you are integrating this library into a Django application or any other single-user setup, you can define the necessary variables within your application's settings. This approach ensures that the configuration behaves as a single user, maintaining a consistent and straightforward setup.

  • Multi-User Configuration: For applications requiring support for multiple users, such as a web application with various user accounts, the library allows you to dynamically change the configuration variables upon each instantiation. This flexibility ensures that each user can have their own Facebook Graph API settings, enabling personalized social media management.

Configuration Variables

To configure the sage_meta package, you need to set the following variables:

Access Token: The Facebook Graph API access token used for authentication.

Example Configuration

Here is an example of how to set up these variables in your project:

  ACCESS_TOKEN = "YOUR_ACCESS_TOKEN"

Single User Configuration

For a single-user setup, you can configure the sage_meta package as follows:

    import sage_meta

    ACCESS_TOKEN = "YOUR_ACCESS_TOKEN"

    fb_client = sage_meta.FacebookClient(
        access_token=ACCESS_TOKEN
    )

Multi-User Configuration

For multi-user applications, you can dynamically configure the sage_meta package upon each instantiation:

    import sage_meta

    class UserService:
        def __init__(self, user_access_token):
            self.fb_client = sage_meta.FacebookClient(
                access_token=user_access_token
            )

        def get_user_data(self):
            return self.fb_client.get_user_data()

    # Example usage
    user_service = UserService("USER_SPECIFIC_ACCESS_TOKEN")
    user_data = user_service.get_user_data()

This example demonstrates how to dynamically configure the package for different users, ensuring personalized management of Facebook and Instagram operations for each user.

Ensure that your configuration is securely managed, especially the access tokens, to prevent unauthorized access to your Facebook and Instagram accounts.

Examples

Example 1: Account Management

This example demonstrates how to manage Facebook and Instagram accounts using the AccountHandler class.

from sage_meta.services.base import FacebookClient

ACCESS_TOKEN = "YOUR_ACCESS_TOKEN"
fb_client = FacebookClient(access_token=ACCESS_TOKEN)
accounts = fb_client.account_handler.get_accounts()
for account in accounts:
    print(account.name)

Example 2: Media Management

This example demonstrates how to manage media for Instagram using the MediaHandler class.

from sage_meta.services.base import FacebookClient

ACCESS_TOKEN = "YOUR_ACCESS_TOKEN"
fb_client = FacebookClient(access_token=ACCESS_TOKEN)
media_items = fb_client.media_handler.get_instagram_media(insta_id="INSTAGRAM_BUSINESS_ACCOUNT_ID")
for media in media_items:
    print(media.caption)

Example 3: Content Publishing

This example demonstrates how to publish content to Instagram using the ContentPublishing class.

from sage_meta.services.base import FacebookClient

ACCESS_TOKEN = "YOUR_ACCESS_TOKEN"
fb_client = FacebookClient(access_token=ACCESS_TOKEN)
publish_response = fb_client.content_publisher.publish_photo(
    image_url="https://example.com/image.jpg",
    caption="This is an example caption."
)
print(publish_response)

License

This project is licensed under the MIT License.

Metadata

Release files for python-sage-meta 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-sage-meta 0.1.0
File Size Uploaded
python_sage_meta-0.1.0.tar.gz 14.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-sage-meta 0.1.0
File Interpreter ABI Platform
python_sage_meta-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 31.7 kB

Release files / python_sage_meta-0.1.0.tar.gz

Download URL python_sage_meta-0.1.0.tar.gz
Size 14.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1889c50ba7846ce16930595815ee4600679edb93b919836b081a1340bb64dac4
BLAKE2b-256 checksum
How to use checksums
57170212f08a9c5100c4bfeb16528fa421caa976f4cb0abde63b7be55250db1f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Windows/11

Release files / python_sage_meta-0.1.0-py3-none-any.whl

Download URL python_sage_meta-0.1.0-py3-none-any.whl
Size 17.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1363551c9c94a3205bd192d8abe0a31e81427b910711f942095cb0374a1c8a13
BLAKE2b-256 checksum
How to use checksums
a56eb4e752d6765aaa20753c3fb39e067d7ea89f4d2c36429bbd48afafeb3eb2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Windows/11

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page