Hello there, after working a lot on making Abrays codebase open-source, today I'm excited to announce the V2 of Quotes API, which includes better API management with 100% test coverage, User authentication and more.

Abrays Quotes is a collection of Quotes to help make people change their mindset and to motivate one to achieve more in life.

My core vision for Quotes API will remain the same: A API that gives you Quotes from the Abrays for free with no limitations on making API calls. What's new is that we implemented use user authentication, mostly to prevent abuse of API.

How to use this API with JavaScript:

Get the credentials:

  1. Visit https://abrays.imadityang.xyz/signup and get your free account.
  2. If successfully signed up, you'll be redirected to the dashboard, where you can see your credentials.
  3. Before using the credentials to make API requests, you'll need to confirm your email address.
  4. In your dashboard, make a note of Quotes Token, you'll need to send this value with all requests.

To get all the quotes:

You can use fetch API for making AJAX request to the API and then render the results to your HTML. Below is the Code to get all the Quotes.

Note: Remember to replace QuotesToken value with your credentials from the dashboard

<div id="app"></div>

<script type="text/javascript">
    var myHeaders = {
      'Content-Type': 'application/json',
      'Accept': 'abrays/json/v2',
      'User-Agent': 'App Name : Website : Email',
      'QuotesToken': 'xxx'
    };

    fetch('https://abrays.imadityang.xyz/quotes', { method: 'GET', headers: myHeaders})
      .then((response) => {
        return response.json();
      }).then((res) => {
        let arr = [];
        for(let i = 0; i < res.data.length; i++){
          arr.push(res.data[i].content);
        }
        document.getElementById('app').innerHTML = arr;
        console.log(res);
      }).catch((err) => {
        console.log(err);
      });
</script>

To get a Quote with specific ID:

You can also get the Quotes individually by its ID. Below example shows how to get Quote with ID 1, i.e., /quotes/1

<div id="app"></div>

<script type="text/javascript">
    var myHeaders = {
      'Content-Type': 'application/json',
      'Accept': 'abrays/json/v2',
      'User-Agent': 'App Name : Website : Email',
      'QuotesToken': 'xxx'
    };

    fetch('https://abrays.imadityang.xyz/quotes/1', { method: 'GET', headers: myHeaders})
      .then((response) => {
        return response.json();
      }).then((res) => {
        document.getElementById('app').innerHTML = res.data.content;
        console.log(res);
      }).catch((err) => {
        console.log(err);
      });
</script>

Best Practices

  1. It's good to add a header when you make a request to our API with "User-Agent" : "App Name | Website | Email" so that we can monitor your requests to avoid spams and abuse. We'll block requests if we receive many requests w/o adding this header.
  2. This service is free, use it in your apps as much as you can. You need to give credit to "Abrays - https://abrays.imadityang.xyz" in your App/Website.