Code Detector identifies the programming language of any submitted code snippet. It returns the canonical language name, readable title, and standard file extension for the detected code.
Install via Composer:
composer require apiverve/codedetectorGet your API key at APIVerve
<?php
require_once 'vendor/autoload.php';
use APIVerve\Codedetector\Client;
// Initialize the client
$client = new Client('YOUR_API_KEY');
// Make a request
$response = $client->execute(['code' => 'a = 5
b = 6
c = 7
# calculate the semi-perimeter
s = (a + b + c) / 2
# calculate the area
area = (s*(s-a)*(s-b)*(s-c)) ** 0.5
print(\'The area of the triangle is %0.2f\' %area)']);
// Print the response
print_r($response);use APIVerve\Codedetector\Client;
use APIVerve\Codedetector\Exceptions\APIException;
use APIVerve\Codedetector\Exceptions\ValidationException;
try {
$response = $client->execute(['code' => 'a = 5
b = 6
c = 7
# calculate the semi-perimeter
s = (a + b + c) / 2
# calculate the area
area = (s*(s-a)*(s-b)*(s-c)) ** 0.5
print(\'The area of the triangle is %0.2f\' %area)']);
print_r($response['data']);
} catch (ValidationException $e) {
echo "Validation error: " . implode(', ', $e->getErrors());
} catch (APIException $e) {
echo "API error: " . $e->getMessage();
echo "Status code: " . $e->getStatusCode();
}// Enable debug logging
$client = new Client(
apiKey: 'YOUR_API_KEY',
debug: true
);{
"status": "ok",
"error": null,
"data": {
"likelihood": 0.99,
"family": "PYTHON",
"current": "python",
"readable": "Python Code",
"extension": ".py",
"paradigm": "multi-paradigm",
"isCompiled": false
}
}- PHP 7.4 or higher
- Guzzle HTTP client
For more information, visit the API Documentation.
- Website: https://apiverve.com/marketplace/codedetector?utm_source=php&utm_medium=referral&utm_content=readme
- Email: hello@apiverve.com
This package is available under the MIT License.