{"id":25049491,"url":"https://github.com/mauriciorobayo/trm-api","last_synced_at":"2025-08-24T02:23:44.202Z","repository":{"id":36982093,"uuid":"286820038","full_name":"MauricioRobayo/trm-api","owner":"MauricioRobayo","description":"Wrapper to simplify GET requests and JSON response parsing from the Tasa Representativa del Mercado API.","archived":false,"fork":false,"pushed_at":"2025-03-25T03:05:39.000Z","size":3565,"stargazers_count":19,"open_issues_count":5,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-27T19:22:27.521Z","etag":null,"topics":["colombia","colombian-peso","cop","dolar","exchange-rates","tasa-representativa-del-mercado","trm","usd"],"latest_commit_sha":null,"homepage":"https://mauriciorobayo.github.io/trm-api/","language":"TypeScript","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/MauricioRobayo.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":"2020-08-11T18:32:30.000Z","updated_at":"2025-01-23T02:14:10.000Z","dependencies_parsed_at":"2024-02-16T04:22:48.246Z","dependency_job_id":"316da07d-3f88-42e2-b001-1092b17bfeb0","html_url":"https://github.com/MauricioRobayo/trm-api","commit_stats":{"total_commits":664,"total_committers":2,"mean_commits":332.0,"dds":"0.16716867469879515","last_synced_commit":"40e1896ffc2713eda2a3c486ffa3facf5785dc4f"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MauricioRobayo%2Ftrm-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MauricioRobayo%2Ftrm-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MauricioRobayo%2Ftrm-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MauricioRobayo%2Ftrm-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MauricioRobayo","download_url":"https://codeload.github.com/MauricioRobayo/trm-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248829036,"owners_count":21168137,"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":["colombia","colombian-peso","cop","dolar","exchange-rates","tasa-representativa-del-mercado","trm","usd"],"created_at":"2025-02-06T08:19:30.057Z","updated_at":"2025-08-24T02:23:44.191Z","avatar_url":"https://github.com/MauricioRobayo.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TRM API\n\n[![npm version](https://badge.fury.io/js/trm-api.svg)](https://badge.fury.io/js/trm-api)\n\nThe `trm-api` package is a wrapper to simplify GET requests and JSON response parsing from the [Tasa Representativa del Mercado API](https://dev.socrata.com/foundry/www.datos.gov.co/32sa-8pi3).\n\n## Install\n\n```\nnpm install trm-api\n```\n\n## Usage\n\nThe `TrmApi` class provides five methods: [`latest()`](#latest), [`between(options)`](#betweenoptions), [`history(options?)`](#historyoptions), [`date(date)`](#datedate), and [`query(query)`](#queryquery).\n\n### CommonJS\n\n```js\nconst TrmApi = require(\"trm-api\").default;\n\nconst trmApi = new TrmApi();\n```\n\n### ES6 Modules\n\n```js\nimport TrmApi from \"trm-api\";\n\nconst trmApi = new TrmApi();\n```\n\n### TypeScript\n\nThe module is written in TypeScript and type definitions files are included.\n\n### App Token\n\nA limited number of requests can be made without an app token, but they are subject to much lower throttling limits than requests that do include one.\n\nWith an app token, your application is guaranteed access to it's own pool of requests.\n\n👉 [Sign up for an app token!](https://www.datos.gov.co/profile/edit/developer_settings)\n\n![app-token](https://user-images.githubusercontent.com/2121481/90161654-11e0e280-dd59-11ea-9678-4d0a9f995b3c.png)\n\nYou can pass your app token in the constructor:\n\n```js\nconst trmApi = new TrmApi(\"YOUR-APP-TOKEN-HERE\");\n```\n\n### Methods\n\n- [`latest()`](#latest)\n- [`between(options)`](#betweenoptions)\n- [`history(options?)`](#historyoptions)\n- [`date(date)`](#datedate)\n- [`query(query)`](#queryquery).\n\n#### `latest()`\n\nProvides the most recent quote:\n\n```js\ntrmApi\n  .latest()\n  .then((data) =\u003e console.log(data))\n  .catch((error) =\u003e console.log(error));\n```\n\nThe response is a single object with the latest information from the [Tasa Representativa del Mercado API](https://dev.socrata.com/foundry/www.datos.gov.co/32sa-8pi3):\n\n```js\n{\n  valor: '3792.98',\n  unidad: 'COP',\n  vigenciadesde: '2020-08-05T00:00:00.000',\n  vigenciahasta: '2020-08-05T00:00:00.000'\n}\n```\n\n#### `between(options)`\n\nReturns an array with the quotes between two dates: `startAt` and `endAt`.\n\nThe `options` argument is an object with the following fields:\n\n| Field   | Type     | Description                                                          |\n| ------- | -------- | -------------------------------------------------------------------- |\n| startAt | Required | The initial date of the data to be retrieved in `YYYY-MM-DD` format. |\n| endAt   | Required | The final date of the data to be retrieved in `YYYY-MM-DD` format.   |\n| order?  | Optional | Can be `'ASC'` or `'DESC'`. Defaults to `'ASC'`.                     |\n\n```js\ntrmApi\n  .between({ startAt: \"2020-07-02\", endAt: \"2020-07-7\", order: \"DESC\" })\n  .then((data) =\u003e console.log(data))\n  .catch((error) =\u003e console.log(error));\n```\n\nWill return the following array:\n\n```js\n[\n  {\n    valor: \"3633.32\",\n    unidad: \"COP\",\n    vigenciadesde: \"2020-07-07T00:00:00.000\",\n    vigenciahasta: \"2020-07-07T00:00:00.000\",\n  },\n  {\n    valor: \"3645.90\",\n    unidad: \"COP\",\n    vigenciadesde: \"2020-07-04T00:00:00.000\",\n    vigenciahasta: \"2020-07-06T00:00:00.000\",\n  },\n  {\n    valor: \"3660.18\",\n    unidad: \"COP\",\n    vigenciadesde: \"2020-07-03T00:00:00.000\",\n    vigenciahasta: \"2020-07-03T00:00:00.000\",\n  },\n  {\n    valor: \"3723.67\",\n    unidad: \"COP\",\n    vigenciadesde: \"2020-07-02T00:00:00.000\",\n    vigenciahasta: \"2020-07-02T00:00:00.000\",\n  },\n];\n```\n\n#### `history(options?)`\n\nReturns an array with all the values starting from the most recent value.\n\nThe `options` optional argument is an object with the following fields:\n\n| Field  | Type     | Description                                                                |\n| ------ | -------- | -------------------------------------------------------------------------- |\n| order? | Optional | Can be `'ASC'` or `'DESC'`. Defaults to `ASC`.                             |\n| limit? | Optional | Maximum number of results to return. Defaults to 1,000. Maximum of 50,000. |\n\n```js\ntrmApi\n  .history({ limit: 30 })\n  .then((data) =\u003e console.log(data))\n  .catch((error) =\u003e console.log(error));\n```\n\n#### `date(date)`\n\nReturns the TRM for an specific date given in `YYYY-MM-DD` format.\n\n```js\ntrmApi\n  .date(\"2020-08-09\")\n  .then((data) =\u003e console.log(data))\n  .catch((error) =\u003e console.log(error));\n```\n\nThe response is a single object with the information for the given date:\n\n```js\n{\n  valor: '3769.67',\n  unidad: 'COP',\n  vigenciadesde: '2020-08-07T00:00:00.000',\n  vigenciahasta: '2020-08-10T00:00:00.000'\n}\n```\n\n#### `query(query)`\n\nThis method allows you to use any custom [`SoQL query`](https://dev.socrata.com/docs/queries/).\n\nFor example:\n\n```js\ntrmApi\n  .query(\n    \"SELECT valor, vigenciadesde WHERE valor \u003e= 4150 AND vigenciadesde \u003c '2020-08-01'\"\n  )\n  .then((data) =\u003e console.log(data))\n  .catch((error) =\u003e console.log(error));\n```\n\nIt will return an array of objects each with the requested fields (or all the fields if no SELECT clause used):\n\n```js\n[\n  {\n    valor: \"4153.91\",\n    vigenciadesde: \"2020-03-20T00:00:00.000\",\n  },\n];\n```\n\n## CLI\n\nThe packages provides a simple CLI to quickly get TRM quotes.\n\nIf called without arguments it will return the current exchange rate:\n\n```\n$ npx --quiet trm-api\n3767.05\n```\n\nIt can also be called with a given date in `YYYY-MM-DD` format to get the exchange rate for that date:\n\n```\n$ npx --quiet trm-api 2010-09-23\n1803.71\n```\n\n## Contributing\n\nContributions, issues and feature requests are welcome!\n\n## Show your support\n\nGive a ⭐️ if you like this project!\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmauriciorobayo%2Ftrm-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmauriciorobayo%2Ftrm-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmauriciorobayo%2Ftrm-api/lists"}