╔═══════════════════════════════════║═║═══════════╗
║██╗ ██╗ ██████╗ ██╗ ███╗ ██████╗ ██████╗║
║██║ ██║ ██║ ██║ █████╗ ██║ ║██╗ ██╔═══╝║
║██████║ ██████║ ██║ ██ ██╗ █████╔═╝ ██████╗║
║ ██║ ██╔═══╝ ██║ ███████║ ██║ ║██╗ ██║║
║ ██║ ██████╗ ██████╗ ██║ ██║ ██████╔╝ ██████║║
║ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═║═║═╝ ╚═════╝║
╚═════════════════════════════════════════════════╝
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.
Used for create a server in localhost:8000.
Used for parse the log file in cli.
Used for request a external API and this local API.
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.
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 ║
╚══════════════╩═══════════════╩═══════════════╝
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"
}
By using:
- cURL
$> curl localhost:8000 | jq
jq
- Command-line JSON processor
-
In any browser.
-
Isomnia or other API Client.
This project is under the GNU General Public License v3.
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
to support me.thanks to: