Skip to content

Instantly share code, notes, and snippets.

@madhurgupta10
Last active April 14, 2019 00:02
Show Gist options
  • Save madhurgupta10/4a0fd0dac408cb4bbc0bd3eabe5f7525 to your computer and use it in GitHub Desktop.
Save madhurgupta10/4a0fd0dac408cb4bbc0bd3eabe5f7525 to your computer and use it in GitHub Desktop.
Short Url using bitly with python
def shorturl():
import requests
import json
link = input("Enter url: ")
query_params = {'access_token': 'your key goes here, use generic key only',
'longUrl': link}
endpoint = 'https://api-ssl.bitly.com/v3/shorten'
response = requests.get(endpoint, params=query_params, verify=False)
data = json.loads(response.content)
print(data['data']['url'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment