This API provides access to resources I've found helpful during my study of web and software development.
Download and manage via rbenv or RVM
gem install rails -v '~> 5.1'
Follow the instructions for downloading PostgreSQL based on your operating system, and be sure to create a database user with privileges.
Clone the repository:
git clone https://github.com/chznbaum/dev-resources-api.git
cd ./dev-resources-api
Install the gems:
bundle install
And set up the database:
rails db:create
rails db:migrate
Start the development server:
rails s
You can test this by making a GET request to localhost:3000
using Postman or an alternative.
The API can be accessed from the URL https://floating-river-84963.herokuapp.com/
followed by the API endpoint.
For example: https://floating-river-84963.herokuapp.com/api/v1/resources/1
Endpoints for creating or updating categories or resources require a JSON Web Token.
Authentication requests must be made to /api/v1/auth/login
, and include an email and a password. Valid login credentials are limited to the API creator at this time.
An example response may look like the following:
{
"access_token": "eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJleHAiOjE1MjA4MjEwNTV9.OwcvXUtkeyK-vyoAUQbSB16AqHRw9rmMfJUeCSXHEJs",
"message": "Login successful."
}
Authentication is not required to access resource or category data.
All valid and properly formatted requests will return a HTTP status of 200. In the JSON response, there will also be a status field that will return "Successful" on such requests.
- URL
/api/v1/auth/login
- Method:
POST
- Data Params:
Required:
email=[string]
password=[string]
- Success Response
- Code: 200
- Content:
{ "access_token": ..., "message": "Login successful." }
- Error Response
- Code: 401
- Content:
{ "error": { "user_authentication": [ "Invalid credentials." ] } }
- URL
/api/v1/resources/
- Method:
GET
- Data Params: Required: none
- Success Response
- Code: 200
- Content:
{ "status": "Success", "message": "Loaded all resources.", "data": [ { "id": 1, "name": ..., "url": ..., "credit": ..., "description": ..., "category_id": ..., "created_at": ..., "updated_at": ... } ] }
- URL
/api/v1/resources/:id
- Method:
GET
- Data Params: Required: none
- Success Response
- Code: 200
- Content:
{ "status": "Success", "message": "Loaded resource: ....", "data": { "id": 1, "name": ..., "url": ..., "credit": ..., "description": ..., "category_id": ..., "created_at": ..., "updated_at": ... } }
- URL
/api/v1/categories/
- Method:
GET
- Data Params: Required: none
- Success Response
- Code: 200
- Content:
{ "status": "Success", "message": "Loaded all categories.", "data": [ { "id": 1, "name": ..., "description": ..., "created_at": ..., "updated_at": ... } ] }
- URL
/api/v1/categories/:id
- Method:
GET
- Data Params: Required: none
- Success Response
- Code: 200
- Content:
{ "status": "Success", "message": "Loaded all categories.", "data": [ { "id": 1, "name": ..., "description": ..., "created_at": ..., "updated_at": ..., "resources": [ { "id": 1, "name": ..., "url": ..., "credit": ..., "description": ..., "category_id": ..., "created_at": ..., "updated_at": ... }, { "id": 1, "name": ..., "url": ..., "credit": ..., "description": ..., "category_id": ..., "created_at": ..., "updated_at": ... } ] } ] }
- Rails - Web Framework
- rbenv - Environment Managemet
- Bundler - Dependency Management
- Heroku - Deployment Platform
- Travis CI - Continuous Integration
- Code Climate - Code Quality Checks
Please read CONTRIBUTING.md for details on the code of conduct, and the process for submitting pull requests.
v. 1.0 - Initial API release
- Chazona Baum - Initial work
This project is licensed under the MIT License - see the LICENSE.md file for more details.