For a complete documentation of all endpoints offered by the Stuart API, you can visit Stuart API documentation.
$ npm install stuart-client-js --saveconst{
Authenticator,
Environment,
ApiResponse,
HttpClient
}=require('stuart-client-js')constenvironment=Environment.SANDBOX()constapi_client_id='XXXXXXX-XXXXXXXX-XXXXXXX'// can be found here: https://admin-sandbox.stuart.com/client/apiconstapi_client_secret='XXXXXXX-XXXXXXXX-XXXXXXX'// can be found here: https://admin-sandbox.stuart.com/client/apiconstauth=newAuthenticator(environment,api_client_id,api_client_secret)consthttpClient=newHttpClient(auth)constjob={job: {transport_type: "bike",pickups: [{address: "46 Boulevard Barbès, 75018 Paris",comment: "Wait outside for an employee to come.",contact: {firstname: "Martin",lastname: "Pont",phone: "+33698348756'",company: "KFC Paris Barbès"}}],dropoffs: [{address: "156 rue de Charonne, 75011 Paris",package_description: "Red packet.",client_reference: "12345678ABCDE",// must be uniquecomment: "code: 3492B. 3e étage droite. Sonner à Durand.",contact: {firstname: "Alex",lastname: "Durand",phone: "+33634981209",company: "Durand associates."}}]}}httpClient.performPost('/v2/jobs',JSON.stringify(job)).then((apiResponse)=>{console.log(apiResponse)}).catch((error)=>{console.log(error)})httpClient.performGet('/v2/jobs').then((apiResponse)=>{console.log(apiResponse)}).catch((error)=>{console.log(error)})