/v0-integrations

v0 and Freightos integration: Step-by-Step Guide 2025

Learn to integrate v0 with Freightos in this step-by-step guide. Enhance your shipping management and boost efficiency with our straightforward integration tips.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free No-Code consultation

How to integrate v0 with Freightos?

 

Step 1: Adding the Freightos Client File

 
  • Create a new file in your project directory and name it freightosClient.ts. This file will contain all the functions needed to communicate with the Freightos API.
  • Copy and paste the following TypeScript code into the new file. This code defines interfaces for the input and response of a freight quote and creates a FreightosClient class to call the Freightos API.

export interface FreightQuoteInput {
  origin: string;
  destination: string;
  cargoDetails: {
    weight: number;
    dimensions: {
      length: number;
      width: number;
      height: number;
    };
  };
}

export interface FreightQuoteResponse {
  quoteId: string;
  price: number;
  currency: string;
  estimatedDelivery: string;
}

export class FreightosClient {
  private apiKey: string;
  private baseUrl: string;

  constructor(apiKey: string, baseUrl: string) {
    this.apiKey = apiKey;
    this.baseUrl = baseUrl;
  }

  async getQuote(input: FreightQuoteInput): Promise {
    const response = await fetch(${this.baseUrl}/quotes, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'Authorization': Bearer ${this.apiKey}
      },
      body: JSON.stringify({
        origin: input.origin,
        destination: input.destination,
        cargoDetails: input.cargoDetails
      })
    });
    if (!response.ok) {
      throw new Error(Error fetching quote: ${response.statusText});
    }
    return await response.json();
  }
}

 

Step 2: Integrating the Freightos Client in Your Main Code

 
  • Open your main TypeScript file where you want to integrate Freightos functionality (for example, main.ts or the relevant file in your project).
  • Insert the following code snippet at an appropriate location where you need to trigger the Freightos API call. This snippet imports the FreightosClient, creates an instance with your API key and base URL, and calls the getQuote method.

// Import the FreightosClient from the file you just created
import { FreightosClient, FreightQuoteInput } from "./freightosClient";

// Replace these with your actual Freightos API key and base URL
const freightosApiKey = "YOURAPIKEY_HERE";
const freightosBaseUrl = "https://api.freightos.com"; // Adjust the URL based on Freightos documentation

// Create an instance of the FreightosClient
const freightosClient = new FreightosClient(freightosApiKey, freightosBaseUrl);

// Function to request a freight quote
async function requestFreightQuote() {
  try {
    // Define your freight quote input (customize these values as needed)
    const input: FreightQuoteInput = {
      origin: "NYC",
      destination: "LAX",
      cargoDetails: {
        weight: 200,
        dimensions: {
          length: 10,
          width: 5,
          height: 3
        }
      }
    };

    // Get the quote from Freightos
    const quote = await freightosClient.getQuote(input);
    console.log("Freight Quote:", quote);
  } catch (error) {
    console.error("Error fetching freight quote:", error);
  }
}

// Call the function to execute the API request
requestFreightQuote();

 

Step 3: Managing Dependencies Without a Terminal

 
  • Since your v0 project does not have a terminal, you cannot run npm install commands directly. Instead, ensure that your project environment supports TypeScript and the Fetch API natively.
  • If the Fetch API is not available in your environment, include a lightweight polyfill by adding the polyfill code directly in your project. For example, you can insert the following snippet at the beginning of your main file:

// Polyfill for fetch if it is not available in your environment
if (typeof fetch !== "function") {
  // Minimal fetch polyfill implementation (for example purposes only)
  const fetch = require('node-fetch');
}
  • If you need to add external dependencies manually, include their compiled JavaScript files in your project and add corresponding script tags in your HTML file.

 

Step 4: Testing the Integration

 
  • Save all your changes in the respective files (freightosClient.ts and your main TypeScript file).
  • Run your v0 project (using your project’s built-in runner). The console should log the freight quote or an error if something is misconfigured.
  • Verify that the API request reaches Freightos and that you see the expected JSON output in your console.

 

Step 5: Final Adjustments and Customization

 
  • Customize the FreightQuoteInput parameters based on your project requirements or additional Freightos API specifications.
  • Add error handling and logging as needed to ensure smooth integration and easier debugging.
  • Ensure your API key and sensitive data are secured; avoid hardcoding them in the source code when deploying to production. Instead, use environment variables if your v0 environment supports reading them from a configuration file.

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022