Python bindings for the EnsembleData API
Project description
EnsembleData Python API
Documentation
Check out the API docs to see which endpoints are available for each social media and for detailed descriptions of their parameters and functionality.
Installation
Install the package with pip as you would any other python package.
pip install ensembledata
Requirements
- The package only supports Python 3.7 and above.
Usage
Register to get your free API token.
from ensembledata.api import EDClient
client = EDClient("API-TOKEN")
result = client.tiktok.user_info_from_username(username="daviddobrik")
print("Data: ", result.data)
print("Units charged:", result.units_charged)
# Other Examples:
# result = client.instagram.user_info(username="daviddobrik")
# result = client.youtube.channel_subscribers(channel_id="UCnQghMm3Z164JFhScQYFTBw")
TikTok Guide
Get started with the TikTok API Guide. Find out which endpoints are available, and how you can use them with examples using the ensembledata python package.
Instagram Guide
Get started with the Instagram API Guide. Find out which endpoints are available, and how you can use them with examples using the ensembledata python package.
Missing Endpoints / Parameters
If you find that one of the endpoints from our API docs is not yet available in this package, you can use the EDClient.request method to specify the endpoint manually in the meantime.
from ensembledata.api import EDClient
client = EDClient("API-TOKEN")
result = client.request("/instagram/[example]", params={"foo": "...", "bar": "..."})
If you find that one the parameters to an existing endpoint is missing, you can still send this parameter via the extra_params dictionary which is available on all endpoint methods. See the example below:
from ensembledata.api import EDClient
client = EDClient("API-TOKEN")
result = client.instagram.user_info(username="...", extra_params={"baz": "..."})
Handling Errors
In the API docs, each endpoint lists a handful of possible errors the API may respond with. You can handle these errors by catching the EDError exception.
from ensembledata.api import EDClient, EDError, errors
client = EDClient("API-TOKEN")
try:
result = client.tiktok.user_info_from_username(username="daviddobrik")
except EDError as e:
# Rate limit exceeded...
if e.status_code == errors.STATUS_429_RATE_LIMIT_EXCEEDED:
print(e.detail)
# Subscription expired...
if e.status_code == errors.STATUS_493_SUBSCRIPTION_EXPIRED:
print(e.detail)
except Exception as e:
# Some other error occurred, unrelated to the EnsembleData API
# E.g. httpx.RequestError, json.JSONDecodeError
pass
Async
This package provides an asynchronous client, EDAsyncClient, which will give you access to async versions of all the same methods that can be found on the EDClient.
import asyncio
from ensembledata.api import EDAsyncClient
async def main():
client = EDAsyncClient("API-TOKEN")
result = await client.tiktok.user_info_from_username(username="daviddobrik")
if __name__ == "__main__":
asyncio.run(main())
Network Retries
By default the EDClient will perform 3 retries when it encounters network issues. If you would like to customise this behaviour, you can pass in the max_network_retries param as show below:
Note: if the request times out, it will not be retried.
from ensembledata.api import EDClient
client = EDClient("API-TOKEN", max_network_retries=5)
Configure Timeout
If you would like control over the read timeout, you can configure this either for all request by setting timeout when creating the EDClient, or you can specify the timeout per request, on any of the individual methods as shown below:
Note: the timeout is specified in seconds.
from ensembledata.api import EDClient
client = EDClient("API-TOKEN", timeout=120)
result = client.tiktok.user_info_from_username(username="daviddobrik", timeout=10)
Types
The package uses type hints, and is type checked with the latest version of mypy. If you experience any type checking related issues with the package, please let us know by creating an issue.
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 ensembledata-0.2.8.tar.gz.
File metadata
- Download URL: ensembledata-0.2.8.tar.gz
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a202d71bf72cc3f34fb1c742ade918c9cfae04a50ae34f37fb8b3bcbaadc5525
|
|
| MD5 |
ad13ed3b9d19ec75b2de1195a5be88d7
|
|
| BLAKE2b-256 |
1f89eae54e967a4848cc360564eb8b13858c8bff28fe6a09fc1cce3982e0db1e
|
Provenance
The following attestation bundles were made for ensembledata-0.2.8.tar.gz:
Publisher:
release.yml on EnsembleData/ensembledata-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ensembledata-0.2.8.tar.gz -
Subject digest:
a202d71bf72cc3f34fb1c742ade918c9cfae04a50ae34f37fb8b3bcbaadc5525 - Sigstore transparency entry: 531423630
- Sigstore integration time:
-
Permalink:
EnsembleData/ensembledata-python@1b7258e892fc81ad3026eab9b55de2320641de41 -
Branch / Tag:
refs/tags/v0.2.8 - Owner: https://github.com/EnsembleData
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1b7258e892fc81ad3026eab9b55de2320641de41 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ensembledata-0.2.8-py3-none-any.whl.
File metadata
- Download URL: ensembledata-0.2.8-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90b5c6e940d8f02f96dbe67f007247675c396c38fae3d8ceebb11b382bea1644
|
|
| MD5 |
f869bee421e984b922172bef79cf4a3c
|
|
| BLAKE2b-256 |
f5dbc04a6f1e1530d3cfa5d3213cf6e2b2febc60cf0856cbad98f2ecc1f71012
|
Provenance
The following attestation bundles were made for ensembledata-0.2.8-py3-none-any.whl:
Publisher:
release.yml on EnsembleData/ensembledata-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ensembledata-0.2.8-py3-none-any.whl -
Subject digest:
90b5c6e940d8f02f96dbe67f007247675c396c38fae3d8ceebb11b382bea1644 - Sigstore transparency entry: 531423641
- Sigstore integration time:
-
Permalink:
EnsembleData/ensembledata-python@1b7258e892fc81ad3026eab9b55de2320641de41 -
Branch / Tag:
refs/tags/v0.2.8 - Owner: https://github.com/EnsembleData
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1b7258e892fc81ad3026eab9b55de2320641de41 -
Trigger Event:
push
-
Statement type: