Skip to main content

Quickstart Guide

Get up and running with the Fuuffy API in minutes.

Prerequisites

  • API credentials (Client ID and Client Secret)
  • PHP 7.4 or higher (or your preferred language)
  • cURL or HTTP client library

Step 1: Get Your Credentials

Contact support@fuuffy.com to obtain your API credentials:

  • Client ID
  • Client Secret

Step 2: Authenticate

Obtain an access token using OAuth 2.0:

<?php
function getAccessToken($client_id, $client_secret) {
$ch = curl_init('${API_URL}/v1/oauth/token');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
'grant_type' => 'client_credentials',
'client_id' => $client_id,
'client_secret' => $client_secret,
]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$data = json_decode($response, true);

return $data['access_token'];
}

$access_token = getAccessToken('YOUR_CLIENT_ID', 'YOUR_CLIENT_SECRET');
?>

Step 3: Create Your First Order

<?php
function createOrder($access_token) {
$order_data = [
'sender' => [
'name' => 'John Doe',
'phone' => '+1234567890',
'address' => '123 Main Street, New York, NY 10001, US'
],
'recipient' => [
'name' => 'Jane Smith',
'phone' => '+0987654321',
'address' => '456 Oak Avenue, Los Angeles, CA 90001, US'
],
'package' => [
'weight' => 2.5,
'dimensions' => [
'length' => 30,
'width' => 20,
'height' => 15
]
],
'service_type' => 'express'
];

$ch = curl_init('${API_URL}/v1/orders');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($order_data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $access_token,
'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
return json_decode($response, true);
}

$order = createOrder($access_token);
echo "Order created! Tracking number: " . $order['tracking_number'];
?>

Step 4: Track Your Order

<?php
function trackOrder($access_token, $tracking_number) {
$ch = curl_init("${API_URL}/v1/tracking/{$tracking_number}");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $access_token,
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
return json_decode($response, true);
}

$tracking = trackOrder($access_token, $order['tracking_number']);
echo "Status: " . $tracking['status'];
?>

Complete Example

Here's a complete working example:

<?php
// Configuration
$client_id = getenv('FUUFFY_CLIENT_ID');
$client_secret = getenv('FUUFFY_CLIENT_SECRET');

// Step 1: Get access token
$ch = curl_init('${API_URL}/v1/oauth/token');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
'grant_type' => 'client_credentials',
'client_id' => $client_id,
'client_secret' => $client_secret,
]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$auth_data = json_decode($response, true);
$access_token = $auth_data['access_token'];

echo "✓ Authenticated successfully\n";

// Step 2: Create order
$order_data = [
'sender' => [
'name' => 'John Doe',
'phone' => '+1234567890',
'address' => '123 Main Street, New York, NY 10001, US'
],
'recipient' => [
'name' => 'Jane Smith',
'phone' => '+0987654321',
'address' => '456 Oak Avenue, Los Angeles, CA 90001, US'
],
'package' => [
'weight' => 2.5,
'dimensions' => ['length' => 30, 'width' => 20, 'height' => 15]
],
'service_type' => 'express',
'reference' => 'ORDER-' . time()
];

$ch = curl_init('${API_URL}/v1/orders');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($order_data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $access_token,
'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$order = json_decode($response, true);

echo "✓ Order created: {$order['tracking_number']}\n";
echo "✓ Estimated delivery: {$order['estimated_delivery']}\n";

// Step 3: Track order
$ch = curl_init("${API_URL}/v1/tracking/{$order['tracking_number']}");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $access_token,
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$tracking = json_decode($response, true);

echo "✓ Current status: {$tracking['status']}\n";
?>

Next Steps