Skip to main content

Official Python SDK for URI Social API - Enterprise-grade social media content generation and management

Project description

urisocial

Official Python SDK for URI Social API - AI-powered social media content generation.

Installation

pip install urisocial

Quick Start

from urisocial import URISocial

client = URISocial(api_key='your-api-key')

# Generate content for multiple platforms
content = client.content.generate(
    seed_content='Launch our new luxury perfume collection',
    platforms=['instagram', 'facebook', 'twitter'],
    reference_image='https://example.com/perfume.jpg',
    tone='professional',
    include_hashtags=True
)

print(content['platforms'])  # Platform-specific content
print(content['image_url'])  # Generated image URL

Core Features

1. Content Generation

Generate platform-optimized social media content:

content = client.content.generate(
    seed_content='Introducing our eco-friendly water bottle',
    platforms=['instagram', 'linkedin'],
    reference_image='https://example.com/bottle.jpg',
    tone='friendly',
    include_hashtags=True,
    include_emojis=False
)

# Access platform-specific content
for platform in content['platforms']:
    print(f"{platform['platform']}: {platform['text']}")
    print(f"Hashtags: {' '.join(platform['hashtags'])}")

2. Draft Management

Work with drafts before publishing:

# List all drafts
drafts = client.drafts.list(page=1, per_page=20)

# Get specific draft
draft = client.drafts.get('draft-id')

# Update draft
updated = client.drafts.update(
    'draft-id',
    text_content=[{
        'platform': 'instagram',
        'text': 'Updated caption',
        'hashtags': ['#NewProduct'],
        'character_count': 50
    }]
)

# Delete draft
client.drafts.delete('draft-id')

3. Image Generation

Generate and edit images with AI:

# Generate new image
image = client.images.generate(
    prompt='Luxury perfume bottle on marble surface, golden hour lighting',
    reference_image='https://example.com/product.jpg',
    style='immersive',
    aspect_ratio='1:1'
)

# Remove background from product image
cutout = client.images.remove_background('https://example.com/product.jpg')
print(cutout['cutout_url'])

# Analyze product forensically
analysis = client.images.analyze_product('https://example.com/product.jpg')
print(analysis['product_type'])
print(analysis['colors'])

4. Social Media Connections

Manage platform connections:

# List connected platforms
connections = client.connections.list()
for conn in connections['connected_platforms']:
    print(f"{conn['platform']}: {conn['account_name']}")

# Get OAuth URL for connecting platform
result = client.connections.get_connect_url(
    'instagram',
    redirect_url='https://yourapp.com/callback'
)
print(result['auth_url'])  # Redirect user here

# Disconnect platform
client.connections.disconnect('facebook')

# Check connection status
status = client.connections.get_status('instagram')
print(status['status'])  # 'active', 'expired', or 'error'

5. Publishing

Publish or schedule content:

# Publish immediately
result = client.publishing.publish(
    draft_id='draft-123',
    platforms=['instagram', 'facebook']
)

for r in result['results']:
    print(f"{r['platform']}: {r['status']}")
    if r.get('post_id'):
        print(f"Post ID: {r['post_id']}")

# Schedule for later
scheduled = client.publishing.schedule(
    draft_id='draft-123',
    platforms=['instagram'],
    schedule_time='2024-12-25T10:00:00Z'
)
print(f"Scheduled ID: {scheduled['scheduled_id']}")

# List scheduled posts
scheduled_posts = client.publishing.list_scheduled()

# Cancel scheduled post
client.publishing.cancel_scheduled('scheduled-id')

6. Billing & Credits

Monitor usage and credits:

# Get billing info
billing = client.billing.get_info()
print(f"Credits remaining: {billing['credits_remaining']}")
print(f"Tier: {billing['subscription_tier']}")

# Get usage history
usage = client.billing.get_usage(
    start_date='2024-01-01',
    end_date='2024-01-31'
)
print(f"Total credits used: {usage['total_credits_used']}")

# Purchase credits
checkout = client.billing.purchase_credits(100)
print(checkout['checkout_url'])  # Redirect user here

Configuration

client = URISocial(
    api_key='your-api-key',
    base_url='https://api.urisocial.com',  # Optional
    timeout=60  # Optional, request timeout in seconds
)

# Update API key after initialization
client.set_api_key('new-api-key')

Context Manager

Use as context manager for automatic cleanup:

with URISocial(api_key='your-api-key') as client:
    content = client.content.generate(
        seed_content='Test',
        platforms=['instagram']
    )
    # Session automatically closed

Error Handling

from urisocial import (
    URISocial,
    AuthenticationError,
    RateLimitError,
    InsufficientCreditsError,
    ValidationError
)

try:
    content = client.content.generate(
        seed_content='Test',
        platforms=['instagram']
    )
except AuthenticationError as e:
    print(f"Invalid API key: {e.message}")
except RateLimitError as e:
    print(f"Rate limit exceeded: {e.message}")
except InsufficientCreditsError as e:
    print(f"Insufficient credits: {e.message}")
except ValidationError as e:
    print(f"Validation error: {e.message}")

Type Hints

Full type hint support:

from urisocial import (
    URISocial,
    Platform,
    ContentGenerationRequest,
    GeneratedContent,
    Draft
)

platforms: list[Platform] = ['instagram', 'facebook']

content: GeneratedContent = client.content.generate(
    seed_content='Product launch',
    platforms=platforms,
    tone='professional'
)

Platform Support

Supported platforms:

  • Instagram
  • Facebook
  • Twitter
  • LinkedIn
  • TikTok

Requirements

  • Python 3.8+
  • requests >= 2.31.0

API Reference

Full API documentation: https://docs.urisocial.com/api

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

urisocial-3.0.0.tar.gz (24.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

urisocial-3.0.0-py3-none-any.whl (30.3 kB view details)

Uploaded Python 3

File details

Details for the file urisocial-3.0.0.tar.gz.

File metadata

  • Download URL: urisocial-3.0.0.tar.gz
  • Upload date:
  • Size: 24.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for urisocial-3.0.0.tar.gz
Algorithm Hash digest
SHA256 fdc1644b4b4a10508bbea797fc417ee84e7b28ed885e1003f06cce5327385829
MD5 2890db03b25c0d8934fc13274a54cedc
BLAKE2b-256 f68a5496bd0e9d2e9533e921a52184d188abf9ecbbb14505f956b9e8cbb53903

See more details on using hashes here.

File details

Details for the file urisocial-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: urisocial-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 30.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for urisocial-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ab02c817ff4aa2d02dad51426115cc0a9cd9967d5b64a2e89f0ab42a8cae6de0
MD5 a1f542fe145e98c489966d8cca410d15
BLAKE2b-256 c26378ef315dc1a53b841104dae1ab3dbf93b391afaf072af4f939ffc9957ab2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page