Code Examples

curl, JavaScript and Python snippets

6 min read

Copy-paste examples for the most common API operations. Set FMK to your API key (starts with fmk_).

curl

  • Verify key: curl -H "Authorization: Bearer $FMK" https://freemaint.com/api/v1/public-api/whoami
  • List WOs: curl -H "Authorization: Bearer $FMK" 'https://freemaint.com/api/v1/work-orders?limit=10'
  • GraphQL: curl -X POST -H "Authorization: Bearer $FMK" -H "Content-Type: application/json" -d '{"query":"{ workOrders(limit:5){ id title } }"}' https://freemaint.com/api/v1/graphql

JavaScript (fetch)

const r = await fetch('https://freemaint.com/api/v1/graphql', { method: 'POST', headers: { 'Authorization': `Bearer ${process.env.FMK}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ query: '{ workOrders(limit:5){ id title } }' }) }); const data = await r.json();

Python (requests)

import requests; r = requests.post('https://freemaint.com/api/v1/graphql', headers={'Authorization': f'Bearer {FMK}'}, json={'query': '{ workOrders(limit:5){ id title } }'}); print(r.json())

Python: barcode kiosk

Scan a code, look up the part, then subtract one unit: import requests; H={'Authorization': f'Bearer {FMK}'}; U='https://freemaint.com/api/v1/graphql'; code=input('Scan: '); part=requests.post(U,headers=H,json={'query':'query($c:String!){ part(barcode:$c){ id name description quantity minQuantity maxStockLevel unitOfMeasure imageUrl area location{name} vendor{name website} } }','variables':{'c':code}}).json()['data']['part']; requests.post(U,headers=H,json={'query':'mutation($id:Int!){ adjustStock(id:$id,quantity:-1,reason:"Kiosk"){ id quantity } }','variables':{'id':int(part['id'])}})

Tip

Always check X-RateLimit-Remaining in the response โ€” your integration should warn you before exhausting the daily cap.

Was this page helpful?