Skip to content

A project for building an API server that returns some infos of Cryptocurrency requesting from an external API to participate the 42Labs program.

License

Notifications You must be signed in to change notification settings

LucasDatilioCarderelli/42Labs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

╔═══════════════════════════════════║═║═══════════╗
║██╗ ██╗ ██████╗ ██╗       ███╗   ██████╗  ██████╗║
║██║ ██║     ██║ ██║      █████╗  ██║ ║██╗ ██╔═══╝║
║██████║ ██████║ ██║     ██   ██╗ █████╔═╝ ██████╗║
║    ██║ ██╔═══╝ ██║     ███████║ ██║ ║██╗     ██║║
║    ██║ ██████╗ ██████╗ ██║  ██║ ██████╔╝ ██████║║
║    ╚═╝ ╚═════╝ ╚═════╝ ╚═╝  ╚═╝ ╚═║═║═╝  ╚═════╝║
╚═════════════════════════════════════════════════╝

Project development for

Linkedin

Description

This is a C project for building an API server that returns some infos of Cryptocurrency like Bitcoin, Etherium and GODS requesting from Mercado Bitcoin, a Brazilian exchange with a public API. To see the documentation click here, to see other public APIs check this repository.

Table of content

Prerequisites

mongoose

Used for create a server in localhost:8000.

get_next_line

Used for parse the log file in cli.

libcurl

Used for request a external API and this local API.

How to Execute

To run this project is recommendable to execute the Makefile to create the API server and the CLI binaries.

$> make all

Compile all objects and executables.

To run the server, execute the program below.

$> ./run_api

Executes the API server in the terminal.

How to test the CLI

Execute the command below to see some information and analytics data of the project.

$> ./my_cli

Options avaliable:
║
╠══ version:    Show Mongoose Version.
╠══ endpoints:  List all coins supported.
╚══ show:       Show the log's summary.

Exemple:

$> ./my_cli show

╔══════════════╦═══════════════╦═══════════════╗
║Total Requests║  HTTP Method  ║      Path     ║
╠══════════════╬═══════════════╬═══════════════╣
║      17      ║      GET      ║      /        ║
║      36      ║      GET      ║      /BTC     ║
║      03      ║      GET      ║      /GODS    ║
║      54      ║     ERROR     ║       404     ║
╚══════════════╩═══════════════╩═══════════════╝

API Requests

http://localhost:8000/{COIN}

[GET] /

Header: HomePage

{"CoinsAvailables":["BTC", "ETH", "BAT", "GODS"]}

[GET] /BTC

Show the current Information of BTC.
Response: application/json

[GET] /ETH

Show the current Information of ETH.
Response: application/json

[GET] /BAT

Show the current Information of BAT.
Response: application/json

[GET] /GODS

Show the current Information of GODS.
Response: application/json

[OK] 200 Response

{
	"ticker": {
		"high": "208000.00000000",
		"low": "196120.88525000",
		"vol": "58.44889346",
		"last": "205851.25000001",
		"buy": "205851.25000000",
		"sell": "205851.25000001",
		"open": "198591.00223001",
		"date": 1645839553
	}
}

[KO] 404 Response

{
	"message":"Page not Found"
}

How to test API

By using:

  • cURL
$> curl localhost:8000 | jq

jq - Command-line JSON processor

  • In any browser.

  • Isomnia or other API Client.

License

This project is under the GNU General Public License v3.

What to do next

  • Implement automatized tests and CI/CD pipelines with Github Actions.
  • Configure a docker environment.
  • Create a Database to store the requests responses.
  • Add more functionalities for the CLI and treat the log.

Reference used for this project: link


thanks to:

to support me.

Contact:

Linkedin

About

A project for building an API server that returns some infos of Cryptocurrency requesting from an external API to participate the 42Labs program.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •