Guide: Set Up FetchAPI in 60 Seconds with Just curl
The fastest way to add durability to your API integrations.
Most developer tools require you to install a heavy SDK, configure a complex client, and learn a new set of abstractions. FetchAPI is different. It's built on the most universal interface in software: the HTTP request.
In this guide, we'll show you how to set up FetchAPI and make your first durable call using nothing but curl.
1. Get Your API Key
First, sign up at fetchapi.dev. Once you're in the dashboard, navigate to the API Keys section and copy your secret key. It will look something like relay_sk_....
2. Make Your First Call
Let's start with a simple GET request. We'll use httpbin.org as our target endpoint.
curl -X POST https://api.fetchapi.dev/v1/fetch \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://httpbin.org/get",
"method": "GET"
}'This request returns a call_id. FetchAPI has now taken responsibility for this request. Even if httpbin.org is down, we'll ensure the call eventually succeeds.
3. Check the Status
You can check the status of any call using its ID. This is useful for debugging or for long-running requests.
curl https://api.fetchapi.dev/v1/calls/CALL_ID \
-H "Authorization: Bearer YOUR_API_KEY"4. Add Retries
By default, FetchAPI uses a smart retry strategy. But you can customize it to fit your specific needs.
curl -X POST https://api.fetchapi.dev/v1/fetch \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"url": "https://api.example.com/data",
"method": "POST",
"retry": {
"maxAttempts": 5,
"backoff": "exponential"
}
}'5. Use Idempotency
To prevent duplicate actions (like double-charging a customer), use an idempotency key. If you send the same key twice, we'll return the cached result of the first successful call.
curl -X POST https://api.fetchapi.dev/v1/fetch \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: order_123" \
-d '{
"url": "https://api.stripe.com/v1/charges",
"method": "POST"
}'6. Set Up a Callback
Instead of polling for status, you can provide a callback URL. We'll send a POST request to this URL as soon as the call completes.
curl -X POST https://api.fetchapi.dev/v1/fetch \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "X-Relay-Callback: https://yourapp.com/webhook" \
-d '{
"url": "https://api.example.com/process",
"method": "POST"
}'Language Examples
While curl is great for testing, you'll likely use FetchAPI within your application code.
JavaScript / TypeScript
const response = await fetch('https://api.fetchapi.dev/v1/fetch', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
url: 'https://api.stripe.com/v1/charges',
method: 'POST',
body: { amount: 2000 }
})
});
const { call_id } = await response.json();Python
import requests
r = requests.post(
'https://api.fetchapi.dev/v1/fetch',
headers={'Authorization': 'Bearer YOUR_API_KEY'},
json={
'url': 'https://api.stripe.com/v1/charges',
'method': 'POST'
}
)
call_id = r.json()['call_id']Conclusion
Setting up FetchAPI is as simple as making an HTTP request. By moving the complexity of retries and persistence to our edge, you can focus on building your core product features.
Ready to build?
Get your API key and start making durable calls in less than a minute.
Get Started Free