Code examples

Node.js

const formData = {
ipAddress: '219.88.232.1',
file: {
value: fs.createReadStream(dest),
options: {
filename: message.file.name,
contentType: message.file.mimetype
}
}
};
request.post({
url: 'https://api.taggun.io/api/receipt/v1/verbose/file', formData,
headers: { apikey: 'yourapikey' }
}, (err, httpResponse, body) => {
if (err) {
return console.error('upload failed:', err);
}
console.log('Upload successful! Server responded with:', body);
});

C# or .NET

See sample code for Taggun client in .NET C# here

CURL

curl -X POST --header 'Content-Type: multipart/form-data' --header 'Accept: application/json' --header 'apikey: yourapikey' 'https://api.taggun.io/api/receipt/v1/verbose/file' -F 'file=@/file.jpg'

PHP

<?php
$filename = realpath( './uploads/20.jpg' );
$cfile = new CurlFile( $filename, 'image/jpeg', $filename );
$data = array( 'file' => $cfile );
$taggun_endpoint = 'https://api.taggun.io/api/receipt/v1/simple/file';
$ch = curl_init();
$options = array(
CURLOPT_URL => $taggun_endpoint,
CURLOPT_RETURNTRANSFER => true,
CURLINFO_HEADER_OUT => true,
CURLOPT_HEADER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => array(
'apikey: YOUR API KEY',
'Accept: application/json',
'Content-Type: multipart/form-data',
),
CURLOPT_POSTFIELDS => $data,
);
curl_setopt_array( $ch, $options );
$result = curl_exec( $ch );
$header_info = curl_getinfo( $ch, CURLINFO_HEADER_OUT );
$header_size = curl_getinfo( $ch, CURLINFO_HEADER_SIZE );
$header = substr( $result, 0, $header_size );
$body = substr( $result, $header_size );
curl_close( $ch );
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>File Upload results</title>
</head>
<body>
<p>Raw Result: <?php echo $result; ?>
<p>Header Sent: <?php echo $header_info; ?></p>
<p>Header Received: <?php echo $header; ?></p>
<p>Body: <?php echo $body; ?></p>
</body>
</html>

python

import requests
url = 'https://api.taggun.io/api/receipt/v1/simple/file'
headers = {'apikey': 'yourapikey'}
files = {
'file': (
'1_Dinner.jpg', # set a filename for the file
open('1_Dinner.jpg', 'rb'), # the actual file
'image/jpg'), # content-type for the file
# other optional parameters for Taggun API (eg: incognito, refresh, ipAddress, language)
'incognito': (
None, #set filename to none for optional parameters
'false') #value for the parameters
}
response = requests.post(url, files=files, headers=headers)
print(response.content)