python library to the bitly api

Overview

bitly API python library

Installation

pip install bitly_api

Run tests

Your username is the lowercase name shown when you login to bitly, your access token can be fetched using the following ( http://dev.bitly.com/authentication.html ):

curl -u "username:password" -X POST "https://api-ssl.bitly.com/oauth/access_token"

To run the tests either export the environment variable or set it up inline before calling nosetests:

bitly-api-python $ BITLY_ACCESS_TOKEN=<accesstoken> nosetests

API Documentation

http://dev.bitly.com/

Comments
  • Compatibility with Python 3

    Compatibility with Python 3

    It doesn't work in the current form on python 3.3. There are some changes required, like bitly_api.bitly_api instead of bitly_api, replacing urllib2 with urllib.request, replacing cStringIO with io.BytesIO, etc.

    opened by extesy 7
  • Not all parameters are strings, _utf8 assumes that they all are

    Not all parameters are strings, _utf8 assumes that they all are

    If I call:

      link_clicks(link="http://bitly.com/Wozuff", rollup=False, unit="hour", units=-1)
    

    with an integer units parameter (as noted in your docs), it throws:

    ...
    bitly_api/bitly_api.pyc in _utf8(s)
    ...
    ---> 24     assert isinstance(s, str)
    

    If you provide a string for units then

    _call_oauth2_metrics(self, endpoint, params, unit, units, tz_offset, rollup, limit)
    ...
    --> 632   assert isinstance(units, int), "Unit (%r) must be integer" % units
    
    

    throws an error.

    Why does _uft8 assume that every parameter is a string?

    opened by ianozsvald 7
  • Set or edit tags using python client

    Set or edit tags using python client

    I notice that there does not seem to be a way to set the tag for links through the client, only bundles, yet from reading online bundles are deprecated.

    Is there away to set/get tags using the API right now?

    Thx.

    opened by rkpatel33 6
  • Username/AccessToken provided via Environment variables

    Username/AccessToken provided via Environment variables

    Username and AccessToken are imported using environment variables. If they're missing then a useful error is raised. README updated to explain how to set this up, doc added in test_bitly_api.py to explain how to run the test.

    One test changed in test_bitly_api as the 'test1' key is a valid bitly key, maybe this entered the keyspace? I've added a longer random string, I don't know if this keeps the same meaning to the test (this needs validation).

    opened by ianozsvald 5
  • RATE_LIMIT_EXCEEDED when using nosetests

    RATE_LIMIT_EXCEEDED when using nosetests

    Having just checked out the repo I ran the tests and received:

    $ nosetests test_bitly_api.py EE..

    ERROR: test_bitly_api.testApi ... raise BitlyError(data.get('status_code', 500), data.get('status_txt', 'UNKNOWN_ERROR')) BitlyError: RATE_LIMIT_EXCEEDED ... ERROR: test_bitly_api.testExpand ... raise BitlyError(data.get('status_code', 500), data.get('status_txt', 'UNKNOWN_ERROR')) BitlyError: RATE_LIMIT_EXCEEDED

    Can your API key be whitelisted to allow these tests to pass, or perhaps you should force us to use our own API key (environment variable? local config file?), such that all the tests pass on a clean checkout?

    opened by ianozsvald 3
  • INVALID_ARG_ACCESS_TOKEN on valid access token.

    INVALID_ARG_ACCESS_TOKEN on valid access token.

    I'm continually getting this error when I try to shorten a url. My code is as follows:

    import bitly_api as bitly
    
    bitly_api = bitly.Connection(access_token='R_fsjlkasdfsd')
    bitly_api.shorten('http://example.com')
    

    Which returns this traceback:

    >>> bitly_api/bitly_api.py", line 87, in shorten
        data = self._call(self.host, 'v3/shorten', params, self.secret)
      File "/Users/brianabelson/.virtualenvs/newslynx/lib/python2.7/site-packages/bitly_api/bitly_api.py", line 789, in _call
        data.get('status_txt', 'UNKNOWN_ERROR'))
    BitlyError: INVALID_ARG_ACCESS_TOKEN
    

    I'm assuming it's not the library, but nothing seems to work (even repeatedly resetting my access token)

    opened by abelsonlive 2
  • Efficient Way for Aggregate Call?

    Efficient Way for Aggregate Call?

    Hi,

    I went through the developer documentation, realized that there's no direct endpoints that provides aggregated information.

    So I went ahead and used ThreadPool with a concurrency of 5 to try to improve sequential calls of all 11 endpoints I needed.

    Here's the gist, let me know if there's any way to do it from the client side that could improve it!

    https://gist.github.com/woozyking/4ad49ded84effdce6ef3

    Or, please point me to the right documentation where there are aggregated endpoints :)

    opened by woozyking 2
  • Is this package supported anymore?

    Is this package supported anymore?

    I had a couple of older accounts and found that I'm getting all kinds of results.

    Worked.

    import bitly_api
    c = bitly_api.Connection('chavneor1','R_xxxx')
    # or to use oauth2 endpoints
    c.shorten('http://www.google.com/')
    

    Now dosn't work.

    import bitly_api
    c = bitly_api.Connection('chavneor1','R_xxxx')
    # or to use oauth2 endpoints
    c.shorten('http://www.google.com/')
    
     File "C:\Users\Casey\Envs\campuslists-website\lib\site-packages\bitly_api\bitly_api.py", line 87, in shorten
       data = self._call(self.host, 'v3/shorten', params, self.secret)
     File "C:\Users\Casey\Envs\campuslists-website\lib\site-packages\bitly_api\bitly_api.py", line 789, in _call
        data.get('status_txt', 'UNKNOWN_ERROR'))
    BitlyError: INVALID_LOGIN
    
    

    Nothing seemed to change. Also trying to assign the user or key via a variable throws unknown errors.

    Ideas?

    opened by chavenor 1
  • 0.2 removed from PyPi?

    0.2 removed from PyPi?

    Getting this error when trying to install from my requirements.txt:

    Downloading/unpacking bitly-api==0.2 (from -r requirements.txt (line 71))
      Could not find a version that satisfies the requirement bitly-api==0.2 (from -r requirements.txt (line 71)) (from versions: 0.3)
    

    I lock versions via pip freeze and I shouldn't have to upgrade to 0.3 when I know that 0.2 works fine, especially when all I'm trying to do is set up my project on a new server. Any reason why 0.2 was removed from PyPi?

    opened by benwilber 1
  • Python 2 and 3 compatibility

    Python 2 and 3 compatibility

    • Drop PyCURL, since it's not Py3k compatible.
    • Drop bitly_http module, just inline urllib(2) code.
    • Steal *_types lists from six.
    • Update isinstance calls.
    • Update excepts.
    • Decode response body as utf-8.
    • Drop simplejson import, just use json
    • Should be compatible with >=2.6.
    opened by jsocol 1
  • Duplicated method name bundle_collaborator_remove in Connection

    Duplicated method name bundle_collaborator_remove in Connection

    The pep8 module discovered this duplicated method, I'm not sure which of the two endpoints are the correct choice:

     class Connection(object):
        def bundle_collaborator_remove(self, bundle_link, collaborator):
            """remove a collaborator from a bundle"""
            params = dict(bundle_link=bundle_link)
            params["collaborator"] = collaborator
            data = self._call_oauth2_metrics("v3/bundle/collaborator_remove", params)
            return data
        def bundle_collaborator_remove(self, bundle_link, collaborator):
            """remove a pending collaborator from a bundle"""
            params = dict(bundle_link=bundle_link)
            params["collaborator"] = collaborator
            data = self._call_oauth2_metrics("v3/bundle/pending_collaborator_remove", params)
            return data
    
    opened by ianozsvald 1
  • Is this project/library dead ?

    Is this project/library dead ?

    With python-3 it throws error ImportError: cannot import name 'Connection'. There was a pull request (#41 ) made 2 years ago but hasn't merged yet.

    Is this this project/library dead ? If so please remove the link to this page from https://dev.bitly.com/code_libraries.html

    opened by vjcalel 1
  • Connection._call timeout argument is unused

    Connection._call timeout argument is unused

    The Connection._call timeout argument defaults to 5000 but seems to be unused. https://github.com/bitly/bitly-api-python/blob/master/bitly_api/bitly_api.py#L774

    opened by pramttl 1
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
Python API wrapper library for Convex Value API

convex-value-python Python API wrapper library for Convex Value API. Further Links: Convex Value homepage @ConvexValue on Twitter JB on Twitter Authen

Aaron DeVera 2 May 11, 2022
This an API wrapper library for the OpenSea API written in Python 3.

OpenSea NFT API Python 3 wrapper This an API wrapper library for the OpenSea API written in Python 3. The library provides a simplified interface to f

Attila Tóth 159 Dec 26, 2022
Aio-binance-library - Async library for connecting to the Binance API on Python

aio-binance-library Async library for connecting to the Binance API on Python Th

GRinvest 10 Nov 21, 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
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
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
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
A new coin listing alert bot using Python, Flask, MongoDB, Telegram API and Binance API

Bzzmans New Coin Listing Detection Bot Architecture About Project Work in progress. This bot basically gets new coin listings from Binance using Binan

Eyüp Barlas 21 May 31, 2022
YARSAW is an Async Python API Wrapper for the Random Stuff API.

Yet Another Random Stuff API Wrapper - YARSAW YARSAW is an Async Python API Wrapper for the Random Stuff API. This module makes it simpler for you to

Bruce 6 Mar 27, 2022
Python API Client for Twitter API v2

?? Python Client For Twitter API v2 ?? Why Twitter Stream ? Twitter-Stream.py a python API client for Twitter API v2 now supports FilteredStream, Samp

Twitivity 31 Nov 19, 2022
EpikCord.py - This is an API Wrapper for Discord's API for Python

EpikCord.py - This is an API Wrapper for Discord's API for Python! We've decided not to fork discord.py and start completely from scratch for a new, better structuring system!

EpikHost 28 Oct 10, 2022
A simple Python API wrapper for Cloudflare Stream's API.

python-cloudflare-stream A basic Python API wrapper for working with Cloudflare Stream. Arbington.com started off using Cloudflare Stream. We used the

Arbington 3 Sep 8, 2022