{"id":27471889,"url":"https://github.com/hihiqy1/modrinth_api_dart","last_synced_at":"2025-04-16T02:01:58.251Z","repository":{"id":113243985,"uuid":"609915575","full_name":"hexaclue/modrinth_api_dart","owner":"hexaclue","description":"An unofficial Modrinth API library for the Dart programming language.","archived":false,"fork":false,"pushed_at":"2023-03-05T16:15:31.000Z","size":69,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T19:05:15.184Z","etag":null,"topics":["dart-package","minecraft","modrinth","modrinth-api"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/modrinth_api","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hexaclue.png","metadata":{"files":{"readme":"readme.md","changelog":"CHANGELOG.md","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}},"created_at":"2023-03-05T16:09:52.000Z","updated_at":"2024-07-02T19:19:27.000Z","dependencies_parsed_at":"2023-08-17T21:30:31.858Z","dependency_job_id":null,"html_url":"https://github.com/hexaclue/modrinth_api_dart","commit_stats":null,"previous_names":["hexaclue/modrinth_api_dart","hihiqy1/modrinth_api_dart"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexaclue%2Fmodrinth_api_dart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexaclue%2Fmodrinth_api_dart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexaclue%2Fmodrinth_api_dart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexaclue%2Fmodrinth_api_dart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hexaclue","download_url":"https://codeload.github.com/hexaclue/modrinth_api_dart/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249183098,"owners_count":21226140,"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":["dart-package","minecraft","modrinth","modrinth-api"],"created_at":"2025-04-16T02:01:31.786Z","updated_at":"2025-04-16T02:01:58.238Z","avatar_url":"https://github.com/hexaclue.png","language":"Dart","funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"# Modrinth API for Dart\nUnofficial package for interacting with the Modrinth API, written in pure Dart!\n\nThis package currently targets Labrinth version `2.7.0` / `3b22f59`.\n\n\u003cbr\u003e\n\n## Features\nFeature                                        | Support\n-----------------------------------------------|------------------------\nSearch facets                                  | ✅\nAlternative Modrinth instance                  | ✅\nGet a version by a file hash                   | ✅\nGet statistics about the Modrinth instance     | ✅\nAutomatic rate limiting                        | ✅\nAny requests that make changes to the database | ❌🕒: planned for v1.0.0\n\n\u003e 🌐 Note: this library assumes an internet connection is available. If there is no connection available, the [underlying http library](https://pub.dev/packages/http) will throw.\n\n\u003cbr\u003e\n\n## Early access\nAs this package is still in a v0 phase, breaking changes could happen at any time.\n\nFor example, currently, most of the functions throw when something is not found. For most of these functions, that makes sense, but for some, where you don't have a clear \"path\" to take (clear path: e.g. search --\u003e project id --\u003e `getProject()`  --\u003e version ids --\u003e `getVersion()`), it also throws, instead of returning a null value. I would like to change that, but the foundation of the functions has been laid, and so using them should work with just a bit of finicking around.\n\n\u003cbr\u003e\n\n## Getting started\nInstall the library into your project like so, in your terminal:\n```sh\ndart pub add modrinth_api\n```\n\nBefore using the API, import and then initialize the API:\n\n```dart\nimport \"package:modrinth_api/modrinth_api.dart\";\n\nvoid main() async {\n  final api = ModrinthApi(project: \"my_test_project\");\n}\n```\n\n\u003e Note that you ***have to*** put in a name for your project (even better: insert your (GitHub) username as well). This makes it easier for the developers of the API to see who is using this package, might something go wrong with rate limiting or the content which is uploaded.\n\nIf you have an API key, you can specify it as such:\n\n```dart\nfinal api = ModrinthApi(\n  project: \"my_test_project\",\n  apiKey: \"my_api_key\",\n);\n```\n\nAdding an API key allows you to access functions such as `getAuthenticatedUser`, `getUserNotifications`, `getUserFollowedProjects` and `getUserPayoutHistory`.\n\nMight you want to use the staging API server - which is perfect for debugging \u0026 testing purposes - or just use another Modrinth instance, you can specify a custom `baseUrl` in the constructor like so:\n\n```dart\nfinal api = ModrinthApi(\n  project: \"my_test_project\",\n  baseUrl: \"https://staging-api.modrinth.com/v2\",\n);\n```\n\nBe sure to also dispose of your `ModrinthApi` instance once you're done using it, to prevent hangs even though your code is done running.\n\n```dart\napi.dispose();\n```\n\n\u003cbr\u003e\n\n## Usage\n### Searching for projects\nSearching can be done with facets. How they work exactly is explained in the [Labrinth docs](https://docs.modrinth.com/docs/tutorials/api_search/#facets).\n\nExample for searching for only mods:\n\n```dart\napi.search(\n  facets: FacetListBuilder()\n    ..and(\n      Facet(FacetType.project_type, \"mod\"),\n    ),\n);\n```\n\nAs such, you can also use `or()` to add multiple facets to filter for any of the provided facets.\n\nExample for searching for any project that is *definitely* a mod (`and()`) and could be targeting version 1.19 *or* 1.19.1 (`or()`), and limit the amount of results to 5.\n\n```dart\nfinal quiteExact = await api.search(\n  facets: FacetListBuilder()\n    ..and(\n      Facet(FacetType.project_type, \"mod\"),\n    )\n    ..or(\n      [\n        Facet(FacetType.versions, \"1.19\"),\n        Facet(FacetType.versions, \"1.19.1\"),\n      ],\n    ),\n  limit: 5,\n);\n```\n\n\u003cbr\u003e\n\n### Get a project by its id or slug\n```dart\nfinal exactProject = await api.getProject(\"P7dR8mSH\");\n// ...Or:\nfinal exactProject = await api.getProject(\"fabric-api\");\n```\n\n\u003cbr\u003e\n\n### Get a version by its id\n```dart\nfinal exactVersion = await api.getVersion(\"nOI7bsDO\");\n```\n\n\u003e Note: you *cannot* use slugs here, as versions don't have slugs.\n\n\u003cbr\u003e\n\n### Get a version by a file hash\nNote that calculating a file hash requires a library, such as [crypto](https://pub.dev/packages/crypto), as used in the following example:\n\n```dart\nimport \"dart:io\";\nimport \"package:crypto/crypto.dart\";\nimport \"package:modrinth_api/modrinth_api.dart\";\n\nvoid main() async {\n  final api = ModrinthApi(project: \"my_test_project\");\n\n  final File f = File(\"my_mod_jar.jar\");\n\n  final List\u003cint\u003e input = await f.readAsBytes();\n\n  final String sha = sha1.convert(input).toString();\n\n  final Version foundVersion = await api.getVersionFromHash(sha);\n}\n```\n\n\u003cbr\u003e\n\n### ...and many more functions!\nThere's many functions in this library, and they are pretty straight-forward to use, in my opinion. Might you need some additional documentation or come across a bug, feel free to open an issue on [the repository](https://github.com/hihiqy1/modrinth_api_dart)!\n\n\u003cbr\u003e\n\n## Credits\nHuge credits to the Labrinth team for writing [their API docs](https://docs.modrinth.com/api-spec)! Without the docs, this package would be near-impossible to make.\n\n\u003cbr\u003e\n\n## License\nThis library is licensed under the Apache License 2.0","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhihiqy1%2Fmodrinth_api_dart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhihiqy1%2Fmodrinth_api_dart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhihiqy1%2Fmodrinth_api_dart/lists"}