Code Monkey home page Code Monkey logo

bitly_api_examples's Introduction

bitly_api_examples

Various scripts that do useful things with Bitly's API endpoints

link_details.py

This script generates click counts per day for the Bitlink you specify.

The script was written to work with Python 2.7, and requires the requests library. A requirements.txt file is included for use with pip.

The script requires you to supply three arguments, your Bitly account access token (https://bitly.com/a/oauth_apps and generate the Generic Access Token), the Bitlink for which you want click data by day, and the filename of the CSV you want to hold the script's output.

To run the script:

python link_details.py XXXXXXXXXXXXXXXXXX output.csv http://bit.ly/123ABC

recent_links_detail_report.py

This script generates click counts per country for the most-recently-created 100 Bitlinks in your account, for the past month.

The script was written to work with Python 2.7, and requires the requests library. A requirements.txt file is included for use with pip.

The script requires you to supply two arguments, your Bitly account access token (https://bitly.com/a/oauth_apps and generate the Generic Access Token), and the filename of the CSV you want to hold the script's output.

To run the script:

python recent_links_detail_report.py XXXXXXXXXXXXXXXXXX output.csv

shorten_links.py

This script shortens URLs and generates a CSV of the output.

The script was written to work with Python 2.7, and requires the requests library. A requirements.txt file is included for use with pip.

The script requires two arguments, your Bitly account access token (https://bitly.com/a/oauth_apps and generate the Generic Access Token), and the name of the file containing the URLs you want to shorten. The URLs should be one URL per line.

The script takes one optional argument, "rate_limit". If you are a free user, or generally don't want to bother worrying about it, the script defaults to the free use rate limit of 1000 calls to shorten a URL per hour. If you are a paid user and thus have a higher rate limit, enter your actual rate limit and the script will run more rapidly. Input a rate limit that is higher than your actual limit, and you will get back RATE_LIMIT_EXCEEDED errors.

To run the script:

python shorten_links.py --access_token=XXXXXXXXXXXXXX --filename=input.txt --rate_limit=15000

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.