· 6 years ago · Jan 13, 2020, 12:38 AM
1PASTEBINpaste
2
3Looking for our Scraping API? Check out the Scraping API documentation.
4Developers API
5This is the pastebin.com developers API documentation page. Here you can find all the information you need to get started with our API. If you have questions, feel free to contact us. If you are a developer, and you are building something for Pastebin which might benefit others as well, be sure to contact us, as we might be able to feature your creation on our tools page.
61. Your Unique Developer API Key
72. Creating A New Paste
83. Creating A New Paste, [Required Parameters]
94. Creating A New Paste, [Optional Parameters]
105. Creating A New Paste, The 'api_paste_format' Paramater In Detail
116. Creating A New Paste, The 'api_paste_expire_date' Paramater In Detail
127. Creating A New Paste, The 'api_paste_private' Paramater In Detail
138. Creating An 'api_user_key' Using The API Member Login System
149. Listing Pastes Created By A User
1510. Deleting A Paste Created By A User
1611. Getting A Users Information And Settings
1712. Getting raw paste output of users pastes including 'private' pastes
1813. Getting raw paste output of any 'public' & 'unlisted' pastes
19Your Unique Developer API Key
20Everybody using our API is required to use a valid Developer API Key. You automatically get a key when you become a member of Pastebin. For that reason we require you to be logged into your account to access this page. Your key is shown in the box below:
21f002b44ec0c45ca07b72ae339c0c37cf
22Creating A New Paste
23Creating a new paste via our API is very easy. You simply have to send a valid POST request to the url shown below. Please make sure you are sending the data
24as the UTF-8 charset.
25https://pastebin.com/api/api_post.php
26Below is a PHP example using curl how to create a new paste:
27$api_dev_key = 'f002b44ec0c45ca07b72ae339c0c37cf'; // your api_developer_key
28$api_paste_code = 'just some random text you :)'; // your paste text
29$api_paste_private = '1'; // 0=public 1=unlisted 2=private
30$api_paste_name = 'justmyfilename.php'; // name or title of your paste
31$api_paste_expire_date = '10M';
32$api_paste_format = 'php';
33$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
34$api_paste_name = urlencode($api_paste_name);
35$api_paste_code = urlencode($api_paste_code);
36
37$url = 'https://pastebin.com/api/api_post.php';
38$ch = curl_init($url);
39
40curl_setopt($ch, CURLOPT_POST, true);
41curl_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.'');
42curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
43curl_setopt($ch, CURLOPT_VERBOSE, 1);
44curl_setopt($ch, CURLOPT_NOBODY, 0);
45
46$response = curl_exec($ch);
47echo $response;
48Possible Good API Responses: (example)
49https://pastebin.com/UIFdu235s
50Possible Bad API Responses:
51Bad API request, invalid api_option
52Bad API request, invalid api_dev_key
53Bad API request, IP blocked
54Bad API request, maximum number of 25 unlisted pastes for your free account
55Bad API request, maximum number of 10 private pastes for your free account
56Bad API request, api_paste_code was empty
57Bad API request, maximum paste file size exceeded
58Bad API request, invalid api_expire_date
59Bad API request, invalid api_paste_private
60Bad API request, invalid api_paste_format
61Bad API request, invalid api_user_key
62Bad API request, invalid or expired api_user_key
63Creating A New Paste, [Required Parameters]
64Include all the following POST parameters when you request the url:
65
661. api_dev_key - which is your unique API Developers Key.
672. api_option - set as paste, this will indicate you want to create a new paste.
683. api_paste_code - this is the text that will be written inside your paste.
69
70Leaving any of these parameters out will result in an error.
71Creating A New Paste, [Optional Parameters]
72These parameters are not required when you create a new paste, but are possible to add:
73
741. api_user_key - this paramater is part of the login system, which is explained further down the page.
752. api_paste_name - this will be the name / title of your paste.
763. api_paste_format - this will be the syntax highlighting value, which is explained in detail further down the page.
774. api_paste_private - this makes a paste public, unlisted or private, public = 0, unlisted = 1, private = 2
785. api_paste_expire_date - this sets the expiration date of your paste, the values are explained futher down the page.
79Creating A New Paste, The 'api_paste_format' Paramater In Detail
80We 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.
81 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 blitzbasic = Blitz Basic b3d = Blitz3D bmx = BlitzMax bnf = BNF boo = BOO bf = BrainFuck c = C c_winapi = C (WinAPI) c_mac = C for Macs cil = C Intermediate Language csharp = C# 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 chaiscript = ChaiScript chapel = Chapel 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 (Oxygene) 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 Definition 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 text = None nsis = NullSoft Installer oberon2 = Oberon 2 objeck = Objeck Programming L... objc = Objective C ocaml = OCaml ocaml-brief = OCaml Brief octave = Octave oorexx = Open Object Rexx pf = OpenBSD PACKET FILTER glsl = OpenGL Shading oobas = Openoffice BASIC oracle11 = Oracle 11 oracle8 = Oracle 8 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 visualprolog = Visual Pro Log vb = VisualBasic visualfoxpro = VisualFoxPro whitespace = WhiteSpace whois = WHOIS winbatch = Winbatch xbasic = XBasic xml = XML xorg_conf = Xorg Config xpp = XPP yaml = YAML z80 = Z80 Assembler zxbasic = ZXBasic
82
83Creating A New Paste, The 'api_paste_expire_date' Paramater In Detail
84We have 9 valid values available which you can use with the api_paste_expire_date parameter:
85 N = Never
86 10M = 10 Minutes
87 1H = 1 Hour
88 1D = 1 Day
89 1W = 1 Week
90 2W = 2 Weeks
91 1M = 1 Month
92 6M = 6 Months
93 1Y = 1 Year
94Creating A New Paste, The 'api_paste_private' Paramater In Detail
95We have 3 valid values available which you can use with the api_paste_private parameter:
96 0 = Public
97 1 = Unlisted
98 2 = Private (only allowed in combination with api_user_key, as you have to be logged into your account to access the paste)
99Creating An 'api_user_key' Using The API Member Login System
100With 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:
101https://pastebin.com/api/api_login.php
102Include all the following POST parameters when you request the url:
1031. api_dev_key - this is your API Developer Key, in your case: f002b44ec0c45ca07b72ae339c0c37cf
1042. api_user_name - this is the username of the user you want to login.
1053. api_user_password - this is the password of the user you want to login.
106
107If 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.
108
109Below is a PHP example using curl how to create a valid api_user_key:
110$api_dev_key = 'f002b44ec0c45ca07b72ae339c0c37cf';
111$api_user_name = 'a_users_username';
112$api_user_password = 'a_users_password';
113$api_user_name = urlencode($api_user_name);
114$api_user_password = urlencode($api_user_password);
115$url = 'https://pastebin.com/api/api_login.php';
116$ch = curl_init($url);
117
118curl_setopt($ch, CURLOPT_POST, true);
119curl_setopt($ch, CURLOPT_POSTFIELDS, 'api_dev_key='.$api_dev_key.'&api_user_name='.$api_user_name.'&api_user_password='.$api_user_password.'');
120curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
121curl_setopt($ch, CURLOPT_VERBOSE, 1);
122curl_setopt($ch, CURLOPT_NOBODY, 0);
123
124$response = curl_exec($ch);
125echo $response;
126Possible Good API Responses: (example)
1276c6d3fe13b19bbd6e479b705df0a607f
128Possible Bad API Responses:
129Bad API request, use POST request, not GET
130Bad API request, invalid api_dev_key
131Bad API request, invalid login
132Bad API request, account not active
133Bad API request, invalid POST parameters
134If you quickly need to create a personal api_user_key, you can use this form to generate one.
135Listing Pastes Created By A User
136With 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:
137https://pastebin.com/api/api_post.php
138Include all the following POST parameters when you request the url:
1391. api_dev_key - this is your API Developer Key, in your case: f002b44ec0c45ca07b72ae339c0c37cf
1402. api_user_key - this is the session key of the logged in user. How to obtain such a key
1413. api_results_limit - this is not required, by default its set to 50, min value is 1, max value is 1000
1424. api_option - set as 'list'
143
144Below is a PHP example using curl how to list pastes:
145$api_dev_key = 'f002b44ec0c45ca07b72ae339c0c37cf';
146$api_user_key = '';
147$api_results_limit = '100';
148$url = 'https://pastebin.com/api/api_post.php';
149$ch = curl_init($url);
150
151curl_setopt($ch, CURLOPT_POST, true);
152curl_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.'');
153curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
154curl_setopt($ch, CURLOPT_VERBOSE, 1);
155curl_setopt($ch, CURLOPT_NOBODY, 0);
156
157$response = curl_exec($ch);
158echo $response;
159Below is an example output of a users paste listing:
160<paste>
161 <paste_key>0b42rwhf</paste_key>
162 <paste_date>1297953260</paste_date>
163 <paste_title>javascript test</paste_title>
164 <paste_size>15</paste_size>
165 <paste_expire_date>1297956860</paste_expire_date>
166 <paste_private>0</paste_private>
167 <paste_format_long>JavaScript</paste_format_long>
168 <paste_format_short>javascript</paste_format_short>
169 <paste_url>https://pastebin.com/0b42rwhf</paste_url>
170 <paste_hits>15</paste_hits>
171</paste>
172<paste>
173 <paste_key>0C343n0d</paste_key>
174 <paste_date>1297694343</paste_date>
175 <paste_title>Welcome To Pastebin V3</paste_title>
176 <paste_size>490</paste_size>
177 <paste_expire_date>0</paste_expire_date>
178 <paste_private>0</paste_private>
179 <paste_format_long>None</paste_format_long>
180 <paste_format_short>text</paste_format_short>
181 <paste_url>https://pastebin.com/0C343n0d</paste_url>
182 <paste_hits>65</paste_hits>
183</paste>
184Other Possible Good API Responses:
185No pastes found.
186Possible Bad API Responses:
187Bad API request, invalid api_option
188Bad API request, invalid api_dev_key
189Bad API request, invalid api_user_key
190Deleting A Paste Created By A User
191With 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:
192https://pastebin.com/api/api_post.php
193Include all the following POST parameters when you request the url:
1941. api_dev_key - this is your API Developer Key, in your case: f002b44ec0c45ca07b72ae339c0c37cf
1952. api_user_key - this is the session key of the logged in user. How to obtain such a key
1963. api_paste_key - this is the unique key of the paste you want to delete.
1974. api_option - set as 'delete'
198
199Below is a PHP example using curl how to create a valid 'api_user_key':
200$api_dev_key = 'f002b44ec0c45ca07b72ae339c0c37cf';
201$api_user_key = '';
202$api_paste_key = '';
203$url = 'https://pastebin.com/api/api_post.php';
204$ch = curl_init($url);
205
206curl_setopt($ch, CURLOPT_POST, true);
207curl_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.'');
208curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
209curl_setopt($ch, CURLOPT_VERBOSE, 1);
210curl_setopt($ch, CURLOPT_NOBODY, 0);
211
212$response = curl_exec($ch);
213echo $response;
214Possible Good API Responses:
215Paste Removed
216Possible Bad API Responses:
217Bad API request, invalid api_option
218Bad API request, invalid api_dev_key
219Bad API request, invalid api_user_key
220Bad API request, invalid permission to remove paste
221Getting A Users Information And Settings
222With 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:
223https://pastebin.com/api/api_post.php
224Include all the following POST parameters when you request the url:
2251. api_dev_key - this is your API Developer Key, in your case: f002b44ec0c45ca07b72ae339c0c37cf
2262. api_user_key - this is the session key of the logged in user. How to obtain such a key
2273. api_option - set as 'userdetails'
228
229Below is a PHP example using curl how to create a valid 'api_user_key':
230$api_dev_key = 'f002b44ec0c45ca07b72ae339c0c37cf';
231$api_user_key = '';
232$url = 'https://pastebin.com/api/api_post.php';
233$ch = curl_init($url);
234
235curl_setopt($ch, CURLOPT_POST, true);
236curl_setopt($ch, CURLOPT_POSTFIELDS, 'api_option=userdetails&api_user_key='.$api_user_key.'&api_dev_key='.$api_dev_key.'');
237curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
238curl_setopt($ch, CURLOPT_VERBOSE, 1);
239curl_setopt($ch, CURLOPT_NOBODY, 0);
240
241$response = curl_exec($ch);
242echo $response;
243Below is an example output of a user information listing:
244<user>
245 <user_name>wiz_kitty</user_name>
246 <user_format_short>text</user_format_short>
247 <user_expiration>N</user_expiration>
248 <user_avatar_url>https://pastebin.com/cache/a/1.jpg</user_avatar_url>
249 <user_private>1</user_private> (0 Public, 1 Unlisted, 2 Private)
250 <user_website>https://myawesomesite.com</user_website>
251 <user_email>oh@dear.com</user_email>
252 <user_location>New York</user_location>
253 <user_account_type>1</user_account_type> (0 normal, 1 PRO)
254</user>
255Possible Bad API Responses:
256Bad API request, invalid api_option
257Bad API request, invalid api_dev_key
258Bad API request, invalid api_user_key
259Getting raw paste output of users pastes including 'private' pastes
260With this API you can obtain the raw paste output of a users pastes, including private pastes:
261https://pastebin.com/api/api_raw.php
262Include all the following POST parameters when you request the url:
2631. api_dev_key - this is your API Developer Key, in your case: f002b44ec0c45ca07b72ae339c0c37cf
2642. api_user_key - this is the session key of the logged in user. How to obtain such a key
2653. api_paste_key - this is paste key you want to fetch the data from.
2664. api_option - set as 'show_paste'
267
268Below is a PHP example using curl how to fetch a users raw paste output:
269$api_dev_key = 'f002b44ec0c45ca07b72ae339c0c37cf';
270$api_user_key = '';
271$url = 'https://pastebin.com/api/api_raw.php';
272$ch = curl_init($url);
273
274curl_setopt($ch, CURLOPT_POST, true);
275curl_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');
276curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
277curl_setopt($ch, CURLOPT_VERBOSE, 1);
278curl_setopt($ch, CURLOPT_NOBODY, 0);
279
280$response = curl_exec($ch);
281echo $response;
282Possible Bad API Responses:
283Bad API request, invalid api_option
284Bad API request, invalid api_dev_key
285Bad API request, invalid api_user_key
286Bad API request, invalid permission to view this paste or invalid api_paste_key
287Getting raw paste output of any 'public' & 'unlisted' pastes
288This 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:
289https://pastebin.com/raw/
290Simply add the paste_key at the end of that url and you will get the raw output.
291TIP: If you are trying to scrape our content, check out our scraping API.
292Not a member of Pastebin yet?
293Sign Up, it unlocks many cool features!
294
295create new paste / dealsnew! / syntax languages / archive / faq / tools / night mode / api / scraping api
296privacy statement / cookies policy / terms of service / security disclosure / dmca / contact
297
298Dedicated Server Hosting by Steadfast
299Top