This Laravel application integrates with the Coinbase API to retrieve cryptocurrency data, store it in your database, and provide real-time feedback on the fetching process.
- Coinbase API Integration: Makes calls to the Coinbase API to fetch crypto data.
- Automatic Data Storage: Uses background jobs to store retrieved data in your database asynchronously.
- Real-Time Feedback: Provides updates on the status of data fetching, including initiation, progress, and completion.
- Laravel: Ensure you have Laravel installed on your development machine. Refer to the official documentation for installation instructions: https://laravel.com/docs/
- Docker: Docker and Docker Compose are required for building and running the application. Detailed installation guides are available at https://www.docker.com/ and https://docs.docker.com/compose/
- Coinbase API Keys: You'll need API keys from your Coinbase developer account. To create API keys:
- Log in to your Coinbase account and navigate to the Developer Dashboard.
- Click on "API Keys" and create a new API key.
- Copy and paste the API key and secret into your
.env
file, following the format provided.
-
Clone the repository:
git clone https://github.com/larrydevofficial/coinbase-api-laravel.git
-
Install dependencies:
cd coinbase-api-laravel composer install
-
Configure environment variables:
Create a file named
.env
in the project root directory. Paste the following lines into the.env
file, replacing with your actual Coinbase API keys:COINBASE_KEY_NAME="organizations/{org_id}/apiKeys/{key_id}" COINBASE_KEY_SECRET="-----BEGIN EC PRIVATE KEY-----\nYOUR PRIVATE KEY\n-----END EC PRIVATE KEY-----\n"
Important:
- Replace
{org_id}
with your organization ID. - Replace
YOUR PRIVATE KEY
with your actual Coinbase API key secret in the correct format.
- Replace
-
Generate application key:
php artisan key:generate
-
Run database migrations:
php artisan migrate
-
Run NPM with HMR (optional): (For development with Hot Module Replacement)
npm run dev
-
Build and start containers:
docker-compose build docker-compose up
-
Access the application:
Open http://localhost in your web browser to access the application.
Note: The actual application endpoint might differ depending on your Laravel project structure. If you've customized the port used by the containers, adjust the URL accordingly (e.g., http://localhost:8000 if port 8000 is mapped).
-
Make changes:
Edit the relevant Laravel code files as needed.
-
Rebuild and restart containers:
docker-compose build docker-compose up -d --build
The
-d
flag instructs Docker Compose to run the containers in detached mode, allowing them to run in the background. The--build
flag ensures that containers are rebuilt if any dependencies have changed. -
Exec into container:
docker compose exec -it app sh
If you do not have Node or Composer installed on the host machine, you will have to
docker exec
into theapp
container to run commands likephp artisan
ornpm run dev
.
-
Run tests:
php artisan test
When the application is functioning correctly, all tests should pass.
-
Run queues:
php artisan queue:work
This application uses queues to process inserting models into the database as well as other tasks.
- This README provides a general guide. Refer to the Laravel and Coinbase API documentation for more details on specific functionalities.
- Consider incorporating security best practices (e.g., sanitization, validation) for user input and API interactions.
- Implement logging for debugging purposes.
- Consider implementing unit and integration tests for comprehensive application testing.