How to Create Pastes Programmatically: Complete API Integration Guide
PasteTemp offers a clean REST API that allows developers to create, retrieve, and manage pastes programmatically. Whether you are building CI/CD pipelines, integrating paste sharing into your application, or automating reporting workflows, the API provides all the functionality available through the web interface.
The API is designed around RESTful principles with predictable resource-oriented URLs, standard HTTP methods, and JSON request and response formats. Authentication is handled via API keys, which are available to premium users through their account settings.
To get started, you need an API key from your PasteTemp account settings page (premium feature). Once you have your key, you can make requests to the base URL https://api.pastetemp.com/v1. All requests must include the API key in the Authorization header.
Creating a paste is a simple POST request. You send the content, expiration time in minutes, and optionally a password. The API returns a unique paste ID and the shareable URL. Here is a curl example: curl -X POST https://api.pastetemp.com/v1/pastes -H 'Authorization: Bearer YOUR_API_KEY' -H 'Content-Type: application/json' -d '{"content": "Hello World", "expires_in": 5}'. The response includes the paste ID and URL.
Retrieving a paste is equally straightforward with a GET request to the paste ID endpoint. The API returns the paste content, creation time, expiration time, and view count. For password-protected pastes, you need to include the password in the request body.
Error handling follows standard HTTP conventions. A 200 response indicates success, 400 indicates a bad request (missing required fields), 401 indicates authentication failure, 404 indicates the paste was not found or has expired, and 429 indicates rate limiting. Each error response includes a descriptive message to help with debugging.
Rate limiting is applied per API key: 100 requests per hour for Monthly Basic, 500 per hour for Annual, and 1000 per hour for Lifetime plans. The response headers include X-RateLimit-Remaining and X-RateLimit-Reset for monitoring usage.
For JavaScript developers, here is a simple integration using fetch: const response = await fetch('https://api.pastetemp.com/v1/pastes', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ content: 'Hello from JavaScript!', expires_in: 10 }) }); const data = await response.json(); console.log(data.url);
The API is designed to be simple enough for quick scripts while powerful enough for production integration. Whether you are a solo developer automating your workflow or a team integrating paste sharing into your tools, the PasteTemp API provides the functionality you need with minimal overhead.
Frequently Asked Questions
Do I need an API key to use the PasteTemp API?
Yes, API keys are required for authentication and are available to premium plan users.
What programming languages can I use with the API?
Any language that supports HTTP requests: curl, JavaScript, Python, Ruby, Go, PHP, Java, and more.
What is the rate limit for the API?
100 requests/hour for Monthly Basic, 500/hour for Annual, and 1000/hour for Lifetime plans.