Disqus API bindings for Python

Overview

disqus-python

https://travis-ci.org/disqus/disqus-python.svg?branch=master

Let's start with installing the API:

pip install disqus-python

Use the API by instantiating it, and then calling the method through dotted notation chaining:

from disqusapi import DisqusAPI
disqus = DisqusAPI(secret_key, public_key)
for result in disqus.get('trends.listThreads'):
    print result

Parameters (including the ability to override version, api_secret, and format) are passed as keyword arguments to the resource call:

disqus.get('posts.details', post=1, version='3.0')

Paginating through endpoints is easy as well:

from disqusapi import Paginator
paginator = Paginator(api.get, 'trends.listThreads', forum='disqus')
for result in paginator:
    print result

# pull in a maximum of 500 results (this limit param differs from the endpoint's limit param)
for result in paginator(limit=500):
    print result

Documentation on all methods, as well as general API usage can be found at https://disqus.com/api/docs/

Comments
  • Python 3 support

    Python 3 support

    Considering the Python maintainers say that Python 3 is the "current and future version," and Python 2 is "legacy," it seems to make sense to port disqus-python to Python 3. As stands, it's unusable in a Python 3 environment, and a tool like auto2to3 fails with an ImportError (no module named 'disqus_static').

    For starters, in Python 3, httplib was changed to http.client (see also: http://stackoverflow.com/questions/13778252/import-httplib-importerror-no-module-named-httplib).

    opened by ShaunaGordon 8
  • Now compatible from Python 2.6-3.4 with all unit tests passing.

    Now compatible from Python 2.6-3.4 with all unit tests passing.

    Hi I've refactored most of the incompatibility issues, and package runs on Python 2.6, 2.7, 3.3, and 3.4. Here are some changes i've made.

    Build Status

    Changelog

    • Added Travis-CI Integration
    • General Bug/Compatibility Fixes
      • +# -*- coding: utf-8 -*- and from __future__ import idioms
    • Supports wheel binary specification
    • Removed depreciated modules e.g. pkg_resources
    • Cleanup of __init__.py
    • Added requirements.txt & test_requirements.txt
    • Added Makefile for automation
    • Created __version__.py as single authoritative reference of version #

    Some additional refactoring that would be useful

    TODO:

    • Documentation, maybe just pulling the docstrings with Sphinx Autofunc
    • Moving rest of code out of __init__.py
    • Complete refactor of setup.py
    • Authentication without secret key, or some cryptography.
    • A CONTRIBUTE.in file
    • Remove simplejson dependency
    opened by jjangsangy 8
  • Package httplib not found!

    Package httplib not found!

    I tried to install & run the first lines of code. Got the ImportError: No module named 'httplib' for lines in __init__.py of disqusapi. When searched online, found that there is no httplib anymore. There is a newer package called httplib2 and httplib has been renamed to http.client in Python 3 Source@StackOverFlow. Should the code be updated to reflect the changes?

    opened by rampyg 5
  • Invalid API Key due to missing Content-Type

    Invalid API Key due to missing Content-Type

    A couple of hours ago, my calls to the Disqus API started to fail due to Invalid API key. Interestingly, I couldn't reproduce this with cURL or the requests library. So I had a closer look at the requests and noticed that the client does not specify the Content-Type header. Setting it to application/x-www-form-urlencoded resolves the issue. I guess something in the backend has changed lately (e.g., the default content type).

    I'm not sure whether or not this project is still maintained. The fix is trivial but if a pull request is preferred, I will gladly submit one.

    opened by jvcop 3
  • TypeError: __call__() takes exactly 1 argument (2 given)

    TypeError: __call__() takes exactly 1 argument (2 given)

    Using pip install disqus-python I got version 0.4.2 installed.

    The following code raises error (in fact it is just like in your example):

    from disqusapi import DisqusAPI
    public_key = 'XXXXXXXXXXXXXXXXXXXX'
    secret_key = 'XXXXXXXXXXXXXXXXXXXX'
    disqus = DisqusAPI(secret_key, public_key)
    disqus.get('threads.listPopular', forum='myforum')
    

    If I pass values as in the following code I get error JSONDecodeError: Expecting value: line 1 column 1 (char 0):

    kwargs = {
        'method': 'threads.listPopular',
        'forum': 'myforum',
    }
    disqus.get(**kwargs)
    
    opened by shalakhin 3
  • disqus.get('trends.listThreads'): TypeError: __call__() takes exactly 1 argument (2 given)

    disqus.get('trends.listThreads'): TypeError: __call__() takes exactly 1 argument (2 given)

    I installed disqus-python and followed https://github.com/disqus/disqus-python to do the following but it throws an exception:

    from disqusapi import DisqusAPI disqus = DisqusAPI(secret_key, public_key) for result in disqus.get('trends.listThreads'): print result

    disqus.get('trends.listThreads') Traceback (most recent call last): File "", line 1, in TypeError: call() takes exactly 1 argument (2 given)

    opened by chicheongweng 2
  • Python 3.3 compatibility

    Python 3.3 compatibility

    • Refactor needed in order to have tests
    • 100% Coverage with unit tests
    • Syntax highlight in README.rst
    • Update CHANGES
    • Added tox and nose configuration
    • Ignore .coverage, .tox and *.swp

    Can this be a good base for version 0.5?

    opened by graffic 2
  • Question on the code

    Question on the code

    Why do you use setters like setVersion when as far as I know in python attributes are already setters and getters? Object attributes can be changed just like disqus.version = '3.0'. I haven't look too carefully to the whole code but just wonder why.

    Another idea: if usage of separate setters makes sense it would be better to use underscores like set_version.

    If you want such attributes like version to be just properties outside you can use @property. I can make pull request if you agree with this idea.

    P.S. When 0.5.0 from CHANGES will be on PyPI?

    Thank you for Disqus API library and for developing Disqus. It is awesome!

    opened by shalakhin 1
  • Some followup

    Some followup

    Fixed recursion error when

    disqus.interface.update(dict)

    is used. Now throws InterfaceNotDefined expection.

    disqus.update_interface(dict)

    must be used now.

    opened by dpetzold 1
  • minimal python3 compatability

    minimal python3 compatability

    Updated pull request for minimum compatibility with Python 3.

    All unit tests passing for Python versions 2.6, 2.7, 3.3 and 3.4 confirmed on TravisCI. I can remove the .travis.yml file if CI testing isn't necessary.

    I also have a Pelican blog using the API, and tested that it runs correctly.

    Changelog

    • Uses six module for main compatibility layer with Python 2 and Python 3. Added it to the requirement specification.
    • All iterators and moved standard library modules changed to use six module versions.
    • Added requirements.txt and test_requirements.txt files.
    opened by jjangsangy 1
  • Invalid API key Error

    Invalid API key Error

    I had tested the code sample in README, and it returns Invalid API key Error.

    What does it mean? Did I inject incorrect secret key or disqus.trends.listThread() is not recognizable?

    opened by psalty 1
  • NameError: name 'api' is not defined

    NameError: name 'api' is not defined

    So I'm trying to navigate around the functionality of this library and find the things I need but nothing seems to work at first try unfortunately.

    I got the first example from README.rst to work in Python 3 with a few modifications but the third piece of code (with brackets for the print for python 3) is throwing the error in the title

    from disqusapi import Paginator
    paginator = Paginator(api.get, 'trends.listThreads', forum='disqus')
    for result in paginator:
        print (result)
    

    So I tried to change api.get to disqus as defined above disqus = DisqusAPI(secret_key, public_key) but now it is throwing a different error InterfaceNotDefined: Interface is not defined, you must pass ``method`` (HTTP Method). I tried the solution that worked for the other code snippet: paginator = Paginator(disqus, 'trends.listThreads', forum='disqus', method='GET') ..now it's running without error but not returning anything.

    Does anyone know how this code is meant to work?

    opened by aktivkohle 1
  • cannot import disqusapi with python3

    cannot import disqusapi with python3

    After I started ipython3, and typed in the shell import disqusapi, it showed ImportError: No module named 'httplib'. Seems look like the disqusapi isn't supporting python3?

    I'm using Python 3.5.2 :: Anaconda custom (x86_64)

    Here's the error log:

    In [1]: import disqusapi
    ---------------------------------------------------------------------------
    ImportError                               Traceback (most recent call last)
    <ipython-input-2-1dede7c1a4ae> in <module>()
    ----> 1 import disqusapi
    
    /Users/kspun/anaconda3/lib/python3.5/site-packages/disqusapi/__init__.py in <module>()
         13     __version__ = 'unknown'
         14 
    ---> 15 import httplib
         16 import os.path
         17 import simplejson
    
    ImportError: No module named 'httplib'
    
    opened by carsonpun 2
  • NameError: name 'Paginator' is not defined

    NameError: name 'Paginator' is not defined

    This example code

    paginator = Paginator(api.get, 'trends.listThreads', forum='disqus')
    for result in paginator:
        print result
    

    throws the error mentioned in the title.

    Probably a little bit of update in the README file would help, I am sure it is outdated, as I have seen in another issue thread.

    opened by imrek 3
  • update pypi listing, has 0.4.2 and should be 0.5.0

    update pypi listing, has 0.4.2 and should be 0.5.0

    uses httplib ..

    https://github.com/disqus/disqus-python/blob/master/CHANGES

    Edit:

    Oh, "support for python 3"

    Can you guys updates pypi then please, its still running older (non python3) version.

    https://pypi.python.org/pypi/disqus-python/0.4.2

    opened by bhcopeland 0
Python bindings for Alexa Web Information Service (AWIS) API

Attention! This package is no longer maintained. See this ticket for more info. Wraps Alexa Web Information Service. Usage Making UrlInfo requests: ap

Atamert Ölçgen 51 Feb 12, 2022
Python bindings for swm-core client REST API

Python bindings for swm-core client REST API Description Sky Port is an universal bus between user software and compute resources. It can also be cons

Sky Workflows 1 Jan 1, 2022
Python bindings for ArrayFire: A general purpose GPU library.

ArrayFire Python Bindings ArrayFire is a high performance library for parallel computing with an easy-to-use API. It enables users to write scientific

ArrayFire 402 Dec 20, 2022
Python bindings for BigML.io

BigML Python Bindings BigML makes machine learning easy by taking care of the details required to add data-driven decisions and predictive power to yo

BigML Inc, Machine Learning made easy 271 Dec 27, 2022
Python bindings to the Syncthing REST interface.

python-syncthing Python bindings to the Syncthing REST interface. Python API Documentation Syncthing Syncthing REST Documentation Syncthing Forums $ p

Blake VandeMerwe 64 Aug 13, 2022
Python bindings for LibreTranslate

Python bindings for LibreTranslate

Argos Open Tech 42 Jan 3, 2023
pylunasvg - Python bindings for lunasvg

pylunasvg - Python bindings for lunasvg Pylunasvg is a simple wrapper around lunasvg that uses pybind11 to create python bindings. All public API of t

Eren 6 Jan 5, 2023
PRAW, an acronym for "Python Reddit API Wrapper", is a python package that allows for simple access to Reddit's API.

PRAW: The Python Reddit API Wrapper PRAW, an acronym for "Python Reddit API Wrapper", is a Python package that allows for simple access to Reddit's AP

Python Reddit API Wrapper Development 3k Dec 29, 2022
PRAW, an acronym for "Python Reddit API Wrapper", is a python package that allows for simple access to Reddit's API.

PRAW: The Python Reddit API Wrapper PRAW, an acronym for "Python Reddit API Wrapper", is a Python package that allows for simple access to Reddit's AP

Python Reddit API Wrapper Development 3k Dec 29, 2022
alpaca-trade-api-python is a python library for the Alpaca Commission Free Trading API.

alpaca-trade-api-python is a python library for the Alpaca Commission Free Trading API. It allows rapid trading algo development easily, with support for both REST and streaming data interfaces

Alpaca 1.5k Jan 9, 2023
WhatsApp Api Python - This documentation aims to exemplify the use of Moorse Whatsapp API in Python

WhatsApp API Python ChatBot Este repositório contém uma aplicação que se utiliza

Moorse.io 3 Jan 8, 2022
Official python API for Phish.AI public and private API to detect zero-day phishing websites

phish-ai-api Summary Official python API for Phish.AI public and private API to detect zero-day phishing websites How it Works (TLDR) Essentially we h

Phish.AI 168 May 17, 2022
Python API wrapper around Trello's API

A wrapper around the Trello API written in Python. Each Trello object is represented by a corresponding Python object. The attributes of these objects

Richard Kolkovich 904 Jan 2, 2023
A python to scratch API connector. Can fetch data from the API and send it back in cloud variables.

Scratch2py Scratch2py or S2py is a easy to use, versatile tool to communicate with the Scratch API Based of scratchclient by Raihan142857 Installation

null 20 Jun 18, 2022
Async ready API wrapper for Revolt API written in Python.

Mutiny Async ready API wrapper for Revolt API written in Python. Installation Python 3.9 or higher is required To install the library, you can just ru

null 16 Mar 29, 2022
🚀 An asynchronous python API wrapper meant to replace discord.py - Snappy discord api wrapper written with aiohttp & websockets

Pincer An asynchronous python API wrapper meant to replace discord.py ❗ The package is currently within the planning phase ?? Links |Join the discord

Pincer 125 Dec 26, 2022
wyscoutapi is an extremely basic API client for the Wyscout API (v2 & v3) for Python

wyscoutapi wyscoutapi is an extremely basic API client for the Wyscout API (v2 & v3). Usage Install with pip install wyscoutapi. To connect to the Wys

Ben Torvaney 11 Nov 22, 2022
Beyonic API Python official client library simplified examples using Flask, Django and Fast API.

Beyonic API Python official client library simplified examples using Flask, Django and Fast API.

Harun Mbaabu Mwenda 46 Sep 1, 2022
A Python API wrapper for the Twitter API!

PyTweet PyTweet is an api wrapper made for twitter using twitter's api version 2! Installation Windows py3 -m pip install PyTweet Linux python -m pip

TheFarGG 1 Nov 19, 2022