What is this?

This is a public API using GitHub Pages for the Final Higher Education Project of Multiplatform Application Development. It consists of a series of motivational phrases to help the people using the app, which is an addiction manager.

Can I contribute?

Absolutely! Feel free to add your favorite phrases whether they are religious or not. Use the religion camp on the JSON to clarify it. 1 = Catholic, 0 = non-religious. You can also add new translations or fix possible errors on the current ones.

We are not currently accepting web contributions. There are plans to migrate the documentation to Vue, which may affect the process in the future.

Can I use this for my project?

Yes, you can. You can also fork this and use it however you want.

How can I use this API?

Simply make an HTTP request to:

https://gomezmig03.github.io/MotivationalAPI/[language].json

The current language codes are the following:

Example of an HTTP request to get a random phrase and author in JavaScript

fetch('https://gomezmig03.github.io/MotivationalAPI/en.json')
        .then(response => {
            if (!response.ok) {
                throw new Error('Unable to retrieve data from the server.');
            }
            return response.json();
        })
        .then(data => {
            const randomIndex = Math.floor(Math.random() * data.length);
            const phrase = data[randomIndex].phrase;
            const author = data[randomIndex].author;
            console.log(('quote').textContent = `"${phrase}" - ${author}`);
        })
        .catch(error => {
            console.error('Error:', error);
        });