Public api assets for the fulfillmenttools platform API
We provide ready-to-use API collections for popular HTTP clients to help you get started quickly:
| Client | Folder |
|---|---|
| Postman | postman/ |
| Insomnia | insomnia/ |
| Bruno | bruno/ |
Import the collection file from the respective subfolder into your HTTP client of choice. See Access to fulfillmenttools APIs for instructions.
Ensure you have the latest version of FFT’s api.swagger.yaml in your working directory. You can download it from this link.
wget https://raw.githubusercontent.com/fulfillmenttools/fulfillmenttools-api-reference/refs/heads/master/api.swagger.yamlRun the generator with your preferred target language. For example, to generate a TypeScript client using the Fetch API:
npx @hey-api/openapi-ts -i api.swagger.yaml -o src/client- Initialize a new node project
npm init -y
npm install typescript ts-node node-fetch @types/node- Compile and Integrate the Generated Client
- Copy the
src/clientfolder into your project - Add a tsconfig.json to configure TypeScript if not present:
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"outDir": "./dist",
"esModuleInterop": true,
"strict": true,
"skipLibCheck": true
},
"include": ["./src/client", "./src"]
}- Call an API endpoint
- Create a src/index.ts file and replace placeholders with your tenant information and credentials
import { type ClientOptions, getAllUsers } from "./client";
import { createConfig } from "./client/client";
import { client } from "./client/client.gen";
const options = {
baseUrl: 'https://<tenant>.api.fulfillmenttools.com',
email: '<email>',
password: '<password>',
apiKey: '<api-key>'
}
async function getJwtToken(): Promise<string> {
const url = `https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=${options.apiKey}`;
const res = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
body: JSON.stringify({ email: options.email, password: options.password, returnSecureToken: true,}),
});
if (!res.ok) {
const text = await res.text();
console.error(text);
throw new Error('Error obtaining firebase token, please check credentials.');
}
return (await res.json()).idToken;
}
async function run() {
try {
client.setConfig(createConfig<ClientOptions>({
baseUrl: options.baseUrl,
headers: { Authorization: `Bearer ${await getJwtToken()}` },
}));
const result = await getAllUsers();
console.log(result.data);
} catch (error) {
console.error('Request failed:', error);
}
}
run();- Run the Code
npx ts-node src/index.ts