import crypto from “crypto”;
import axios from “axios”;
const BASE_URL = “https://quote.freightinsurancefast.com/api/v2/”;
const ACCOUNT_ID = “123”; // your account id
const SECRET_KEY = “abc”; // your secret
function pacificTimestampNow() {
// Build a Date in America/Los_Angeles and extract parts without zero padding
const fmt = new Intl.DateTimeFormat(“en-US”, {
timeZone: “America/Los_Angeles”,
year: “numeric”,
month: “numeric”,
day: “numeric”,
hour: “numeric”,
hour12: false,
});
const parts = Object.fromEntries(fmt.formatToParts(new Date()).map(p => [p.type, p.value]));
return `${parts.year}-${parts.month}-${parts.day}-${parts.hour}`;
}
function makeToken(action) {
const ts = pacificTimestampNow();
const s = `${ACCOUNT_ID}-${SECRET_KEY}-${action}-${ts}`;
return crypto.createHash(“sha1”).update(s, “utf8”).digest(“hex”);
}
No zero-padding in the timestamp (e.g., March → 3, day 5 → 5).
Pacific Time (handles PST/PDT automatically in the examples above).
Always send POST JSON for the quote/cert create/purchase calls, while keeping accountid, action, token in the query string.
Loop back providerid and allconditions_to_agree from quote_prepare into quote_create.
If you tell me which runtime you’ll deploy on (e.g., AWS Lambda Python, Node on Vercel, .NET service), I can tailor one of these into a drop-in module with basic error handling and retries.
API Node.js
Freight Insurance Fast – API documentation: https://quote.freightinsurancefast.com/api/v2/
EXAMPLE Node.js (axios + built-in crypto)
import crypto from “crypto”;
import axios from “axios”;
const BASE_URL = “https://quote.freightinsurancefast.com/api/v2/”;
const ACCOUNT_ID = “123”; // your account id
const SECRET_KEY = “abc”; // your secret
function pacificTimestampNow() {
// Build a Date in America/Los_Angeles and extract parts without zero padding
const fmt = new Intl.DateTimeFormat(“en-US”, {
timeZone: “America/Los_Angeles”,
year: “numeric”,
month: “numeric”,
day: “numeric”,
hour: “numeric”,
hour12: false,
});
const parts = Object.fromEntries(fmt.formatToParts(new Date()).map(p => [p.type, p.value]));
return `${parts.year}-${parts.month}-${parts.day}-${parts.hour}`;
}
function makeToken(action) {
const ts = pacificTimestampNow();
const s = `${ACCOUNT_ID}-${SECRET_KEY}-${action}-${ts}`;
return crypto.createHash(“sha1”).update(s, “utf8”).digest(“hex”);
}
async function get(action, extra = {}) {
const params = { accountid: ACCOUNT_ID, action, token: makeToken(action), …extra };
const { data } = await axios.get(BASE_URL, { params, timeout: 30000 });
return data;
}
async function post(action, body) {
const params = { accountid: ACCOUNT_ID, action, token: makeToken(action) };
const { data } = await axios.post(BASE_URL, body, { params, timeout: 30000 });
return data;
}
// — Sample usage:
(async () => {
console.log(“echo ->”, await get(“echo”, { phrase: “hello LIS-FIF” }));
console.log(“commodities ->”, await get(“commodities”, { term: “furniture” }));
const prepareReq = {
from: 199, to: 199, transmodeid: 1, loadtype: “ltl”,
instotal: 500000, insded: 1000,
commodityid: 1, commoditynotes: “commodity description”,
condition: “Used”, overweight: 0, oversized: 0, reefer: 0, cif: 0
};
const prep = await post(“quote_prepare”, prepareReq);
console.log(“quote_prepare ->”, prep);
const createReq = { …prepareReq, providerid: prep.providerid, agreed_conditions: prep.conditions_to_agree };
const created = await post(“quote_create”, createReq);
console.log(“quote_create ->”, created);
// Purchase (fill required owner fields for your provider)
const purchaseReq = {
quoteid: created.quoteid,
owner: “Bob”,
owneraddr: “1 Main St”,
ownercity: “San Jose”,
ownerprov: “CA”,
ownerzip: “95113”,
ownercountry: “US”,
carrier: “Some other carrier”,
equipmentid: 5,
pieces: 1,
weight: “500 lb”,
shipdate: “2025-8-21”,
fromcity: “San Jose”,
fromstate: “CA”,
tocity: “Houston”,
tostate: “TX”
};
const purchased = await post(“quote_purchase”, purchaseReq);
console.log(“quote_purchase ->”, purchased);
})();
Quick
curlsmoke tests# 1) echo (replace TOKEN with SHA1(accountid-secret-echo-YYYY-M-D-HH Pacific))
curl -sG “https://quote.freightinsurancefast.com/api/v2/” \
–data-urlencode “action=echo” \
–data-urlencode “accountid=123” \
–data-urlencode “token=REPLACE_WITH_TOKEN” \
–data-urlencode “phrase=hello”
# 2) commodities
curl -sG “https://quote.freightinsurancefast.com/api/v2/” \
–data-urlencode “action=commodities” \
–data-urlencode “accountid=123” \
–data-urlencode “token=REPLACE_WITH_TOKEN” \
–data-urlencode “term=furniture”
# 3) quote_prepare (POST JSON body; auth in query)
curl -s “https://quote.freightinsurancefast.com/api/v2/?action=quote_prepare&accountid=123&token=REPLACE_WITH_TOKEN” \
-H “Content-Type: application/json” \
-d ‘{
“from”:199,”to”:199,”transmodeid”:1,”loadtype”:”ltl”,
“instotal”:500000,”insded”:1000,”commodityid”:1,
“commoditynotes”:”commodity description”,”condition”:”Used”,
“overweight”:0,”oversized”:0,”reefer”:0,”cif”:0
}’
Gotchas to avoid
No zero-padding in the timestamp (e.g., March →
3, day 5 →5).Pacific Time (handles PST/PDT automatically in the examples above).
Always send POST JSON for the quote/cert create/purchase calls, while keeping
accountid,action,tokenin the query string.Loop back
provideridand allconditions_to_agreefromquote_prepareintoquote_create.If you tell me which runtime you’ll deploy on (e.g., AWS Lambda Python, Node on Vercel, .NET service), I can tailor one of these into a drop-in module with basic error handling and retries.