· 5 years ago · Sep 05, 2020, 12:44 AM
1$api_dev_key = 'YOUR API DEVELOPER KEY'; // your api_developer_key
2$api_paste_code = 'just some random text you :)'; // your paste text
3$api_paste_private = '1'; // 0=public 1=unlisted 2=private
4$api_paste_name = 'justmyfilename.php'; // name or title of your paste
5$api_paste_expire_date = '10M';
6$api_paste_format = 'php';
7$api_user_key = ''; // if an invalid or expired api_user_key is used, an error will spawn. If no api_user_key is used, a guest paste will be created
8$api_paste_name = urlencode($api_paste_name);
9$api_paste_code = urlencode($api_paste_code);
10
11$url = 'https://pastebin.com/api/api_post.php';
12$ch = curl_init($url);
13
14curl_setopt($ch, CURLOPT_POST, true);
15curl_setopt($ch, CURLOPT_POSTFIELDS, 'api_option=paste&api_user_key='.$api_user_key.'&api_paste_private='.$api_paste_private.'&api_paste_name='.$api_paste_name.'&api_paste_expire_date='.$api_paste_expire_date.'&api_paste_format='.$api_paste_format.'&api_dev_key='.$api_dev_key.'&api_paste_code='.$api_paste_code.'');
16curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
17curl_setopt($ch, CURLOPT_VERBOSE, 1);
18curl_setopt($ch, CURLOPT_NOBODY, 0);
19
20$response = curl_exec($ch);
21echo $response;
22Possible Good API Responses: (example)
23https://pastebin.com/UIFdu235s
24Possible Bad API Responses:
25Bad API request, invalid api_option
26Bad API request, invalid api_dev_key
27Bad API request, maximum number of 25 unlisted pastes for your free account
28Bad API request, maximum number of 10 private pastes for your free account
29Bad API request, api_paste_code was empty
30Bad API request, maximum paste file size exceeded
31Bad API request, invalid api_paste_expire_date
32Bad API request, invalid api_paste_private
33Bad API request, invalid api_paste_format
34Bad API request, invalid api_user_key
35Bad API request, invalid or expired api_user_key
36Creating A New Paste, [Required Parameters]
37Include all the following POST parameters when you request the url:
38
391. api_dev_key - which is your unique API Developers Key.
402. api_option - set as paste, this will indicate you want to create a new paste.
413. api_paste_code - this is the text that will be written inside your paste.
42
43Leaving any of these parameters out will result in an error.
44Creating A New Paste, [Optional Parameters]
45These parameters are not required when you create a new paste, but are possible to add:
46
471. api_user_key - this paramater is part of the login system, which is explained further down the page.
482. api_paste_name - this will be the name / title of your paste.
493. api_paste_format - this will be the syntax highlighting value, which is explained in detail further down the page.
504. api_paste_private - this makes a paste public, unlisted or private, public = 0, unlisted = 1, private = 2
515. api_paste_expire_date - this sets the expiration date of your paste, the values are explained futher down the page.
52Creating A New Paste, The 'api_paste_format' Paramater In Detail
53We have over 200 syntax highlighting options available, below you can find a list of all the possible values you can use in combination with api_paste_format. Always include the value on the left from the list below, the value on the right is just the full name of the language in question.
54 4cs = 4CS 6502acme = 6502 ACME Cross Asse... 6502kickass = 6502 Kick Assembler 6502tasm = 6502 TASM/64TASS abap = ABAP actionscript = ActionScript actionscript3 = ActionScript 3 ada = Ada aimms = AIMMS algol68 = ALGOL 68 apache = Apache Log applescript = AppleScript apt_sources = APT Sources arduino = Arduino arm = ARM asm = ASM (NASM) asp = ASP asymptote = Asymptote autoconf = autoconf autohotkey = Autohotkey autoit = AutoIt avisynth = Avisynth awk = Awk bascomavr = BASCOM AVR bash = Bash basic4gl = Basic4GL dos = Batch bibtex = BibTeX b3d = Blitz3D blitzbasic = Blitz Basic bmx = BlitzMax bnf = BNF boo = BOO bf = BrainFuck c = C csharp = C# c_winapi = C (WinAPI) cpp = C++ cpp-winapi = C++ (WinAPI) cpp-qt = C++ (with Qt extensi... c_loadrunner = C: Loadrunner caddcl = CAD DCL cadlisp = CAD Lisp ceylon = Ceylon cfdg = CFDG c_mac = C for Macs chaiscript = ChaiScript chapel = Chapel cil = C Intermediate Langu... clojure = Clojure klonec = Clone C klonecpp = Clone C++ cmake = CMake cobol = COBOL coffeescript = CoffeeScript cfm = ColdFusion css = CSS cuesheet = Cuesheet d = D dart = Dart dcl = DCL dcpu16 = DCPU-16 dcs = DCS delphi = Delphi oxygene = Delphi Prism (Oxygen... diff = Diff div = DIV dot = DOT e = E ezt = Easytrieve ecmascript = ECMAScript eiffel = Eiffel email = Email epc = EPC erlang = Erlang euphoria = Euphoria fsharp = F# falcon = Falcon filemaker = Filemaker fo = FO Language f1 = Formula One fortran = Fortran freebasic = FreeBasic freeswitch = FreeSWITCH gambas = GAMBAS gml = Game Maker gdb = GDB genero = Genero genie = Genie gettext = GetText go = Go groovy = Groovy gwbasic = GwBasic haskell = Haskell haxe = Haxe hicest = HicEst hq9plus = HQ9 Plus html4strict = HTML html5 = HTML 5 icon = Icon idl = IDL ini = INI file inno = Inno Script intercal = INTERCAL io = IO ispfpanel = ISPF Panel Definitio... j = J java = Java java5 = Java 5 javascript = JavaScript jcl = JCL jquery = jQuery json = JSON julia = Julia kixtart = KiXtart kotlin = Kotlin latex = Latex ldif = LDIF lb = Liberty BASIC lsl2 = Linden Scripting lisp = Lisp llvm = LLVM locobasic = Loco Basic logtalk = Logtalk lolcode = LOL Code lotusformulas = Lotus Formulas lotusscript = Lotus Script lscript = LScript lua = Lua m68k = M68000 Assembler magiksf = MagikSF make = Make mapbasic = MapBasic markdown = Markdown matlab = MatLab mirc = mIRC mmix = MIX Assembler modula2 = Modula 2 modula3 = Modula 3 68000devpac = Motorola 68000 HiSof... mpasm = MPASM mxml = MXML mysql = MySQL nagios = Nagios netrexx = NetRexx newlisp = newLISP nginx = Nginx nim = Nim nsis = NullSoft Installer oberon2 = Oberon 2 objeck = Objeck Programming L... objc = Objective C ocaml = OCaml ocaml-brief = OCaml Brief octave = Octave pf = OpenBSD PACKET FILTE... glsl = OpenGL Shading oorexx = Open Object Rexx oobas = Openoffice BASIC oracle8 = Oracle 8 oracle11 = Oracle 11 oz = Oz parasail = ParaSail parigp = PARI/GP pascal = Pascal pawn = Pawn pcre = PCRE per = Per perl = Perl perl6 = Perl 6 php = PHP php-brief = PHP Brief pic16 = Pic 16 pike = Pike pixelbender = Pixel Bender pli = PL/I plsql = PL/SQL postgresql = PostgreSQL postscript = PostScript povray = POV-Ray powerbuilder = PowerBuilder powershell = PowerShell proftpd = ProFTPd progress = Progress prolog = Prolog properties = Properties providex = ProvideX puppet = Puppet purebasic = PureBasic pycon = PyCon python = Python pys60 = Python for S60 q = q/kdb+ qbasic = QBasic qml = QML rsplus = R racket = Racket rails = Rails rbs = RBScript rebol = REBOL reg = REG rexx = Rexx robots = Robots rpmspec = RPM Spec ruby = Ruby gnuplot = Ruby Gnuplot rust = Rust sas = SAS scala = Scala scheme = Scheme scilab = Scilab scl = SCL sdlbasic = SdlBasic smalltalk = Smalltalk smarty = Smarty spark = SPARK sparql = SPARQL sqf = SQF sql = SQL standardml = StandardML stonescript = StoneScript sclang = SuperCollider swift = Swift systemverilog = SystemVerilog tsql = T-SQL tcl = TCL teraterm = Tera Term thinbasic = thinBasic typoscript = TypoScript unicon = Unicon uscript = UnrealScript upc = UPC urbi = Urbi vala = Vala vbnet = VB.NET vbscript = VBScript vedit = Vedit verilog = VeriLog vhdl = VHDL vim = VIM vb = VisualBasic visualfoxpro = VisualFoxPro visualprolog = Visual Pro Log whitespace = WhiteSpace whois = WHOIS winbatch = Winbatch xbasic = XBasic xml = XML xorg_conf = Xorg Config xpp = XPP yaml = YAML z80 = Z80 Assembler zxbasic = ZXBasic
55
56Creating A New Paste, The 'api_paste_expire_date' Paramater In Detail
57We have 9 valid values available which you can use with the api_paste_expire_date parameter:
58 N = Never
59 10M = 10 Minutes
60 1H = 1 Hour
61 1D = 1 Day
62 1W = 1 Week
63 2W = 2 Weeks
64 1M = 1 Month
65 6M = 6 Months
66 1Y = 1 Year
67Creating A New Paste, The 'api_paste_private' Paramater In Detail
68We have 3 valid values available which you can use with the api_paste_private parameter:
69 0 = Public
70 1 = Unlisted
71 2 = Private (only allowed in combination with api_user_key, as you have to be logged into your account to access the paste)
72Creating An 'api_user_key' Using The API Member Login System
73With this API we allow you to create applications which use the Pastebin members system. Sending a valid POST request to our API login system will return a unique api_user_key which can then be used to create a paste as a logged in user. Please send the request to the link shown below:
74https://pastebin.com/api/api_login.php
75Include all the following POST parameters when you request the url:
761. api_dev_key - this is your API Developer Key, in your case: YOUR API DEVELOPER KEY
772. api_user_name - this is the username of the user you want to login.
783. api_user_password - this is the password of the user you want to login.
79
80If all 3 values match, a valid user session key will be returned. This key can be used as the api_user_key paramater. Only one key can be active at the same time for the same user. This key does not expire, unless a new one is generated. We recommend creating just one, then caching that key locally as it does not expire.
81
82Below is a PHP example using curl how to create a valid api_user_key:
83$api_dev_key = 'YOUR API DEVELOPER KEY';
84$api_user_name = 'a_users_username';
85$api_user_password = 'a_users_password';
86$api_user_name = urlencode($api_user_name);
87$api_user_password = urlencode($api_user_password);
88$url = 'https://pastebin.com/api/api_login.php';
89$ch = curl_init($url);
90
91curl_setopt($ch, CURLOPT_POST, true);
92curl_setopt($ch, CURLOPT_POSTFIELDS, 'api_dev_key='.$api_dev_key.'&api_user_name='.$api_user_name.'&api_user_password='.$api_user_password.'');
93curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
94curl_setopt($ch, CURLOPT_VERBOSE, 1);
95curl_setopt($ch, CURLOPT_NOBODY, 0);
96
97$response = curl_exec($ch);
98echo $response;
99Possible Good API Responses: (example)
1006c6d3fe13b19bbd6e479b705df0a607f
101Possible Bad API Responses:
102Bad API request, use POST request, not GET
103Bad API request, invalid api_dev_key
104Bad API request, invalid login
105Bad API request, account not active
106Bad API request, invalid POST parameters
107Listing Pastes Created By A User
108With this API you can list all the pastes created by a certain user. You will need send a valid POST request to the url below to access the data:
109https://pastebin.com/api/api_post.php
110Include all the following POST parameters when you request the url:
1111. api_dev_key - this is your API Developer Key, in your case: YOUR API DEVELOPER KEY
1122. api_user_key - this is the session key of the logged in user. How to obtain such a key
1133. api_results_limit - this is not required, by default its set to 50, min value is 1, max value is 1000
1144. api_option - set as 'list'
115
116Below is a PHP example using curl how to list pastes:
117$api_dev_key = 'YOUR API DEVELOPER KEY';
118$api_user_key = '';
119$api_results_limit = '100';
120$url = 'https://pastebin.com/api/api_post.php';
121$ch = curl_init($url);
122
123curl_setopt($ch, CURLOPT_POST, true);
124curl_setopt($ch, CURLOPT_POSTFIELDS, 'api_option=list&api_user_key='.$api_user_key.'&api_dev_key='.$api_dev_key.'&api_results_limit='.$api_results_limit.'');
125curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
126curl_setopt($ch, CURLOPT_VERBOSE, 1);
127curl_setopt($ch, CURLOPT_NOBODY, 0);
128
129$response = curl_exec($ch);
130echo $response;
131Below is an example output of a users paste listing:
132<paste>
133 <paste_key>0b42rwhf</paste_key>
134 <paste_date>1297953260</paste_date>
135 <paste_title>javascript test</paste_title>
136 <paste_size>15</paste_size>
137 <paste_expire_date>1297956860</paste_expire_date>
138 <paste_private>0</paste_private>
139 <paste_format_long>JavaScript</paste_format_long>
140 <paste_format_short>javascript</paste_format_short>
141 <paste_url>https://pastebin.com/0b42rwhf</paste_url>
142 <paste_hits>15</paste_hits>
143</paste>
144<paste>
145 <paste_key>0C343n0d</paste_key>
146 <paste_date>1297694343</paste_date>
147 <paste_title>Welcome To Pastebin V3</paste_title>
148 <paste_size>490</paste_size>
149 <paste_expire_date>0</paste_expire_date>
150 <paste_private>0</paste_private>
151 <paste_format_long>None</paste_format_long>
152 <paste_format_short>text</paste_format_short>
153 <paste_url>https://pastebin.com/0C343n0d</paste_url>
154 <paste_hits>65</paste_hits>
155</paste>
156Other Possible Good API Responses:
157No pastes found.
158Possible Bad API Responses:
159Bad API request, invalid api_option
160Bad API request, invalid api_dev_key
161Bad API request, invalid api_user_key
162Deleting A Paste Created By A User
163With this API you can delete pastes created by certain users. You will need to send a valid POST request to the url below to access the data:
164https://pastebin.com/api/api_post.php
165Include all the following POST parameters when you request the url:
1661. api_dev_key - this is your API Developer Key, in your case: YOUR API DEVELOPER KEY
1672. api_user_key - this is the session key of the logged in user. How to obtain such a key
1683. api_paste_key - this is the unique key of the paste you want to delete.
1694. api_option - set as 'delete'
170
171Below is a PHP example using curl how to create a valid 'api_user_key':
172$api_dev_key = 'YOUR API DEVELOPER KEY';
173$api_user_key = '';
174$api_paste_key = '';
175$url = 'https://pastebin.com/api/api_post.php';
176$ch = curl_init($url);
177
178curl_setopt($ch, CURLOPT_POST, true);
179curl_setopt($ch, CURLOPT_POSTFIELDS, 'api_option=delete&api_user_key='.$api_user_key.'&api_dev_key='.$api_dev_key.'&api_paste_key='.$api_paste_key.'');
180curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
181curl_setopt($ch, CURLOPT_VERBOSE, 1);
182curl_setopt($ch, CURLOPT_NOBODY, 0);
183
184$response = curl_exec($ch);
185echo $response;
186Possible Good API Responses:
187Paste Removed
188Possible Bad API Responses:
189Bad API request, invalid api_option
190Bad API request, invalid api_dev_key
191Bad API request, invalid api_user_key
192Bad API request, invalid permission to remove paste
193Getting A Users Information And Settings
194With this API you can obtain a users personal information and certain settings. You will need to send a valid POST request to the url below to access the data:
195https://pastebin.com/api/api_post.php
196Include all the following POST parameters when you request the url:
1971. api_dev_key - this is your API Developer Key, in your case: YOUR API DEVELOPER KEY
1982. api_user_key - this is the session key of the logged in user. How to obtain such a key
1993. api_option - set as 'userdetails'
200
201Below is a PHP example using curl how to create a valid 'api_user_key':
202$api_dev_key = 'YOUR API DEVELOPER KEY';
203$api_user_key = '';
204$url = 'https://pastebin.com/api/api_post.php';
205$ch = curl_init($url);
206
207curl_setopt($ch, CURLOPT_POST, true);
208curl_setopt($ch, CURLOPT_POSTFIELDS, 'api_option=userdetails&api_user_key='.$api_user_key.'&api_dev_key='.$api_dev_key.'');
209curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
210curl_setopt($ch, CURLOPT_VERBOSE, 1);
211curl_setopt($ch, CURLOPT_NOBODY, 0);
212
213$response = curl_exec($ch);
214echo $response;
215Below is an example output of a user information listing:
216<user>
217 <user_name>wiz_kitty</user_name>
218 <user_format_short>text</user_format_short>
219 <user_expiration>N</user_expiration>
220 <user_avatar_url>https://pastebin.com/cache/a/1.jpg</user_avatar_url>
221 <user_private>1</user_private> (0 Public, 1 Unlisted, 2 Private)
222 <user_website>https://myawesomesite.com</user_website>
223 <user_email>oh@dear.com</user_email>
224 <user_location>New York</user_location>
225 <user_account_type>1</user_account_type> (0 normal, 1 PRO)
226</user>
227Possible Bad API Responses:
228Bad API request, invalid api_option
229Bad API request, invalid api_dev_key
230Bad API request, invalid api_user_key
231Getting raw paste output of users pastes including 'private' pastes
232With this API you can obtain the raw paste output of a users pastes, including private pastes:
233https://pastebin.com/api/api_raw.php
234Include all the following POST parameters when you request the url:
2351. api_dev_key - this is your API Developer Key, in your case: YOUR API DEVELOPER KEY
2362. api_user_key - this is the session key of the logged in user. How to obtain such a key
2373. api_paste_key - this is paste key you want to fetch the data from.
2384. api_option - set as 'show_paste'
239
240Below is a PHP example using curl how to fetch a users raw paste output:
241$api_dev_key = 'YOUR API DEVELOPER KEY';
242$api_user_key = '';
243$url = 'https://pastebin.com/api/api_raw.php';
244$ch = curl_init($url);
245
246curl_setopt($ch, CURLOPT_POST, true);
247curl_setopt($ch, CURLOPT_POSTFIELDS, 'api_option=show_paste&api_user_key='.$api_user_key.'&api_dev_key='.$api_dev_key.'&api_paste_key=A_VALID_PASTE_KEY_HERE');
248curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
249curl_setopt($ch, CURLOPT_VERBOSE, 1);
250curl_setopt($ch, CURLOPT_NOBODY, 0);
251
252$response = curl_exec($ch);
253echo $response;
254Possible Bad API Responses:
255Bad API request, invalid api_option
256Bad API request, invalid api_dev_key
257Bad API request, invalid api_user_key
258Bad API request, invalid permission to view this paste or invalid api_paste_key
259Getting raw paste output of any 'public' & 'unlisted' pastes
260This option is actually not part of our API, but you might still want to use it. To get the raw output of any public or unlisted paste you can use our raw data output url:
261https://pastebin.com/raw/
262Simply add the paste_key at the end of that url and you will get the raw output.
263TIP: If you are trying to scrape our content, check out our scraping API.
264Public Pastes
265Erettsegi 2015 majus
266Python | 47 min ago
267Untitled
268Java | 1 hour ago
269Attendance Type Settings Overview
270T-SQL | 1 hour ago
271script or module
272Perl | 2 hours ago
273chamber
274Lua | 2 hours ago
275Pong
276Go | 2 hours ago
277Untitled
278C# | 2 hours ago
279cod zombies v1.0
280Lua | 2 hours ago
281