GithubHelp home page GithubHelp logo

ccapi's Introduction

ccapi - cryptocurrency API 1.0 (develop branch)

Requeriments

  • Apache2 or another similar
  • Composer
  • Laravel 5.7
  • Laravel requires PHP >= 7.1.3
  • Laravel requires PHP Extensions: common, cli, mylsq,OpenSSL, PDO, Mbstring, XML, Ctype, JSON, BCMath
  • Mysql 5.7
  • Git

Configuration (for UNIX, can be different for Windows or Apple)

Virtual host configuration file content

<VirtualHost *:80>        
    ServerAdmin webmaster@localhost
    ServerName dev.cc
    DocumentRoot /home/zuljin/projects/ccapi/public
        
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
        
    <Directory /home/zuljin/projects/ccapi/public>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/ccapi-error.log
    CustomLog ${APACHE_LOG_DIR}/ccapi-access.log combined

    # Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
    LogLevel warn
        
</VirtualHost>

Add virtual host site to Apache following the next steps:

$ cd /etc/apache2/sites-available 
$ sudo vim ccapi.conf 
# copy paste Virtual host configuration file content in step 1
$ sudo a2ensite ccapi.conf 
$ sudo vim etc/hosts
# add a new line with: 
127.0.0.1 dev.cc

alt text

Laravel

  • Please, download the project and use develop branch. Master branch is not maintained.
  • Each command (php artisan) must be executed in the project folder

Check composer.json file to install extra libraries used:

  • guzzle for COINMARKETCAP API communication
  • carbon to work with dates
  • laravel-iso8601-validator specific validator for an isoiso8601 date
  • jwt-auth to secure API
  • faker to generate random users info (name, emails, etc..)

Check .env file for COINMARKETCAP_KEY. Is my personal key, so, i will disable it in a few days.

Run next command to generate tables:

$ php artisan migrate

Populate tables in this order. We need cryptpcoins, some fake users, some cryptocoins historical movements and finally some user trades with coins. We will generate it with theses seeders (more info inside each seeder):

$ php artisan db:seed --class=CryptocurrencyTableSeeder
$ php artisan db:seed --class=PopulateUsersTableSeeder          
$ php artisan db:seed --class=CryptocurrencyHistoricalTableSeeder
$ php artisan db:seed --class=PopulateUserTrade

Using CCAPI and deal with JWT security

CCAPI is secured through a token, you can always use a master user test to obtain a token and use it in the requests, and copy-paste it in all requests:

username: saul.goodman password: goodlawyer

Recommendation: Anyway, within the project, you have everything you need and automated to test it with POSTMAN with dynamic variables. JSON files are included in postman folder, you just need to import it. Then, when you call the authenticate endpoint, automatically the rest of endpoints will have assigned the Bearer token (jwt). Remember, before, to select develop enviroment variables in the top-right tab where you can read no enviroment. Any doubts, contact me!

If you want to run tests, go terminal inside the project an execute:

$ ./vendor/bin/phpunit

phpunit.xml is an important file, also config/database.php because we force to write records not in really database, we use memory option

alt text

ccapi's People

Contributors

zuljin avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.