Tinq\Tools

Official Tinq.ai PHP SDK.

All URIs are relative to https://tinq.ai/api/v2, except if the operation defines another base path.

MethodHTTP requestDescription
extractTextFromFilePOST /extract-textExtract text from file
extractUrlPOST /extract-articleExtract URL

extractTextFromFile()

extractTextFromFile($content_type, $accept, $input_file)

Extract text from file

This API endpoint allows users to upload a document file in one of the supported formats. The file can be sent either as input_file. The endpoint accepts various document types such as Word, PowerPoint, and PDF, and enforces a file size limit of 10 MB, and returns the text extracted from the document with no formatting.

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');


// Configure Bearer authorization: bearerAuth
$config = Tinq\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');


$apiInstance = new Tinq\Api\Tools(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$content_type = application/json; // string
$accept = application/json; // string
$input_file = "/path/to/file.txt"; // \SplFileObject

try {
    $apiInstance->extractTextFromFile($content_type, $accept, $input_file);
} catch (Exception $e) {
    echo 'Exception when calling Tools->extractTextFromFile: ', $e->getMessage(), PHP_EOL;
}

Parameters

NameTypeDescriptionNotes
content_typestring[optional]
acceptstring[optional]
input_file\SplFileObject**\SplFileObject**[optional]

Return type

void (empty response body)

Authorization

bearerAuth

HTTP request headers

  • Content-Type: multipart/form-data
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

extractUrl()

extractUrl($content_type, $accept, $extract_url)

Extract URL

Article Extractor endpoint. Please use the newer scraper/extract-article for more flexibility.

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');


// Configure Bearer authorization: bearerAuth
$config = Tinq\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');


$apiInstance = new Tinq\Api\Tools(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$content_type = application/json; // string
$accept = application/json; // string
$extract_url = 'extract_url_example'; // string

try {
    $apiInstance->extractUrl($content_type, $accept, $extract_url);
} catch (Exception $e) {
    echo 'Exception when calling Tools->extractUrl: ', $e->getMessage(), PHP_EOL;
}

Parameters

NameTypeDescriptionNotes
content_typestring[optional]
acceptstring[optional]
extract_urlstring[optional]

Return type

void (empty response body)

Authorization

bearerAuth

HTTP request headers

  • Content-Type: multipart/form-data
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]