{"id":13877869,"url":"https://github.com/ankane/trend-api","last_synced_at":"2025-11-17T14:22:57.592Z","repository":{"id":66166608,"uuid":"237527428","full_name":"ankane/trend-api","owner":"ankane","description":"Anomaly detection and forecasting API","archived":false,"fork":false,"pushed_at":"2025-03-19T07:58:23.000Z","size":60,"stargazers_count":90,"open_issues_count":0,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-31T10:05:53.479Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ankane.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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-01-31T22:31:40.000Z","updated_at":"2025-03-19T07:58:27.000Z","dependencies_parsed_at":"2024-12-24T02:12:43.377Z","dependency_job_id":"52ff7d47-151e-4501-93b4-ee704dc904a2","html_url":"https://github.com/ankane/trend-api","commit_stats":{"total_commits":25,"total_committers":2,"mean_commits":12.5,"dds":0.28,"last_synced_commit":"3891a29e451f4493baa03491dc2ac3281f8596c0"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Ftrend-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Ftrend-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Ftrend-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Ftrend-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ankane","download_url":"https://codeload.github.com/ankane/trend-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247640465,"owners_count":20971557,"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-08-06T08:01:33.423Z","updated_at":"2025-11-17T14:22:52.560Z","avatar_url":"https://github.com/ankane.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"# Trend\n\nAn anomaly detection and forecasting API. Get started quickly with state-of-the-art algorithms.\n\n## Installation\n\n### Docker\n\nAn image is available on [Docker Hub](https://hub.docker.com/r/ankane/trend/). Run:\n\n```sh\ndocker run -ti -p=8000:8000 ankane/trend\n```\n\n### Non-Docker\n\nDownload the latest code\n\n```sh\ngit clone https://github.com/ankane/trend-api.git\ncd trend-api\n```\n\nInstall [Jetpack](https://github.com/ankane/jetpack) and run:\n\n```sh\nRscript -e 'jetpack::install()'\n```\n\nAnd start the server\n\n```sh\nRscript server.R\n```\n\n## Anomaly Detection\n\nDetect anomalies in a time series.\n\n- Works with dates and times\n- Accounts for seasonality and trend\n- Robust to missing values\n\nThe current version uses STL with [multiple seasonal components](https://otexts.org/fpp2/complexseasonality.html#stl-with-multiple-seasonal-periods) for decomposition.\n\n```http\nPOST /anomalies HTTP/1.1\nHost: localhost:8000\nContent-Type: application/json\n\n{\n  \"series\": {\n    \"2025-01-01\": 150,\n    \"2025-01-02\": 125,\n    \"2025-01-03\": 133\n  }\n}\n```\n\nReturns JSON structured like this:\n\n```json\n{\n  \"anomalies\": [\n    \"2025-01-10\",\n    \"2025-01-13\"\n  ]\n}\n```\n\n## Forecasting\n\nGet future predictions for a time series.\n\n- Works with dates and times\n- Accounts for seasonality and trend\n- Robust to missing values\n- No need to remove outliers beforehand\n\nThe current version uses [TBATS](https://robjhyndman.com/papers/ComplexSeasonality.pdf) for predictions.\n\n```http\nPOST /forecast HTTP/1.1\nHost: localhost:8000\nContent-Type: application/json\n\n{\n  \"series\": {\n    \"2025-01-01\": 150,\n    \"2025-01-02\": 125,\n    \"2025-01-03\": 133\n  },\n  \"count\": 3\n}\n```\n\nReturns JSON structured like this:\n\n```json\n{\n  \"forecast\": {\n    \"2025-03-01\": 137.5,\n    \"2025-03-02\": 122.9,\n    \"2025-03-03\": 144.1\n  }\n}\n```\n\nIf you get a [flat or linear forecast](https://robjhyndman.com/hyndsight/flat-forecasts/), this is expected. It means no seasonality is detected in the series.\n\n## Correlation (Experimental)\n\nGet the correlation between two time series.\n\nThe current version uses [normalized cross correlation](https://en.wikipedia.org/wiki/Cross-correlation#Time_series_analysis).\n\n```http\nPOST /correlation HTTP/1.1\nHost: localhost:8000\nContent-Type: application/json\n\n{\n  \"series\": {\n    \"2025-01-01\": 150,\n    \"2025-01-02\": 125,\n    \"2025-01-03\": 133\n  },\n  \"series2\": {\n    \"2025-01-01\": 150,\n    \"2025-01-02\": 176,\n    \"2025-01-03\": 145\n  }\n}\n```\n\nReturns JSON structured like this:\n\n```json\n{\n  \"correlation\": 0.95\n}\n```\n\n## Errors\n\nThe API uses HTTP status codes to indicate errors.\n\nCode | Description\n--- | ---\n400 | There’s an issue with the request parameters\n500 | There’s an issue with the server\n\n\nThe body will contain details about the specific error.\n\n```json\n{\n  \"error\": \"Missing parameter: series\"\n}\n```\n\n## Clients\n\nA client library is available for [Ruby](https://github.com/ankane/trend).\n\nHere’s an example with jQuery:\n\n```js\nvar series = {}, i, date, data;\nfor (i = 1; i \u003c 30; i++) {\n  date = new Date(2025, 1, i);\n  series[date.toISOString()] = date.getDay();\n}\ndata = {series: series};\n\n$.post({\n  url: \"http://localhost:8000/forecast\",\n  data: JSON.stringify(data),\n  dataType: \"json\",\n  contentType: \"application/json\",\n  success: function(resp) { console.log(resp); }\n});\n```\n\n## Credits\n\nA special thanks to [Rob J Hyndman](https://robjhyndman.com) for his incredible work on forecasting. Learn more about the topic from his [free online book](https://otexts.org/fpp2/).\n\n## History\n\nView the [changelog](https://github.com/ankane/trend-api/blob/master/CHANGELOG.md)\n\n## Contributing\n\nEveryone is encouraged to help improve this project. Here are a few ways you can help:\n\n- [Report bugs](https://github.com/ankane/trend-api/issues)\n- Fix bugs and [submit pull requests](https://github.com/ankane/trend-api/pulls)\n- Write, clarify, or fix documentation\n- Suggest or add new features\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankane%2Ftrend-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fankane%2Ftrend-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankane%2Ftrend-api/lists"}