Official Python client for the Socialstats Enterprise API
Project description
Socialstats Python SDK
Official Python client for the Socialstats Enterprise API.
API Base URL: https://api.socialstats.com
API Key Access: Please contact api@socialstats.com
Requirements
- Python >= 3.10
Installation
Install from PyPI:
pip install socialstats-sdk
For local development:
pip install -e ".[dev]"
Quick Start
from socialstats_sdk import SocialstatsClient
client = SocialstatsClient(api_key="YOUR_API_KEY")
# API status
status = client.info.status()
# Creator information
creator = client.creators.info(socialstats_creator_id="abcd1234")
# Creator statistics
creator_stats = client.creators.stats(
socialstats_creator_id="abcd1234",
source="instagram",
)
# Post statistics
post_stats = client.posts.stats(
socialstats_creator_id="abcd1234",
source_id="instagram",
post_id="1234567890",
)
Authentication
All requests include your API key in the apikey header.
You can request an API key by contacting api@socialstats.com.
We recommend storing your key securely in environment variables:
export SOCIALSTATS_API_KEY=your_key_here
Available Resource Clients
client.infoclient.creatorsclient.posts
Info endpoints:
client.info.sources()->/sourcesclient.info.status()->/statusclient.info.uptime_check()->/uptime_checkclient.info.definitions()->/definitions
Creator endpoints:
client.creators.info(...)->/creators/infoclient.creators.stats(...)->/creators/statsclient.creators.historic_stats(...)->/creators/historic_statsclient.creators.audience(...)->/creators/audienceclient.creators.audience_details(country_code=..., ...)->/creators/audience/detailsclient.creators.activities(...)->/creators/activitiesclient.creators.content(...)->/creators/contentclient.creators.top_posts(...)->/creators/top_postsclient.creators.search(q=..., ...)->/creators/searchclient.creators.add_link_request(link=..., ...)->/creators/link_requestclient.creators.remove_link_request(link=..., ...)->/creators/link_request
Post endpoints:
client.posts.stats(...)->/posts/statsclient.posts.historic_stats(...)->/posts/historic_stats
Error Handling
from socialstats_sdk import SocialstatsAPIError, SocialstatsTransportError
try:
client.creators.info(socialstats_creator_id="invalid")
except SocialstatsAPIError as exc:
print(f"API error: {exc}")
except SocialstatsTransportError as exc:
print(f"Transport error: {exc}")
Development
To work on the SDK locally:
git clone https://github.com/songstats/socialstats-python-sdk.git
cd socialstats-python-sdk
pip install -e ".[dev]"
pytest
Versioning
This SDK follows Semantic Versioning (SemVer).
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file
socialstats_sdk-0.1.0.tar.gz.File metadata
File hashes
38a02113ee8a984ec93b764ab599896364de058370d41d73d0ec02a08e1174bc2f296e2f70cf0c7ba809b2a474865ef34bfc75bbd28ba7d5b68545c1972bb88d2c6a173407a7bff0659f041ad493f74dSee more details on using hashes here.