API Documentation

This tool provides a simple and easy-to-use API that can be integrated into your application for automated parsing and conversion of curl commands.

API Endpoint

POST /api/convert

Use the following HTTP request method and path to access the API:

POST https://curl-to.com/api/convert

Request Format

The request body should be in JSON format, containing a `curl` field with the curl command string to be parsed:

Request Example

{
  "curl": "curl -X POST https://api.example.com/users -H 'Content-Type: application/json' -d '{\"name\":\"John\",\"email\":\"[email protected]\"}'"
}

Response Format

The response is a structured JSON object containing the following fields:

  • method - HTTP request method
  • url - Request URL
  • headers - Request headers
  • data - Request data

Response Example

{
  "method": "POST",
  "url": "https://api.example.com/users",
  "headers": {
    "Content-Type": "application/json"
  },
  "data": {
    "name": "John",
    "email": "[email protected]"
  }
}

Usage Examples

Python

import requests
import json

url = "https://curl-to.com/api/convert"
payload = {
    "curl": "curl -X POST https://api.example.com/users -H 'Content-Type: application/json' -d '{\"name\":\"John\",\"email\":\"[email protected]\"}'"
}

response = requests.post(url, json=payload)
result = response.json()
print(json.dumps(result, indent=2))

JavaScript

const url = 'https://curl-to.com/api/convert';
const payload = {
  curl: `curl -X POST https://api.example.com/users -H 'Content-Type: application/json' -d '{"name":"John","email":"[email protected]"}'`
};

fetch(url, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(payload),
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

PHP

<?php
$url = 'https://curl-to.com/api/convert';
$payload = [
    'curl' => 'curl -X POST https://api.example.com/users -H \'Content-Type: application/json\' -d \'{"name":"John","email":"[email protected]"}\''
];

$options = [
    'http' => [
        'method'  => 'POST',
        'header'  => 'Content-Type: application/json',
        'content' => json_encode($payload)
    ]
];

$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
$response = json_decode($result, true);

print_r($response);
?>