Skip to content

Get countries information like states, flag, Covid19 stats, presidents and others via Restful API. Also packed with API monitoring/management Console and api documentation.

License

Notifications You must be signed in to change notification settings

Naterus/restful-countries

Repository files navigation

License

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.

Usage

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.

Documentation

See api documentation here - Api Docs

Running Locally

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.

  1. Open your terminal and cd to any directory of your choice

    cd your-directory
  2. Clone this repository

    git clone https://github.com/Naterus/restful-countries.git
  3. cd into the folder created for cloned project:

    cd restful-countries
  4. Install packages with composer

    composer install
  5. Make a copy of .env.example as .env

    cp .env.example .env

    verify that .env has key APP_VERSION=1 or current api version.

  6. Generate app key

    php artisan key:generate
  7. Create an empty database and add the database credentials to .env file

        DB_DATABASE=your_database_name
        DB_USERNAME=root
        DB_PASSWORD=your_password
    
  8. Run migration

    php artisan migrate
  9. Run database seed to create sample data

    php artisan db:seed
  10. Create a public folder for symbolic link

mkdir storage/app/public
  1. Create a symbolic link to storage for asset uploads
php artisan storage:link
  1. Start laravel local server
php artisan serve
  1. open http://127.0.0.1:8000/ in your browser, You should see the home page of restful countries.

  2. Set up mailgun or mailtrap and add credentials to .env to enable application send api keys to mail.

  3. Navigate to http://127.0.0.1:8000/administrator/login, enter administrator@restfulcountries.com as email and 12345 as password. you should be logged in as super admin user.

Testing

  1. Create test database
  2. Ensure you have created .env.testing file
  3. 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=
  1. Run test by running this command vendor\bin\phpunit or composer test

Contributing

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.

Appreciation

  • To sponsor this project, please visit donation page.
  • Help star this github repo.
  • Share repository link on twitter and other platforms.

License

Restful countries is an open-sourced software licensed under the MIT license.