Skip to main content

Official Python client for the ExportComments API v3

Project description

ExportComments API for Python

This is the official Python client for the ExportComments API v3. Export comments and reviews from 40+ social media and review platforms including Instagram, YouTube, TikTok, Facebook, Twitter/X, Reddit, Trustpilot, Amazon, and more.

Installation

pip install exportcomments

Or install from source:

git clone https://github.com/exportcomments/exportcomments-python.git
cd exportcomments-python
pip install -r requirements.txt
python setup.py install

Usage

Initialize the client with your API token (get it at app.exportcomments.com/user/api):

from exportcomments import ExportComments

ex = ExportComments('<YOUR API TOKEN HERE>')

Check API Connectivity

result = ex.ping()
print(result)  # {'message': 'pong'}

Create an Export Job

Start an export by submitting a URL. The queue is limited to 5 concurrent requests.

response = ex.jobs.create(
    url='https://www.instagram.com/p/1234567',
    options={'replies': True, 'limit': 100}
)
guid = response.body['guid']

Check Job Status

response = ex.jobs.check(guid=guid)
status = response.body['status']  # 'queueing', 'progress', 'done', or 'error'

List Jobs

response = ex.jobs.list(page=1, limit=10)
jobs = response.body

Download Export File

Download the Excel/CSV file for a completed job:

# Downloads and saves the file, returns the file path
file_path = ex.jobs.download(guid=guid)
print(f"Saved to: {file_path}")

# Or specify a custom output path
file_path = ex.jobs.download(guid=guid, output_path='my_export.xlsx')

Download Raw JSON Data

Get the exported data as parsed JSON:

data = ex.jobs.download_json(guid=guid)
for comment in data:
    print(comment['message'], comment['author_name'])

Job Options

The API supports various options when creating a job:

response = ex.jobs.create(
    url='https://www.instagram.com/p/1234567',
    options={
        'replies': True,
        'limit': 500,
        'minTimestamp': 1622505600,
        'maxTimestamp': 1625097600,
        'vpn': 'Norway',
        'cookies': {
            'sessionid': 'your_session_id'
        }
    }
)

Backward Compatibility

For backward compatibility, ex.exports still works as an alias for ex.jobs:

response = ex.exports.create(
    url='https://www.instagram.com/p/1234567',
    options={'replies': True}
)

Handling Errors

from exportcomments.exceptions import ExportCommentsException

try:
    response = ex.jobs.create(
        url='https://www.instagram.com/p/1234567',
        options={'replies': True}
    )
except ExportCommentsException as e:
    print(e)
Exception Class Description
ExportCommentsException Base class for all exceptions.
RequestParamsError Invalid parameter sent. Check the message or response object for details.
AuthenticationError Authentication failed, typically due to an invalid API token.
ForbiddenError Insufficient permissions for the requested action.
PlanRateLimitError Too many requests per minute according to your plan's limits.
ConcurrencyRateLimitError Too many requests per second.

Complete Example

from exportcomments import ExportComments
from exportcomments.exceptions import ExportCommentsException
import time
import sys

ex = ExportComments('<YOUR API TOKEN HERE>')

# Verify connectivity
print(ex.ping())

# Create export
try:
    response = ex.jobs.create(
        url='https://www.instagram.com/p/1234567',
        options={'replies': True, 'limit': 100}
    )
except ExportCommentsException as e:
    print(e)
    sys.exit()

guid = response.body['guid']

# Poll until done
while True:
    response = ex.jobs.check(guid=guid)
    status = response.body['status']

    if status == 'done':
        break
    elif status == 'error':
        print("Error:", response.body.get('error'))
        sys.exit()

    time.sleep(5)

# Download the file
file_path = ex.jobs.download(guid=guid)
print(f"Downloaded: {file_path}")

# Or get raw JSON data
data = ex.jobs.download_json(guid=guid)
print(f"Got {len(data)} comments")

API v3 Changes

Version 2.0.0 supports API v3:

  • New method names: Use ex.jobs instead of ex.exports (backward compatibility maintained)
  • Updated parameters: create() uses an options dict instead of individual parameters
  • New methods: ping(), download(), download_json()
  • Endpoints: Uses /api/v3/ endpoints

For more information, visit ExportComments API Documentation.

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

exportcomments-2.1.0.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

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

exportcomments-2.1.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file exportcomments-2.1.0.tar.gz.

File metadata

  • Download URL: exportcomments-2.1.0.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for exportcomments-2.1.0.tar.gz
Algorithm Hash digest
SHA256 6c138624eafb96f89d5f16d440539a49f89969c31f046ec2a7e627a633615a8a
MD5 49ff8c71d0233592b7b29fa3d04ddf7e
BLAKE2b-256 d313cc6b675e47b56c216daeec25a952ce0b6e2fee22da62f61e67b87395f8b0

See more details on using hashes here.

File details

Details for the file exportcomments-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: exportcomments-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for exportcomments-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7a5587f8025ae24d5f0a5eac09be4a65eaa4b17d71201dbe08c7bd5952667346
MD5 d601e8d1e9b8d29d1093ba2890c5a0ae
BLAKE2b-256 d34dda45071782c4f3b339a7ee343db1cf1721deceb8293f815900bf69d2cf82

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