{"id":22196692,"url":"https://github.com/parmaster/currency-api","last_synced_at":"2025-03-24T22:40:25.753Z","repository":{"id":237339997,"uuid":"793572922","full_name":"parMaster/currency-api","owner":"parMaster","description":"Test task - Currency exchange rates API","archived":false,"fork":false,"pushed_at":"2024-05-10T11:15:38.000Z","size":3711,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-10T12:30:43.741Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/parMaster.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-29T13:27:22.000Z","updated_at":"2024-06-19T07:55:31.578Z","dependencies_parsed_at":"2024-05-10T12:30:21.623Z","dependency_job_id":"acb03431-ccbe-4c63-81f3-a36b702a3551","html_url":"https://github.com/parMaster/currency-api","commit_stats":null,"previous_names":["parmaster/currency-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parMaster%2Fcurrency-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parMaster%2Fcurrency-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parMaster%2Fcurrency-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parMaster%2Fcurrency-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/parMaster","download_url":"https://codeload.github.com/parMaster/currency-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245366207,"owners_count":20603438,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-02T14:16:08.416Z","updated_at":"2025-03-24T22:40:25.734Z","avatar_url":"https://github.com/parMaster.png","language":"Go","readme":"# Currency exchange rates API\n\nThis is a simple REST API that provides exchange rates for the specified list of currencies. The exchange rates are obtained from the currencyfreaks.com API and saved in a SQLite database.\n\n## Prerequisites\nPut an API key for the currencyfreaks.com API in the `config.ini` file:\n```bash\napikey = your_api_key\n```\nor pass it as a command line argument:\n```bash\n./bin/api --apikey your_api_key\n```\nor set it as an environment variable:\n```bash\nAPIKEY=your_api_key ./bin/api\n```\n\n## Docker build and run\nCorrect API key should be put in the `config.ini` file before building the docker container.\n\nTo build and run the docker container:\n```bash\ndocker build -t currency-api .\ndocker run -it --rm -p 8080:8080 currency-api\n```\n\nAPI will be available at `http://localhost:8080/`\n\n## Local build and run\n```bash\nmake \u0026\u0026 ./bin/api\n```\nWill start the API server on port 8080\n\n## Configuration\nThe configuration file is `config.ini` in the root of the project - it contains default settings which can be overridden by environment variables or command line arguments:\n\n```bash\nmake \u0026\u0026 ./bin/api --apikey your_api_key --port 8081 --dbpath /tmp/currency-api.db --currencies UAH,USD,EUR,RON --debug\n```\nFull list of configuration options can be listed with `make \u0026\u0026 ./bin/api --help`\n\n## Database\nThe database is created in the file specified in the configuration file. The database schema with sample data is created automatically on the first run of the API server.\n\n## Logging\nThe API logs all requests to the database. Last 10 logs can be viewed with the `/v1/status/` endpoint.\n\n## Testing\n```bash\nmake test\n```\nRuns all available tests\n\n## API endpoints\n`/v1/rates/` - get latest exchange rates for the currencies specified in the config file\n```json\n{\n\t\"date\": \"2024-04-30 00:00:00\",\n\t\"base\": \"USD\",\n\t\"rates\": {\n\t\t\"EUR\": 0.933291146848332,\n\t\t\"RON\": 4.642474983710198,\n\t\t\"UAH\": 39.63845919120639,\n\t\t\"USD\": 1\n\t}\n}\n```\n\n`/v1/rates/\u003cdate\u003e/` - get exchange rates for the specified date (e.g. 2024-04-20)\n```json\n{\n\t\"date\": \"2024-04-20 00:00:00\",\n\t\"base\": \"USD\",\n\t\"rates\": {\n\t\t\"EUR\": 0.8,\n\t\t\"RON\": 4.7,\n\t\t\"UAH\": 39.4\n\t}\n}\n```\n\n`/v1/pair/\u003cpair\u003e/` - get exchange rates for the specified currency pair (e.g. UAH-RON)\n```json\n{\n\t\"date\": \"2024-04-30\",\n\t\"pair\": \"UAH-RON\",\n\t\"rate\": 0.11712047033200801\n}\n```\n\n`/v1/status/` - get the status of the API\n```json\n{\n\t\"status\": \"ok\",\n\t\"version\": \"93952c1-main-20240501\",\n\t\"config\": {\n\t\t\"port\": 8080,\n\t\t\"dbpath\": \"file:/tmp/currency-api.db?mode=rwc\\u0026_journal_mode=WAL\",\n\t\t\"currencies\": \"UAH,USD,EUR,RON\",\n\t\t\"interval\": 3600,\n\t\t\"debug\": true\n\t},\n\t\"logs\": [\n\t\t\"2024-05-01 01:45:39 | pair | pair: UAH-RON\"\n\t]\n}\n```\n\nOriginal job interview test task:\n\n### Implement a REST API with the following functionality\n\n1. Obtaining exchange rates on a third-party API (UAH / EUR / USD / RON). (eg: https://currencyfreaks.com/)\n\n\t1.1 If there was no exchange rate for the current day, get the exchange rate updated at 12:00\n\n\t1.2 Implement saving the exchange rate in the database (Sqlite for start, PostgreSQL for extra points)\n\n2. Implement endpoints:\n\n\t2.1. Receiving rates for a specified date (all 4 currencies)\n\n\t2.2. Obtaining currency pairs: UAH-USD.\n\n3. Implement validation of requests (dates, currency tickers)\n\n4. Implement API access via API key\n\n5. Implement logging of API requests in the database. Save in the logs - date, type of request (by date / by pair)\n\n6. Use docker for the project.\n\n7. When initializing the server, fill the database with initial data on exchange rates for several dates (any values)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparmaster%2Fcurrency-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparmaster%2Fcurrency-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparmaster%2Fcurrency-api/lists"}