{"id":22437036,"url":"https://github.com/blockfrost/blockfrost-scala","last_synced_at":"2025-08-01T15:31:58.676Z","repository":{"id":46280371,"uuid":"394260239","full_name":"blockfrost/blockfrost-scala","owner":"blockfrost","description":"Scala SDK for Blockfrost.io","archived":false,"fork":false,"pushed_at":"2022-11-24T15:53:02.000Z","size":110,"stargazers_count":1,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-30T20:51:53.436Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Scala","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/blockfrost.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}},"created_at":"2021-08-09T11:12:54.000Z","updated_at":"2024-01-09T05:39:54.000Z","dependencies_parsed_at":"2023-01-22T01:45:40.860Z","dependency_job_id":null,"html_url":"https://github.com/blockfrost/blockfrost-scala","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blockfrost%2Fblockfrost-scala","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blockfrost%2Fblockfrost-scala/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blockfrost%2Fblockfrost-scala/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blockfrost%2Fblockfrost-scala/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blockfrost","download_url":"https://codeload.github.com/blockfrost/blockfrost-scala/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228389159,"owners_count":17912189,"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-06T00:10:53.733Z","updated_at":"2024-12-06T00:10:54.309Z","avatar_url":"https://github.com/blockfrost.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Scala CI with SBT](https://github.com/blockfrost/blockfrost-scala/actions/workflows/actions.yml/badge.svg?branch=master)](https://github.com/blockfrost/blockfrost-scala/actions/workflows/actions.yml)\n\n# blockfrost-scala\n\n\u003cbr/\u003e\n\n\u003cp align=\"center\"\u003eA Scala SDK for \u003ca href=\"https://blockfrost.io\"\u003eBlockfrost.io\u003c/a\u003e API.\u003c/p\u003e\n\u003cp align=\"center\"\u003eCompatible with Blockfrost.io OpenAPI version 0.1.27\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"#getting-started\"\u003eGetting started\u003c/a\u003e •\n  \u003ca href=\"#installation\"\u003eInstallation\u003c/a\u003e •\n  \u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n## Getting started\n\nTo use this SDK, you first need to log in to [blockfrost.io](https://blockfrost.io), create your project and retrieve the API token.\n\n\u003cimg src=\"https://i.imgur.com/smY12ro.png\"\u003e\n\n## Installation\n\nTo use blockfrost-scala as a dependency in your scala project you should clone this repository to your dev environment, build artifcat and publish it to your local maven repository:\n\n```\n$\u003e git clone https://github.com/blockfrost/blockfrost-scala.git\n$\u003e cd blockfrost scala\n$\u003e sbt publishLocal\n```\n\n## Usage\n\nAdd blockfrost-scala dependency to your build.sbt\n\n```\nlibraryDependencies += \"io.blockfrost\" %% \"blockfrost-scala\" % \"0.1.1\"\n```\n\nThis library requires one of sttp backend in your classpath. Full list of supported backends: [Supported backends](https://sttp.softwaremill.com/en/latest/backends/summary.html).\n\nBlockfrost-scala library has built-in support for Future sttp backend to transform response type from `Future[Response[Either[ResponseException[String, Exception], R]]]` to `Future[R]` and fetch all pages from APIs with pagination (see `FuturePaginationSupport` and `FutureResponseConverter` classes). Anyway, this library is designed to use it with any other functional effect wrapper like [ZIO](https://github.com/zio/zio), [Monix](https://monix.io/), [Scalaz](https://github.com/scalaz/scalaz), [cats-effect](https://github.com/typelevel/cats-effect), [fs2](https://github.com/typelevel/fs2) etc.\n\nFor this example we will use [async-http-client](https://sttp.softwaremill.com/en/latest/backends/future.html#using-async-http-client) based on Future:\n\n```\nlibraryDependencies += \"com.softwaremill.sttp.client3\" %% \"async-http-client-backend\" % $version,\n```\n\n**Note:** Replace '$version' with the correct version number\n\n#### Following services are available:\n\n- **Cardano**\n  - AccountsApi\n  - AddressesApi\n  - AssetsApi\n  - BlockApi\n  - EpochsApi\n  - HealthApi\n  - LedgerApi\n  - MetadataApi\n  - MetricsApi\n  - NetworkApi\n  - PoolsApi\n  - TransactionsApi\n- **IPFS**\n  - IpfsApi\n- **Nut.link**\n  - NutlinkApi\n\n#### Example application with blockfrost-sdk and Future sttp backend\n\n```scala\nimport io.blockfrost.sdk.BlockfrostClient\nimport io.blockfrost.sdk.api.{AssetsApi, BlockApi, IpfsApi}\nimport io.blockfrost.sdk.common._\nimport io.blockfrost.sdk.util.FuturePaginationSupport\nimport io.blockfrost.sdk.util.FutureResponseConverter.FutureResponseOps\nimport org.json4s.jackson.Serialization\nimport org.json4s.{DefaultFormats, Formats}\nimport sttp.client3.SttpBackend\nimport sttp.client3.asynchttpclient.future.AsyncHttpClientFutureBackend\n\nimport java.io.File\nimport scala.concurrent.ExecutionContext.Implicits.global\nimport scala.concurrent.Future\n\nobject Application extends App {\n\n  implicit val formats: Formats = DefaultFormats\n  implicit val serialization: Serialization.type = Serialization\n  // SDK configuration for http client, concurrent requests and rate limiter\n  implicit val sdkConfig: Config = Config(threadCount = 5, rateLimitPauseMillis = 500, readTimeoutMillis = 5000)\n  // Explicitly pass you API key to the BlockfrostClient or set it to BLOCKFROST_API_KEY env variable\n  val apiKey = \"your-api-key\"\n  val sttpBackend: SttpBackend[Future, Any] = AsyncHttpClientFutureBackend()\n\n  // Instantiate Mainnet BlockfrostClient\n  val cardanoClient = BlockfrostClient[Future, Any](sttpBackend, Mainnet, apiKey)\n\n  // Get latest Cardano block\n  val latestBlockF: Future[BlockApi.BlockContent] = cardanoClient.getLatestBlock.extract\n\n  // Get paginated assets: 10 elements from second page, sorted ascending\n  val assetsPageF: Future[Seq[AssetsApi.AssetShort]] = cardanoClient.getAssets(SortedPageRequest.apply(count = 10, page = 2, order = Asc)).extract\n\n  // Concurrently get all assets from all pages using 5 threads (configured in sdkConfig variable)\n  val allAssetsF: Future[Seq[AssetsApi.AssetShort]] = FuturePaginationSupport.getAllPages((pr: PageRequest) =\u003e cardanoClient.getAssets(pr.asInstanceOf[SortedPageRequest]).extract, Some(Asc))\n\n  // Instantiate IPFS BlockfrostClient\n  val ipfsClient = BlockfrostClient[Future, Any](sttpBackend, IPFS, apiKey)\n\n  // Create IPFS object and pin it\n  val file = new File(\"\u003cpath to file\u003e\")\n  val pinnedIpfsObjectF: Future[IpfsApi.PinnedObject] = ipfsClient.addObject(file).extract.flatMap { ipfsObject =\u003e\n    ipfsClient.pinObject(ipfsObject.ipfs_hash).extract\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblockfrost%2Fblockfrost-scala","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblockfrost%2Fblockfrost-scala","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblockfrost%2Fblockfrost-scala/lists"}