Restful (JSON) Api to retrieve data about any country with an admin management console to monitor requests, manage country data, feedbacks, and admin users with roles and permissions, api documentation, api authentication:
Everything on https://restfulcountries.com has its source code available here except the data itself as it is hosted on a live database server.
Curl
curl -I https://restfulcountries.com/api/v1/countries?per_page=1 -H "Accept: application/json" -H "Authorization: Bearer Your-token"
Postman
Request access token to test api endpoints.
See api documentation here - Api Docs
The current release of restful countries is built with Laravel Framework 7.29.3 and might need PHP 7.4+ to run smoothly.
If you wish to run the app for the purpose of contributing or just for personal use, you can follow these steps.
-
Open your terminal and
cd
to any directory of your choicecd your-directory
-
Clone this repository
git clone https://github.com/Naterus/restful-countries.git
-
cd
into the folder created for cloned project:cd restful-countries
-
Install packages with composer
composer install
-
Make a copy of .env.example as .env
cp .env.example .env
verify that .env has key
APP_VERSION=1
or current api version. -
Generate app key
php artisan key:generate
-
Create an empty database and add the database credentials to
.env
fileDB_DATABASE=your_database_name DB_USERNAME=root DB_PASSWORD=your_password
-
Run migration
php artisan migrate
-
Run database seed to create sample data
php artisan db:seed
-
Create a public folder for symbolic link
mkdir storage/app/public
- Create a symbolic link to storage for asset uploads
php artisan storage:link
- Start laravel local server
php artisan serve
-
open http://127.0.0.1:8000/ in your browser, You should see the home page of restful countries.
-
Set up
mailgun
ormailtrap
and add credentials to .env to enable application send api keys to mail. -
Navigate to http://127.0.0.1:8000/administrator/login, enter
[email protected]
as email and12345
as password. you should be logged in as super admin user.
- Create test database
- Ensure you have created
.env.testing
file - Update your database details. Example
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=test_restful_countries
DB_USERNAME=root
DB_PASSWORD=
- Run test by running this command
vendor\bin\phpunit
orcomposer test
This project is far from perfect, If you find a bug, or an optimal way of implementing an existing or new feature, Feel free to fork this repository, modify and create a pull request.
How can you contribute?
- Update api documentation
- Clean code (indentations,variable and function names)
- Modify user interface
- Optimize back-end code
- Fix bug
- Add new feature (Would be merged as new api version).
Note :
-
Ensure code is tested and well written before creating pull request.
-
Pull request should be modularized, you should not have too much code in one pull request. e.g if you are modifying documentation page and admin dashboard page, they should both be in different pull requests.
- To sponsor this project, please visit donation page.
- Help star this github repo.
- Share repository link on twitter and other platforms.
Restful countries is an open-sourced software licensed under the MIT license.