Home / Cost tools / cURL converter / Dart
cURL to Dart converter
Paste a cURL command and get the same request in Dart, using package:http. It converts in your browser; nothing you paste is sent anywhere.
Converted in your browser. Nothing you paste is stored or sent, so a command with your API key in it stays on your machine.
// pubspec.yaml: http: ^1.2.0
import 'package:http/http.dart' as http;
Future<void> main() async {
final request = http.Request('GET', Uri.parse('https://api.scraper.example/v1/scrape?url=https%3A%2F%2Fshop.example.com%2Fproducts%3Fpage%3D2&render_js=true&country=us'));
request.headers['Authorization'] = 'Bearer YOUR_API_KEY';
final response = await http.Response.fromStream(await request.send());
print(response.statusCode);
print(response.body);
} Install first: dart pub add http
Running the code
Add the http package with dart pub add http and run it with dart run. The request is built as an http.Request so any method, header and body carry over.
Where package:http differs from curl
An http.Request follows redirects for GET and HEAD by default. The response is read in full before the status is printed.
What calls like this one cost
The example is a scraping API call with JavaScript rendering on and a country chosen. 100,000 of them a month cost from $49.00 on ScrapeBadger, and the same pages without rendering from $19.00 on BrowserCloud, the cheapest complete bills across 27 web scraping APIs this site prices from their own pages. What rendering adds on each API