ROOTE Mobility

ROOTE Mobility

Transportation

Real time free-floating object. Une API (Application Programming Interface) est un serveur permettant de distribuer des informations instantanément entre deux machines. Les API sont de plus en plus utilisées dans la programmation car elles permettent une grande flexibilité et surtout une actualisation en temps réel des données. C'est comme si vous faisiez appel à une brique d'intelligence chez quelqu'un qui à déjà pris le temps de réaliser cet algorithme plutôt que de le re-coder entièrement dans votre projet.

Visit API

📚 Documentation & Examples

Everything you need to integrate with ROOTE Mobility

🚀 Quick Start Examples

ROOTE Mobility Javascript Examplejavascript
// ROOTE Mobility API Example
const response = await fetch('https://docs.roote.io/', {
    method: 'GET',
    headers: {
        'Content-Type': 'application/json'
    }
});

const data = await response.json();
console.log(data);

Exploring the Root API using JavaScript

Are you interested in exploring the Root API to access data related to public holidays, employee leaves, and working days? You've come to the right place! In this blog, we will show you how to easily interact with the Root API using JavaScript.

First, let's get started by understanding a few basics. The Root API is RESTful and makes use of HTTP methods like GET, POST, PUT, DELETE, and PATCH to retrieve and manipulate data. We can leverage JavaScript to interact with the API endpoints and get the data we need.

Set up

Before we can start interacting with the Root API, let's get our development environment set up. We will need to install the appropriate libraries using npm.

const axios = require('axios');
const qs = require('querystring');

// Define the Root API endpoint
const ROOT_API_ENDPOINT = 'https://api.roote.io/';

Making requests

Example 1: Get all the public holidays in the US for the year 2022.

const getHolidays = async () => {
  const params = {
    year: 2022,
    country: 'us',
    type: 'public'
  };

  const url = `${ROOT_API_ENDPOINT}holidays?` + qs.stringify(params);
  const response = await axios.get(url);

  console.log(response.data);
};

getHolidays();

Example 2: Get the number of working days in the US in the month of August 2022.

const getWorkingDays = async () => {
  const params = {
    year: 2022,
    month: 8,
    country: 'us',
    type: 'working',
    count: true
  };

  const url = `${ROOT_API_ENDPOINT}calendar?` + qs.stringify(params);
  const response = await axios.get(url);

  console.log(response.data);
};

getWorkingDays();

Example 3: Get all the leave requests for an employee.

const getEmployeeLeaves = async (employeeId) => {
  const url = `${ROOT_API_ENDPOINT}employees/${employeeId}/leaves`;
  const response = await axios.get(url);

  console.log(response.data);
};

getEmployeeLeaves('98765432');

Conclusion

We hope that you have found this blog post helpful in leveraging the Root API using JavaScript. The examples given here are just a few of the many possible ways in which you can interact with the API. Feel free to refer to the official Root API documentation to learn more about the API and explore additional endpoints. Happy coding!

📊 30-Day Uptime History

Daily uptime tracking showing online vs offline minutes

Jul 9Jul 11Jul 13Jul 15Jul 17Jul 19Jul 21Jul 23Jul 25Jul 27Jul 29Jul 31Aug 2Aug 4Aug 704008001440Minutes
Online
Offline

Related APIs in Transportation