Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

orbimind/orbimind-api

Repository files navigation

Orbimind - where great minds are in the same orbit.

📥 Downloads

⚓ Requirements

  • PHP 8.0.6
  • MySQL 6.x / MariaDB 10.x
  • Composer 2.x

You can easily install those via Homebrew:
brew install php
brew install mysql
brew install composer

🧰 Hosting the API

You can easily host this API on your server if you want to. But if you only want to work with data that is used by officical Orbimind, you can skip this step.

To host the API just follow these steps:

  1. Check the requirements ☝️
  2. Download the latest version
  3. Open folder in your terminal and run composer install
  4. Create your database
  5. Create .env file and fill it with your data accordingly to .env.example file
  6. Run php artisan migrate to fill database with required tables
  7. If you want to add some data to database for testing, run php artisan db:seed
  8. Start the API server with php artisan serve

🔑 Using the API

Web application Orbimind has been released! Check out orbimind-react for more info!

But if you want to use my API directly, without interacting with orbimind-react, you are very welcome!

You can send API requests directly from your JS file using the fetch function, or if you wanna just test some things you can use Insomnia or Postman! If so, you probably should use Insomnia because I have prepared a collection file just for you!
If you are using JavaScript, you should set request header properties Content-Type and Accept to application/json and you are all set.

Public version is hosted at https://orbimind.herokuapp.com

Here's list of possible user API requests:

Authorization module

Action Request Requirements
Register POST - /api/auth/register json data
Login POST - /api/auth/login json data
Refresh token GET - /api/auth/refresh token
Log out POST - /api/auth/logout token
Forgot password POST - /api/auth/password-reset json data (email)
Reset password POST - /api/auth/password-reset/token json data (password)


User module

Action Request Requirements
Show current user GET - /api/users/me token
Show current user favorites GET - /api/users/me/favorites token
Update current user POST - /api/users/me/update token, json data
Update current user avatar POST - /api/users/avatar token, json data (image => binary)
Show specific user GET - /api/users/{user_id} token, user_id
Show specific user favorites GET - /api/users/{user_id}/favorites token, user_id


Posts module

Action Request Requirements
Show all posts GET - /api/posts
Show specific post GET - /api/posts/{post_id} post_id
Create post POST - /api/posts json data
Update post PATCH - /api/posts/{post_id} token, json data
Delete post DELETE - /api/posts/{post_id} token
Show Categories on Post GET - /api/posts/{post_id}/categories post_id
Show Comments on Post GET - /api/posts/{post_id}/comments post_id
Create comment on post POST - /api/posts/{post_id}/comments token, post_id, json data
Show likes/dislikes on post GET - /api/posts/{post_id}/like post_id
Create or delete like/dislike on Post POST - /api/posts/{post_id}/like token, post_id, json data
Delete like on post DELETE - /api/posts/{post_id}/like token, post_id, json data
Add or delete post from favorites POST - /api/posts/{post_id}/favorite token, post_id
Delete post from favorites DELETE - /api/posts/{post_id}/favorite token, post_id
Subscribe or unsubscribe to post updates POST - /api/posts/{post_id}/subscribe token, post_id
Unsubscribe from post updates DELETE - /api/posts/{post_id}/subscribe token, post_id


Categories module

Action Request Requirements
Show all categories (tags) GET - /api/categories
Show specific category (tag) GET - /api/categories/{category_id} category_id
Show all posts associated with category GET - /api/categories/{category_id}/posts category_id


Comments module

Action Request Requirements
Update comment PATCH - /api/comments/{comment_id} token, comment_id
Delete comment DELETE - /api/comments/{comment_id} token, comment_id
Show all likes on comment GET - /api/comments/{comment_id}/like comment_id
Create or delete like on comment POST - /api/comments/{comment_id}/like token, comment_id, json data
Delete like on comment DELETE - /api/comments/{comment_id}/like token, comment_id, json data
Mark or unmark comment as best on post GET - /api/comments/{comment_id}/best token, comment_id

Also it's possible to sort and filter different requests:

Posts module

Applied filters Description
?search={string} Search for posts that contains {string} in their title or content. {string} can be a word or even a letter.
?user={username} Search for posts that was created by {username}.
?category={string} Search for posts that was contains {string} categories. {string} can look like `HTML,JavaScript,React`
?status={integer} Search for posts that was has status true or false. {integer} can be 0 or 1
?startDate={date} Search for posts that was was created after {date}. Can be combined with endDate to create a date interval.
?endDate={int} Search for posts that was was created before {date}. Can be combined with startDate to create a date interval.
?order={string} Get posts ordered by {string}. {string} should look like: date$desc, date$asc, rating$asc, rating$desc
?page={integer} Search for posts that are displayed on {integer} page. Each page contains 10 posts.

Categories module

Applied filters Description
?search={string} Search for categories that contains {string} in their title. {string} can be a word or even a letter.
?limit={int} Get {int} quantity of categories.
?random={int} Get random {int} quantity of categories.

🦊 Have a great day!

Don't forget to check out Orbimind with React!

Also check out my other projects and visit my website!