· 6 years ago · Apr 17, 2020, 02:18 AM
1
2 importing the requests library
3import requests
4
5# defining the api-endpoint
6API_ENDPOINT = "http://pastebin.com/api/api_post.php"
7
8# your API key here
9API_KEY = "XXXXXXXXXXXXXXXXX"
10
11# your source code here
12source_code =
13
14# data to be sent to api
15data = {'api_dev_key':API_KEY,
16 'api_option':'paste',
17 'api_paste_code':source_code,
18 'api_paste_format':'python'}
19
20# sending post request and saving response as response object
21r = requests.post(url = API_ENDPOINT, data = data)