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-2.0.0.tar.gz (18.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-2.0.0-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for urisocial-2.0.0.tar.gz
Algorithm Hash digest
SHA256 763c9a5de4189494db4d7de4e81515caed4248ec7bf571620cf67ff1e0382940
MD5 529df3bfba729521c2654ee6f9b00955
BLAKE2b-256 b460af597b74e61346742c44a920f550ec376336b5706925c8e2f624bc019c63

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for urisocial-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c4c42b968b5b83da9f0d3a512c3b18fa79cb8ed14efc46a2d7170947661471d9
MD5 f6917c1b81f2e04a6947085fa7f592a7
BLAKE2b-256 7ab34372560b0eacbf8210aec310540579b9868f958e9cc0fa13d42481227140

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